]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.9.4-201305292151.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.9.4-201305292151.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..b47493f 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,6 +75,7 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 @@ -80,6 +87,7 @@ aic7*seq.h*
53 aicasm
54 aicdb.h*
55 altivec*.c
56 +ashldi3.S
57 asm-offsets.h
58 asm_offsets.h
59 autoconf.h*
60 @@ -92,19 +100,24 @@ bounds.h
61 bsetup
62 btfixupprep
63 build
64 +builtin-policy.h
65 bvmlinux
66 bzImage*
67 capability_names.h
68 capflags.c
69 classlist.h*
70 +clut_vga16.c
71 +common-cmds.h
72 comp*.log
73 compile.h*
74 conf
75 config
76 config-*
77 config_data.h*
78 +config.c
79 config.mak
80 config.mak.autogen
81 +config.tmp
82 conmakehash
83 consolemap_deftbl.c*
84 cpustr.h
85 @@ -115,9 +128,11 @@ devlist.h*
86 dnotify_test
87 docproc
88 dslm
89 +dtc-lexer.lex.c
90 elf2ecoff
91 elfconfig.h*
92 evergreen_reg_safe.h
93 +exception_policy.conf
94 fixdep
95 flask.h
96 fore200e_mkfirm
97 @@ -125,12 +140,15 @@ fore200e_pca_fw.c*
98 gconf
99 gconf.glade.h
100 gen-devlist
101 +gen-kdb_cmds.c
102 gen_crc32table
103 gen_init_cpio
104 generated
105 genheaders
106 genksyms
107 *_gray256.c
108 +hash
109 +hid-example
110 hpet_example
111 hugepage-mmap
112 hugepage-shm
113 @@ -145,14 +163,14 @@ int32.c
114 int4.c
115 int8.c
116 kallsyms
117 -kconfig
118 +kern_constants.h
119 keywords.c
120 ksym.c*
121 ksym.h*
122 kxgettext
123 lex.c
124 lex.*.c
125 -linux
126 +lib1funcs.S
127 logo_*.c
128 logo_*_clut224.c
129 logo_*_mono.c
130 @@ -162,14 +180,15 @@ mach-types.h
131 machtypes.h
132 map
133 map_hugetlb
134 -media
135 mconf
136 +mdp
137 miboot*
138 mk_elfconfig
139 mkboot
140 mkbugboot
141 mkcpustr
142 mkdep
143 +mkpiggy
144 mkprep
145 mkregtable
146 mktables
147 @@ -185,6 +204,8 @@ oui.c*
148 page-types
149 parse.c
150 parse.h
151 +parse-events*
152 +pasyms.h
153 patches*
154 pca200e.bin
155 pca200e_ecd.bin2
156 @@ -194,6 +215,7 @@ perf-archive
157 piggyback
158 piggy.gzip
159 piggy.S
160 +pmu-*
161 pnmtologo
162 ppc_defs.h*
163 pss_boot.h
164 @@ -203,7 +225,10 @@ r200_reg_safe.h
165 r300_reg_safe.h
166 r420_reg_safe.h
167 r600_reg_safe.h
168 +realmode.lds
169 +realmode.relocs
170 recordmcount
171 +regdb.c
172 relocs
173 rlim_names.h
174 rn50_reg_safe.h
175 @@ -213,8 +238,12 @@ series
176 setup
177 setup.bin
178 setup.elf
179 +signing_key*
180 +size_overflow_hash.h
181 sImage
182 +slabinfo
183 sm_tbl*
184 +sortextable
185 split-include
186 syscalltab.h
187 tables.c
188 @@ -224,6 +253,7 @@ tftpboot.img
189 timeconst.h
190 times.h*
191 trix_boot.h
192 +user_constants.h
193 utsrelease.h*
194 vdso-syms.lds
195 vdso.lds
196 @@ -235,13 +265,17 @@ vdso32.lds
197 vdso32.so.dbg
198 vdso64.lds
199 vdso64.so.dbg
200 +vdsox32.lds
201 +vdsox32-syms.lds
202 version.h*
203 vmImage
204 vmlinux
205 vmlinux-*
206 vmlinux.aout
207 vmlinux.bin.all
208 +vmlinux.bin.bz2
209 vmlinux.lds
210 +vmlinux.relocs
211 vmlinuz
212 voffset.h
213 vsyscall.lds
214 @@ -249,9 +283,12 @@ vsyscall_32.lds
215 wanxlfw.inc
216 uImage
217 unifdef
218 +utsrelease.h
219 wakeup.bin
220 wakeup.elf
221 wakeup.lds
222 +x509*
223 zImage*
224 zconf.hash.c
225 +zconf.lex.c
226 zoffset.h
227 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
228 index 8ccbf27..afffeb4 100644
229 --- a/Documentation/kernel-parameters.txt
230 +++ b/Documentation/kernel-parameters.txt
231 @@ -948,6 +948,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
232 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
233 Default: 1024
234
235 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
236 + ignore grsecurity's /proc restrictions
237 +
238 +
239 hashdist= [KNL,NUMA] Large hashes allocated during boot
240 are distributed across NUMA nodes. Defaults on
241 for 64-bit NUMA, off otherwise.
242 @@ -2147,6 +2151,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
243 the specified number of seconds. This is to be used if
244 your oopses keep scrolling off the screen.
245
246 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
247 + virtualization environments that don't cope well with the
248 + expand down segment used by UDEREF on X86-32 or the frequent
249 + page table updates on X86-64.
250 +
251 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
252 +
253 + pax_extra_latent_entropy
254 + Enable a very simple form of latent entropy extraction
255 + from the first 4GB of memory as the bootmem allocator
256 + passes the memory pages to the buddy allocator.
257 +
258 pcbit= [HW,ISDN]
259
260 pcd. [PARIDE]
261 diff --git a/Makefile b/Makefile
262 index bfbfaf9..d0b1bb8 100644
263 --- a/Makefile
264 +++ b/Makefile
265 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
266
267 HOSTCC = gcc
268 HOSTCXX = g++
269 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
270 -HOSTCXXFLAGS = -O2
271 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
272 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
273 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
274
275 # Decide whether to build built-in, modular, or both.
276 # Normally, just do built-in.
277 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
278 # Rules shared between *config targets and build targets
279
280 # Basic helpers built in scripts/
281 -PHONY += scripts_basic
282 -scripts_basic:
283 +PHONY += scripts_basic gcc-plugins
284 +scripts_basic: gcc-plugins
285 $(Q)$(MAKE) $(build)=scripts/basic
286 $(Q)rm -f .tmp_quiet_recordmcount
287
288 @@ -576,6 +577,65 @@ else
289 KBUILD_CFLAGS += -O2
290 endif
291
292 +ifndef DISABLE_PAX_PLUGINS
293 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
294 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
295 +else
296 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
297 +endif
298 +ifneq ($(PLUGINCC),)
299 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
300 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
301 +endif
302 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
303 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
304 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
305 +endif
306 +ifdef CONFIG_KALLOCSTAT_PLUGIN
307 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
308 +endif
309 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
310 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
311 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
312 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
313 +endif
314 +ifdef CONFIG_CHECKER_PLUGIN
315 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
316 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
317 +endif
318 +endif
319 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
320 +ifdef CONFIG_PAX_SIZE_OVERFLOW
321 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
322 +endif
323 +ifdef CONFIG_PAX_LATENT_ENTROPY
324 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
325 +endif
326 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
327 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
328 +endif
329 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
330 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
331 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
332 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
333 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
334 +ifeq ($(KBUILD_EXTMOD),)
335 +gcc-plugins:
336 + $(Q)$(MAKE) $(build)=tools/gcc
337 +else
338 +gcc-plugins: ;
339 +endif
340 +else
341 +gcc-plugins:
342 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
343 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
344 +else
345 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
346 +endif
347 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
348 +endif
349 +endif
350 +
351 include $(srctree)/arch/$(SRCARCH)/Makefile
352
353 ifdef CONFIG_READABLE_ASM
354 @@ -733,7 +793,7 @@ export mod_sign_cmd
355
356
357 ifeq ($(KBUILD_EXTMOD),)
358 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
359 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
360
361 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
362 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
363 @@ -780,6 +840,8 @@ endif
364
365 # The actual objects are generated when descending,
366 # make sure no implicit rule kicks in
367 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
368 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
369 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
370
371 # Handle descending into subdirectories listed in $(vmlinux-dirs)
372 @@ -789,7 +851,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
373 # Error messages still appears in the original language
374
375 PHONY += $(vmlinux-dirs)
376 -$(vmlinux-dirs): prepare scripts
377 +$(vmlinux-dirs): gcc-plugins prepare scripts
378 $(Q)$(MAKE) $(build)=$@
379
380 # Store (new) KERNELRELASE string in include/config/kernel.release
381 @@ -833,6 +895,7 @@ prepare0: archprepare FORCE
382 $(Q)$(MAKE) $(build)=.
383
384 # All the preparing..
385 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
386 prepare: prepare0
387
388 # Generate some files
389 @@ -940,6 +1003,8 @@ all: modules
390 # using awk while concatenating to the final file.
391
392 PHONY += modules
393 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
394 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
395 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
396 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
397 @$(kecho) ' Building modules, stage 2.';
398 @@ -955,7 +1020,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
399
400 # Target to prepare building external modules
401 PHONY += modules_prepare
402 -modules_prepare: prepare scripts
403 +modules_prepare: gcc-plugins prepare scripts
404
405 # Target to install modules
406 PHONY += modules_install
407 @@ -1021,7 +1086,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
408 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
409 signing_key.priv signing_key.x509 x509.genkey \
410 extra_certificates signing_key.x509.keyid \
411 - signing_key.x509.signer
412 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
413
414 # clean - Delete most, but leave enough to build external modules
415 #
416 @@ -1061,6 +1126,7 @@ distclean: mrproper
417 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
418 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
419 -o -name '.*.rej' \
420 + -o -name '.*.rej' -o -name '*.so' \
421 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
422 -type f -print | xargs rm -f
423
424 @@ -1221,6 +1287,8 @@ PHONY += $(module-dirs) modules
425 $(module-dirs): crmodverdir $(objtree)/Module.symvers
426 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
427
428 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
429 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
430 modules: $(module-dirs)
431 @$(kecho) ' Building modules, stage 2.';
432 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
433 @@ -1357,17 +1425,21 @@ else
434 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
435 endif
436
437 -%.s: %.c prepare scripts FORCE
438 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
439 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
440 +%.s: %.c gcc-plugins prepare scripts FORCE
441 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
442 %.i: %.c prepare scripts FORCE
443 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
444 -%.o: %.c prepare scripts FORCE
445 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
446 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
447 +%.o: %.c gcc-plugins prepare scripts FORCE
448 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
449 %.lst: %.c prepare scripts FORCE
450 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
451 -%.s: %.S prepare scripts FORCE
452 +%.s: %.S gcc-plugins prepare scripts FORCE
453 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
454 -%.o: %.S prepare scripts FORCE
455 +%.o: %.S gcc-plugins prepare scripts FORCE
456 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
457 %.symtypes: %.c prepare scripts FORCE
458 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
459 @@ -1377,11 +1449,15 @@ endif
460 $(cmd_crmodverdir)
461 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
462 $(build)=$(build-dir)
463 -%/: prepare scripts FORCE
464 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
465 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
466 +%/: gcc-plugins prepare scripts FORCE
467 $(cmd_crmodverdir)
468 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
469 $(build)=$(build-dir)
470 -%.ko: prepare scripts FORCE
471 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
472 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
473 +%.ko: gcc-plugins prepare scripts FORCE
474 $(cmd_crmodverdir)
475 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
476 $(build)=$(build-dir) $(@:.ko=.o)
477 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
478 index c2cbe4f..f7264b4 100644
479 --- a/arch/alpha/include/asm/atomic.h
480 +++ b/arch/alpha/include/asm/atomic.h
481 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
482 #define atomic_dec(v) atomic_sub(1,(v))
483 #define atomic64_dec(v) atomic64_sub(1,(v))
484
485 +#define atomic64_read_unchecked(v) atomic64_read(v)
486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
494 +
495 #define smp_mb__before_atomic_dec() smp_mb()
496 #define smp_mb__after_atomic_dec() smp_mb()
497 #define smp_mb__before_atomic_inc() smp_mb()
498 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
499 index ad368a9..fbe0f25 100644
500 --- a/arch/alpha/include/asm/cache.h
501 +++ b/arch/alpha/include/asm/cache.h
502 @@ -4,19 +4,19 @@
503 #ifndef __ARCH_ALPHA_CACHE_H
504 #define __ARCH_ALPHA_CACHE_H
505
506 +#include <linux/const.h>
507
508 /* Bytes per L1 (data) cache line. */
509 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
510 -# define L1_CACHE_BYTES 64
511 # define L1_CACHE_SHIFT 6
512 #else
513 /* Both EV4 and EV5 are write-through, read-allocate,
514 direct-mapped, physical.
515 */
516 -# define L1_CACHE_BYTES 32
517 # define L1_CACHE_SHIFT 5
518 #endif
519
520 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
521 #define SMP_CACHE_BYTES L1_CACHE_BYTES
522
523 #endif
524 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
525 index 968d999..d36b2df 100644
526 --- a/arch/alpha/include/asm/elf.h
527 +++ b/arch/alpha/include/asm/elf.h
528 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
529
530 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
531
532 +#ifdef CONFIG_PAX_ASLR
533 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
534 +
535 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
536 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
537 +#endif
538 +
539 /* $0 is set by ld.so to a pointer to a function which might be
540 registered using atexit. This provides a mean for the dynamic
541 linker to call DT_FINI functions for shared libraries that have
542 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
543 index bc2a0da..8ad11ee 100644
544 --- a/arch/alpha/include/asm/pgalloc.h
545 +++ b/arch/alpha/include/asm/pgalloc.h
546 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
547 pgd_set(pgd, pmd);
548 }
549
550 +static inline void
551 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
552 +{
553 + pgd_populate(mm, pgd, pmd);
554 +}
555 +
556 extern pgd_t *pgd_alloc(struct mm_struct *mm);
557
558 static inline void
559 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
560 index 81a4342..348b927 100644
561 --- a/arch/alpha/include/asm/pgtable.h
562 +++ b/arch/alpha/include/asm/pgtable.h
563 @@ -102,6 +102,17 @@ struct vm_area_struct;
564 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
565 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
566 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
567 +
568 +#ifdef CONFIG_PAX_PAGEEXEC
569 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
570 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
571 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
572 +#else
573 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
574 +# define PAGE_COPY_NOEXEC PAGE_COPY
575 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
576 +#endif
577 +
578 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
579
580 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
581 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
582 index 2fd00b7..cfd5069 100644
583 --- a/arch/alpha/kernel/module.c
584 +++ b/arch/alpha/kernel/module.c
585 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
586
587 /* The small sections were sorted to the end of the segment.
588 The following should definitely cover them. */
589 - gp = (u64)me->module_core + me->core_size - 0x8000;
590 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
591 got = sechdrs[me->arch.gotsecindex].sh_addr;
592
593 for (i = 0; i < n; i++) {
594 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
595 index b9e37ad..44c24e7 100644
596 --- a/arch/alpha/kernel/osf_sys.c
597 +++ b/arch/alpha/kernel/osf_sys.c
598 @@ -1297,10 +1297,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
599 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
600
601 static unsigned long
602 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
603 - unsigned long limit)
604 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
605 + unsigned long limit, unsigned long flags)
606 {
607 struct vm_unmapped_area_info info;
608 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
609
610 info.flags = 0;
611 info.length = len;
612 @@ -1308,6 +1309,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
613 info.high_limit = limit;
614 info.align_mask = 0;
615 info.align_offset = 0;
616 + info.threadstack_offset = offset;
617 return vm_unmapped_area(&info);
618 }
619
620 @@ -1340,20 +1342,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
621 merely specific addresses, but regions of memory -- perhaps
622 this feature should be incorporated into all ports? */
623
624 +#ifdef CONFIG_PAX_RANDMMAP
625 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
626 +#endif
627 +
628 if (addr) {
629 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
630 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
631 if (addr != (unsigned long) -ENOMEM)
632 return addr;
633 }
634
635 /* Next, try allocating at TASK_UNMAPPED_BASE. */
636 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
637 - len, limit);
638 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
639 +
640 if (addr != (unsigned long) -ENOMEM)
641 return addr;
642
643 /* Finally, try allocating in low memory. */
644 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
645 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
646
647 return addr;
648 }
649 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
650 index 0c4132d..88f0d53 100644
651 --- a/arch/alpha/mm/fault.c
652 +++ b/arch/alpha/mm/fault.c
653 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
654 __reload_thread(pcb);
655 }
656
657 +#ifdef CONFIG_PAX_PAGEEXEC
658 +/*
659 + * PaX: decide what to do with offenders (regs->pc = fault address)
660 + *
661 + * returns 1 when task should be killed
662 + * 2 when patched PLT trampoline was detected
663 + * 3 when unpatched PLT trampoline was detected
664 + */
665 +static int pax_handle_fetch_fault(struct pt_regs *regs)
666 +{
667 +
668 +#ifdef CONFIG_PAX_EMUPLT
669 + int err;
670 +
671 + do { /* PaX: patched PLT emulation #1 */
672 + unsigned int ldah, ldq, jmp;
673 +
674 + err = get_user(ldah, (unsigned int *)regs->pc);
675 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
676 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
677 +
678 + if (err)
679 + break;
680 +
681 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
682 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
683 + jmp == 0x6BFB0000U)
684 + {
685 + unsigned long r27, addr;
686 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
687 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
688 +
689 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
690 + err = get_user(r27, (unsigned long *)addr);
691 + if (err)
692 + break;
693 +
694 + regs->r27 = r27;
695 + regs->pc = r27;
696 + return 2;
697 + }
698 + } while (0);
699 +
700 + do { /* PaX: patched PLT emulation #2 */
701 + unsigned int ldah, lda, br;
702 +
703 + err = get_user(ldah, (unsigned int *)regs->pc);
704 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
705 + err |= get_user(br, (unsigned int *)(regs->pc+8));
706 +
707 + if (err)
708 + break;
709 +
710 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
711 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
712 + (br & 0xFFE00000U) == 0xC3E00000U)
713 + {
714 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
715 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
716 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
717 +
718 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
719 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
720 + return 2;
721 + }
722 + } while (0);
723 +
724 + do { /* PaX: unpatched PLT emulation */
725 + unsigned int br;
726 +
727 + err = get_user(br, (unsigned int *)regs->pc);
728 +
729 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
730 + unsigned int br2, ldq, nop, jmp;
731 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
732 +
733 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
734 + err = get_user(br2, (unsigned int *)addr);
735 + err |= get_user(ldq, (unsigned int *)(addr+4));
736 + err |= get_user(nop, (unsigned int *)(addr+8));
737 + err |= get_user(jmp, (unsigned int *)(addr+12));
738 + err |= get_user(resolver, (unsigned long *)(addr+16));
739 +
740 + if (err)
741 + break;
742 +
743 + if (br2 == 0xC3600000U &&
744 + ldq == 0xA77B000CU &&
745 + nop == 0x47FF041FU &&
746 + jmp == 0x6B7B0000U)
747 + {
748 + regs->r28 = regs->pc+4;
749 + regs->r27 = addr+16;
750 + regs->pc = resolver;
751 + return 3;
752 + }
753 + }
754 + } while (0);
755 +#endif
756 +
757 + return 1;
758 +}
759 +
760 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
761 +{
762 + unsigned long i;
763 +
764 + printk(KERN_ERR "PAX: bytes at PC: ");
765 + for (i = 0; i < 5; i++) {
766 + unsigned int c;
767 + if (get_user(c, (unsigned int *)pc+i))
768 + printk(KERN_CONT "???????? ");
769 + else
770 + printk(KERN_CONT "%08x ", c);
771 + }
772 + printk("\n");
773 +}
774 +#endif
775
776 /*
777 * This routine handles page faults. It determines the address,
778 @@ -133,8 +251,29 @@ retry:
779 good_area:
780 si_code = SEGV_ACCERR;
781 if (cause < 0) {
782 - if (!(vma->vm_flags & VM_EXEC))
783 + if (!(vma->vm_flags & VM_EXEC)) {
784 +
785 +#ifdef CONFIG_PAX_PAGEEXEC
786 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
787 + goto bad_area;
788 +
789 + up_read(&mm->mmap_sem);
790 + switch (pax_handle_fetch_fault(regs)) {
791 +
792 +#ifdef CONFIG_PAX_EMUPLT
793 + case 2:
794 + case 3:
795 + return;
796 +#endif
797 +
798 + }
799 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
800 + do_group_exit(SIGKILL);
801 +#else
802 goto bad_area;
803 +#endif
804 +
805 + }
806 } else if (!cause) {
807 /* Allow reads even for write-only mappings */
808 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
809 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
810 index 1cacda4..2cef624 100644
811 --- a/arch/arm/Kconfig
812 +++ b/arch/arm/Kconfig
813 @@ -1850,7 +1850,7 @@ config ALIGNMENT_TRAP
814
815 config UACCESS_WITH_MEMCPY
816 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
817 - depends on MMU
818 + depends on MMU && !PAX_MEMORY_UDEREF
819 default y if CPU_FEROCEON
820 help
821 Implement faster copy_to_user and clear_user methods for CPU
822 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
823 index c79f61f..9ac0642 100644
824 --- a/arch/arm/include/asm/atomic.h
825 +++ b/arch/arm/include/asm/atomic.h
826 @@ -17,17 +17,35 @@
827 #include <asm/barrier.h>
828 #include <asm/cmpxchg.h>
829
830 +#ifdef CONFIG_GENERIC_ATOMIC64
831 +#include <asm-generic/atomic64.h>
832 +#endif
833 +
834 #define ATOMIC_INIT(i) { (i) }
835
836 #ifdef __KERNEL__
837
838 +#define _ASM_EXTABLE(from, to) \
839 +" .pushsection __ex_table,\"a\"\n"\
840 +" .align 3\n" \
841 +" .long " #from ", " #to"\n" \
842 +" .popsection"
843 +
844 /*
845 * On ARM, ordinary assignment (str instruction) doesn't clear the local
846 * strex/ldrex monitor on some implementations. The reason we can use it for
847 * atomic_set() is the clrex or dummy strex done on every exception return.
848 */
849 #define atomic_read(v) (*(volatile int *)&(v)->counter)
850 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
851 +{
852 + return v->counter;
853 +}
854 #define atomic_set(v,i) (((v)->counter) = (i))
855 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
856 +{
857 + v->counter = i;
858 +}
859
860 #if __LINUX_ARM_ARCH__ >= 6
861
862 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
863 int result;
864
865 __asm__ __volatile__("@ atomic_add\n"
866 +"1: ldrex %1, [%3]\n"
867 +" adds %0, %1, %4\n"
868 +
869 +#ifdef CONFIG_PAX_REFCOUNT
870 +" bvc 3f\n"
871 +"2: bkpt 0xf103\n"
872 +"3:\n"
873 +#endif
874 +
875 +" strex %1, %0, [%3]\n"
876 +" teq %1, #0\n"
877 +" bne 1b"
878 +
879 +#ifdef CONFIG_PAX_REFCOUNT
880 +"\n4:\n"
881 + _ASM_EXTABLE(2b, 4b)
882 +#endif
883 +
884 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
885 + : "r" (&v->counter), "Ir" (i)
886 + : "cc");
887 +}
888 +
889 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
890 +{
891 + unsigned long tmp;
892 + int result;
893 +
894 + __asm__ __volatile__("@ atomic_add_unchecked\n"
895 "1: ldrex %0, [%3]\n"
896 " add %0, %0, %4\n"
897 " strex %1, %0, [%3]\n"
898 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
899 smp_mb();
900
901 __asm__ __volatile__("@ atomic_add_return\n"
902 +"1: ldrex %1, [%3]\n"
903 +" adds %0, %1, %4\n"
904 +
905 +#ifdef CONFIG_PAX_REFCOUNT
906 +" bvc 3f\n"
907 +" mov %0, %1\n"
908 +"2: bkpt 0xf103\n"
909 +"3:\n"
910 +#endif
911 +
912 +" strex %1, %0, [%3]\n"
913 +" teq %1, #0\n"
914 +" bne 1b"
915 +
916 +#ifdef CONFIG_PAX_REFCOUNT
917 +"\n4:\n"
918 + _ASM_EXTABLE(2b, 4b)
919 +#endif
920 +
921 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
922 + : "r" (&v->counter), "Ir" (i)
923 + : "cc");
924 +
925 + smp_mb();
926 +
927 + return result;
928 +}
929 +
930 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
931 +{
932 + unsigned long tmp;
933 + int result;
934 +
935 + smp_mb();
936 +
937 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
938 "1: ldrex %0, [%3]\n"
939 " add %0, %0, %4\n"
940 " strex %1, %0, [%3]\n"
941 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
942 int result;
943
944 __asm__ __volatile__("@ atomic_sub\n"
945 +"1: ldrex %1, [%3]\n"
946 +" subs %0, %1, %4\n"
947 +
948 +#ifdef CONFIG_PAX_REFCOUNT
949 +" bvc 3f\n"
950 +"2: bkpt 0xf103\n"
951 +"3:\n"
952 +#endif
953 +
954 +" strex %1, %0, [%3]\n"
955 +" teq %1, #0\n"
956 +" bne 1b"
957 +
958 +#ifdef CONFIG_PAX_REFCOUNT
959 +"\n4:\n"
960 + _ASM_EXTABLE(2b, 4b)
961 +#endif
962 +
963 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
964 + : "r" (&v->counter), "Ir" (i)
965 + : "cc");
966 +}
967 +
968 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
969 +{
970 + unsigned long tmp;
971 + int result;
972 +
973 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
974 "1: ldrex %0, [%3]\n"
975 " sub %0, %0, %4\n"
976 " strex %1, %0, [%3]\n"
977 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
978 smp_mb();
979
980 __asm__ __volatile__("@ atomic_sub_return\n"
981 -"1: ldrex %0, [%3]\n"
982 -" sub %0, %0, %4\n"
983 +"1: ldrex %1, [%3]\n"
984 +" subs %0, %1, %4\n"
985 +
986 +#ifdef CONFIG_PAX_REFCOUNT
987 +" bvc 3f\n"
988 +" mov %0, %1\n"
989 +"2: bkpt 0xf103\n"
990 +"3:\n"
991 +#endif
992 +
993 " strex %1, %0, [%3]\n"
994 " teq %1, #0\n"
995 " bne 1b"
996 +
997 +#ifdef CONFIG_PAX_REFCOUNT
998 +"\n4:\n"
999 + _ASM_EXTABLE(2b, 4b)
1000 +#endif
1001 +
1002 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1003 : "r" (&v->counter), "Ir" (i)
1004 : "cc");
1005 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1006 return oldval;
1007 }
1008
1009 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1010 +{
1011 + unsigned long oldval, res;
1012 +
1013 + smp_mb();
1014 +
1015 + do {
1016 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1017 + "ldrex %1, [%3]\n"
1018 + "mov %0, #0\n"
1019 + "teq %1, %4\n"
1020 + "strexeq %0, %5, [%3]\n"
1021 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1022 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1023 + : "cc");
1024 + } while (res);
1025 +
1026 + smp_mb();
1027 +
1028 + return oldval;
1029 +}
1030 +
1031 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1032 {
1033 unsigned long tmp, tmp2;
1034 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1035
1036 return val;
1037 }
1038 +
1039 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1040 +{
1041 + return atomic_add_return(i, v);
1042 +}
1043 +
1044 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1045 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1046 +{
1047 + (void) atomic_add_return(i, v);
1048 +}
1049
1050 static inline int atomic_sub_return(int i, atomic_t *v)
1051 {
1052 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1053 return val;
1054 }
1055 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1056 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1057 +{
1058 + (void) atomic_sub_return(i, v);
1059 +}
1060
1061 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1062 {
1063 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1064 return ret;
1065 }
1066
1067 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1068 +{
1069 + return atomic_cmpxchg(v, old, new);
1070 +}
1071 +
1072 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1073 {
1074 unsigned long flags;
1075 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1076 #endif /* __LINUX_ARM_ARCH__ */
1077
1078 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1079 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1080 +{
1081 + return xchg(&v->counter, new);
1082 +}
1083
1084 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1085 {
1086 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1087 }
1088
1089 #define atomic_inc(v) atomic_add(1, v)
1090 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1091 +{
1092 + atomic_add_unchecked(1, v);
1093 +}
1094 #define atomic_dec(v) atomic_sub(1, v)
1095 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1096 +{
1097 + atomic_sub_unchecked(1, v);
1098 +}
1099
1100 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1101 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1102 +{
1103 + return atomic_add_return_unchecked(1, v) == 0;
1104 +}
1105 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1106 #define atomic_inc_return(v) (atomic_add_return(1, v))
1107 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1108 +{
1109 + return atomic_add_return_unchecked(1, v);
1110 +}
1111 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1112 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1113
1114 @@ -241,6 +428,14 @@ typedef struct {
1115 u64 __aligned(8) counter;
1116 } atomic64_t;
1117
1118 +#ifdef CONFIG_PAX_REFCOUNT
1119 +typedef struct {
1120 + u64 __aligned(8) counter;
1121 +} atomic64_unchecked_t;
1122 +#else
1123 +typedef atomic64_t atomic64_unchecked_t;
1124 +#endif
1125 +
1126 #define ATOMIC64_INIT(i) { (i) }
1127
1128 static inline u64 atomic64_read(const atomic64_t *v)
1129 @@ -256,6 +451,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1130 return result;
1131 }
1132
1133 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1134 +{
1135 + u64 result;
1136 +
1137 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1138 +" ldrexd %0, %H0, [%1]"
1139 + : "=&r" (result)
1140 + : "r" (&v->counter), "Qo" (v->counter)
1141 + );
1142 +
1143 + return result;
1144 +}
1145 +
1146 static inline void atomic64_set(atomic64_t *v, u64 i)
1147 {
1148 u64 tmp;
1149 @@ -270,6 +478,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1150 : "cc");
1151 }
1152
1153 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1154 +{
1155 + u64 tmp;
1156 +
1157 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1158 +"1: ldrexd %0, %H0, [%2]\n"
1159 +" strexd %0, %3, %H3, [%2]\n"
1160 +" teq %0, #0\n"
1161 +" bne 1b"
1162 + : "=&r" (tmp), "=Qo" (v->counter)
1163 + : "r" (&v->counter), "r" (i)
1164 + : "cc");
1165 +}
1166 +
1167 static inline void atomic64_add(u64 i, atomic64_t *v)
1168 {
1169 u64 result;
1170 @@ -278,6 +500,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1171 __asm__ __volatile__("@ atomic64_add\n"
1172 "1: ldrexd %0, %H0, [%3]\n"
1173 " adds %0, %0, %4\n"
1174 +" adcs %H0, %H0, %H4\n"
1175 +
1176 +#ifdef CONFIG_PAX_REFCOUNT
1177 +" bvc 3f\n"
1178 +"2: bkpt 0xf103\n"
1179 +"3:\n"
1180 +#endif
1181 +
1182 +" strexd %1, %0, %H0, [%3]\n"
1183 +" teq %1, #0\n"
1184 +" bne 1b"
1185 +
1186 +#ifdef CONFIG_PAX_REFCOUNT
1187 +"\n4:\n"
1188 + _ASM_EXTABLE(2b, 4b)
1189 +#endif
1190 +
1191 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1192 + : "r" (&v->counter), "r" (i)
1193 + : "cc");
1194 +}
1195 +
1196 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1197 +{
1198 + u64 result;
1199 + unsigned long tmp;
1200 +
1201 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1202 +"1: ldrexd %0, %H0, [%3]\n"
1203 +" adds %0, %0, %4\n"
1204 " adc %H0, %H0, %H4\n"
1205 " strexd %1, %0, %H0, [%3]\n"
1206 " teq %1, #0\n"
1207 @@ -289,12 +541,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1208
1209 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1210 {
1211 - u64 result;
1212 - unsigned long tmp;
1213 + u64 result, tmp;
1214
1215 smp_mb();
1216
1217 __asm__ __volatile__("@ atomic64_add_return\n"
1218 +"1: ldrexd %1, %H1, [%3]\n"
1219 +" adds %0, %1, %4\n"
1220 +" adcs %H0, %H1, %H4\n"
1221 +
1222 +#ifdef CONFIG_PAX_REFCOUNT
1223 +" bvc 3f\n"
1224 +" mov %0, %1\n"
1225 +" mov %H0, %H1\n"
1226 +"2: bkpt 0xf103\n"
1227 +"3:\n"
1228 +#endif
1229 +
1230 +" strexd %1, %0, %H0, [%3]\n"
1231 +" teq %1, #0\n"
1232 +" bne 1b"
1233 +
1234 +#ifdef CONFIG_PAX_REFCOUNT
1235 +"\n4:\n"
1236 + _ASM_EXTABLE(2b, 4b)
1237 +#endif
1238 +
1239 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1240 + : "r" (&v->counter), "r" (i)
1241 + : "cc");
1242 +
1243 + smp_mb();
1244 +
1245 + return result;
1246 +}
1247 +
1248 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1249 +{
1250 + u64 result;
1251 + unsigned long tmp;
1252 +
1253 + smp_mb();
1254 +
1255 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1256 "1: ldrexd %0, %H0, [%3]\n"
1257 " adds %0, %0, %4\n"
1258 " adc %H0, %H0, %H4\n"
1259 @@ -318,6 +607,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1260 __asm__ __volatile__("@ atomic64_sub\n"
1261 "1: ldrexd %0, %H0, [%3]\n"
1262 " subs %0, %0, %4\n"
1263 +" sbcs %H0, %H0, %H4\n"
1264 +
1265 +#ifdef CONFIG_PAX_REFCOUNT
1266 +" bvc 3f\n"
1267 +"2: bkpt 0xf103\n"
1268 +"3:\n"
1269 +#endif
1270 +
1271 +" strexd %1, %0, %H0, [%3]\n"
1272 +" teq %1, #0\n"
1273 +" bne 1b"
1274 +
1275 +#ifdef CONFIG_PAX_REFCOUNT
1276 +"\n4:\n"
1277 + _ASM_EXTABLE(2b, 4b)
1278 +#endif
1279 +
1280 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1281 + : "r" (&v->counter), "r" (i)
1282 + : "cc");
1283 +}
1284 +
1285 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1286 +{
1287 + u64 result;
1288 + unsigned long tmp;
1289 +
1290 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1291 +"1: ldrexd %0, %H0, [%3]\n"
1292 +" subs %0, %0, %4\n"
1293 " sbc %H0, %H0, %H4\n"
1294 " strexd %1, %0, %H0, [%3]\n"
1295 " teq %1, #0\n"
1296 @@ -329,18 +648,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1297
1298 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1299 {
1300 - u64 result;
1301 - unsigned long tmp;
1302 + u64 result, tmp;
1303
1304 smp_mb();
1305
1306 __asm__ __volatile__("@ atomic64_sub_return\n"
1307 -"1: ldrexd %0, %H0, [%3]\n"
1308 -" subs %0, %0, %4\n"
1309 -" sbc %H0, %H0, %H4\n"
1310 +"1: ldrexd %1, %H1, [%3]\n"
1311 +" subs %0, %1, %4\n"
1312 +" sbcs %H0, %H1, %H4\n"
1313 +
1314 +#ifdef CONFIG_PAX_REFCOUNT
1315 +" bvc 3f\n"
1316 +" mov %0, %1\n"
1317 +" mov %H0, %H1\n"
1318 +"2: bkpt 0xf103\n"
1319 +"3:\n"
1320 +#endif
1321 +
1322 " strexd %1, %0, %H0, [%3]\n"
1323 " teq %1, #0\n"
1324 " bne 1b"
1325 +
1326 +#ifdef CONFIG_PAX_REFCOUNT
1327 +"\n4:\n"
1328 + _ASM_EXTABLE(2b, 4b)
1329 +#endif
1330 +
1331 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1332 : "r" (&v->counter), "r" (i)
1333 : "cc");
1334 @@ -374,6 +707,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1335 return oldval;
1336 }
1337
1338 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1339 +{
1340 + u64 oldval;
1341 + unsigned long res;
1342 +
1343 + smp_mb();
1344 +
1345 + do {
1346 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1347 + "ldrexd %1, %H1, [%3]\n"
1348 + "mov %0, #0\n"
1349 + "teq %1, %4\n"
1350 + "teqeq %H1, %H4\n"
1351 + "strexdeq %0, %5, %H5, [%3]"
1352 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1353 + : "r" (&ptr->counter), "r" (old), "r" (new)
1354 + : "cc");
1355 + } while (res);
1356 +
1357 + smp_mb();
1358 +
1359 + return oldval;
1360 +}
1361 +
1362 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1363 {
1364 u64 result;
1365 @@ -397,21 +754,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1366
1367 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1368 {
1369 - u64 result;
1370 - unsigned long tmp;
1371 + u64 result, tmp;
1372
1373 smp_mb();
1374
1375 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1376 -"1: ldrexd %0, %H0, [%3]\n"
1377 -" subs %0, %0, #1\n"
1378 -" sbc %H0, %H0, #0\n"
1379 +"1: ldrexd %1, %H1, [%3]\n"
1380 +" subs %0, %1, #1\n"
1381 +" sbcs %H0, %H1, #0\n"
1382 +
1383 +#ifdef CONFIG_PAX_REFCOUNT
1384 +" bvc 3f\n"
1385 +" mov %0, %1\n"
1386 +" mov %H0, %H1\n"
1387 +"2: bkpt 0xf103\n"
1388 +"3:\n"
1389 +#endif
1390 +
1391 " teq %H0, #0\n"
1392 -" bmi 2f\n"
1393 +" bmi 4f\n"
1394 " strexd %1, %0, %H0, [%3]\n"
1395 " teq %1, #0\n"
1396 " bne 1b\n"
1397 -"2:"
1398 +"4:\n"
1399 +
1400 +#ifdef CONFIG_PAX_REFCOUNT
1401 + _ASM_EXTABLE(2b, 4b)
1402 +#endif
1403 +
1404 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1405 : "r" (&v->counter)
1406 : "cc");
1407 @@ -434,13 +804,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1408 " teq %0, %5\n"
1409 " teqeq %H0, %H5\n"
1410 " moveq %1, #0\n"
1411 -" beq 2f\n"
1412 +" beq 4f\n"
1413 " adds %0, %0, %6\n"
1414 -" adc %H0, %H0, %H6\n"
1415 +" adcs %H0, %H0, %H6\n"
1416 +
1417 +#ifdef CONFIG_PAX_REFCOUNT
1418 +" bvc 3f\n"
1419 +"2: bkpt 0xf103\n"
1420 +"3:\n"
1421 +#endif
1422 +
1423 " strexd %2, %0, %H0, [%4]\n"
1424 " teq %2, #0\n"
1425 " bne 1b\n"
1426 -"2:"
1427 +"4:\n"
1428 +
1429 +#ifdef CONFIG_PAX_REFCOUNT
1430 + _ASM_EXTABLE(2b, 4b)
1431 +#endif
1432 +
1433 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1434 : "r" (&v->counter), "r" (u), "r" (a)
1435 : "cc");
1436 @@ -453,10 +835,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1437
1438 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1439 #define atomic64_inc(v) atomic64_add(1LL, (v))
1440 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1441 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1442 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1443 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1444 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1445 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1446 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1447 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1448 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1449 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1450 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1451 index 75fe66b..ba3dee4 100644
1452 --- a/arch/arm/include/asm/cache.h
1453 +++ b/arch/arm/include/asm/cache.h
1454 @@ -4,8 +4,10 @@
1455 #ifndef __ASMARM_CACHE_H
1456 #define __ASMARM_CACHE_H
1457
1458 +#include <linux/const.h>
1459 +
1460 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1461 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1462 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1463
1464 /*
1465 * Memory returned by kmalloc() may be used for DMA, so we must make
1466 @@ -24,5 +26,6 @@
1467 #endif
1468
1469 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1470 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1471
1472 #endif
1473 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1474 index e1489c5..d418304 100644
1475 --- a/arch/arm/include/asm/cacheflush.h
1476 +++ b/arch/arm/include/asm/cacheflush.h
1477 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1478 void (*dma_unmap_area)(const void *, size_t, int);
1479
1480 void (*dma_flush_range)(const void *, const void *);
1481 -};
1482 +} __no_const;
1483
1484 /*
1485 * Select the calling method
1486 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1487 index 6dcc164..b14d917 100644
1488 --- a/arch/arm/include/asm/checksum.h
1489 +++ b/arch/arm/include/asm/checksum.h
1490 @@ -37,7 +37,19 @@ __wsum
1491 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1492
1493 __wsum
1494 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1495 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1496 +
1497 +static inline __wsum
1498 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1499 +{
1500 + __wsum ret;
1501 + pax_open_userland();
1502 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1503 + pax_close_userland();
1504 + return ret;
1505 +}
1506 +
1507 +
1508
1509 /*
1510 * Fold a partial checksum without adding pseudo headers
1511 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1512 index 4f009c1..466c59b 100644
1513 --- a/arch/arm/include/asm/cmpxchg.h
1514 +++ b/arch/arm/include/asm/cmpxchg.h
1515 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1516
1517 #define xchg(ptr,x) \
1518 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1519 +#define xchg_unchecked(ptr,x) \
1520 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1521
1522 #include <asm-generic/cmpxchg-local.h>
1523
1524 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1525 index 6ddbe44..b5e38b1 100644
1526 --- a/arch/arm/include/asm/domain.h
1527 +++ b/arch/arm/include/asm/domain.h
1528 @@ -48,18 +48,37 @@
1529 * Domain types
1530 */
1531 #define DOMAIN_NOACCESS 0
1532 -#define DOMAIN_CLIENT 1
1533 #ifdef CONFIG_CPU_USE_DOMAINS
1534 +#define DOMAIN_USERCLIENT 1
1535 +#define DOMAIN_KERNELCLIENT 1
1536 #define DOMAIN_MANAGER 3
1537 +#define DOMAIN_VECTORS DOMAIN_USER
1538 #else
1539 +
1540 +#ifdef CONFIG_PAX_KERNEXEC
1541 #define DOMAIN_MANAGER 1
1542 +#define DOMAIN_KERNEXEC 3
1543 +#else
1544 +#define DOMAIN_MANAGER 1
1545 +#endif
1546 +
1547 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1548 +#define DOMAIN_USERCLIENT 0
1549 +#define DOMAIN_UDEREF 1
1550 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1551 +#else
1552 +#define DOMAIN_USERCLIENT 1
1553 +#define DOMAIN_VECTORS DOMAIN_USER
1554 +#endif
1555 +#define DOMAIN_KERNELCLIENT 1
1556 +
1557 #endif
1558
1559 #define domain_val(dom,type) ((type) << (2*(dom)))
1560
1561 #ifndef __ASSEMBLY__
1562
1563 -#ifdef CONFIG_CPU_USE_DOMAINS
1564 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1565 static inline void set_domain(unsigned val)
1566 {
1567 asm volatile(
1568 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1569 isb();
1570 }
1571
1572 -#define modify_domain(dom,type) \
1573 - do { \
1574 - struct thread_info *thread = current_thread_info(); \
1575 - unsigned int domain = thread->cpu_domain; \
1576 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1577 - thread->cpu_domain = domain | domain_val(dom, type); \
1578 - set_domain(thread->cpu_domain); \
1579 - } while (0)
1580 -
1581 +extern void modify_domain(unsigned int dom, unsigned int type);
1582 #else
1583 static inline void set_domain(unsigned val) { }
1584 static inline void modify_domain(unsigned dom, unsigned type) { }
1585 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1586 index 38050b1..9d90e8b 100644
1587 --- a/arch/arm/include/asm/elf.h
1588 +++ b/arch/arm/include/asm/elf.h
1589 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1590 the loader. We need to make sure that it is out of the way of the program
1591 that it will "exec", and that there is sufficient room for the brk. */
1592
1593 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1594 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1595 +
1596 +#ifdef CONFIG_PAX_ASLR
1597 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1598 +
1599 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1600 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1601 +#endif
1602
1603 /* When the program starts, a1 contains a pointer to a function to be
1604 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1605 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1606 extern void elf_set_personality(const struct elf32_hdr *);
1607 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1608
1609 -struct mm_struct;
1610 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1611 -#define arch_randomize_brk arch_randomize_brk
1612 -
1613 #endif
1614 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1615 index de53547..52b9a28 100644
1616 --- a/arch/arm/include/asm/fncpy.h
1617 +++ b/arch/arm/include/asm/fncpy.h
1618 @@ -81,7 +81,9 @@
1619 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1620 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1621 \
1622 + pax_open_kernel(); \
1623 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1624 + pax_close_kernel(); \
1625 flush_icache_range((unsigned long)(dest_buf), \
1626 (unsigned long)(dest_buf) + (size)); \
1627 \
1628 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1629 index e42cf59..7b94b8f 100644
1630 --- a/arch/arm/include/asm/futex.h
1631 +++ b/arch/arm/include/asm/futex.h
1632 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1633 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1634 return -EFAULT;
1635
1636 + pax_open_userland();
1637 +
1638 smp_mb();
1639 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1640 "1: ldrex %1, [%4]\n"
1641 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1642 : "cc", "memory");
1643 smp_mb();
1644
1645 + pax_close_userland();
1646 +
1647 *uval = val;
1648 return ret;
1649 }
1650 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1651 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1652 return -EFAULT;
1653
1654 + pax_open_userland();
1655 +
1656 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1657 "1: " TUSER(ldr) " %1, [%4]\n"
1658 " teq %1, %2\n"
1659 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1660 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1661 : "cc", "memory");
1662
1663 + pax_close_userland();
1664 +
1665 *uval = val;
1666 return ret;
1667 }
1668 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1669 return -EFAULT;
1670
1671 pagefault_disable(); /* implies preempt_disable() */
1672 + pax_open_userland();
1673
1674 switch (op) {
1675 case FUTEX_OP_SET:
1676 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1677 ret = -ENOSYS;
1678 }
1679
1680 + pax_close_userland();
1681 pagefault_enable(); /* subsumes preempt_enable() */
1682
1683 if (!ret) {
1684 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1685 index 83eb2f7..ed77159 100644
1686 --- a/arch/arm/include/asm/kmap_types.h
1687 +++ b/arch/arm/include/asm/kmap_types.h
1688 @@ -4,6 +4,6 @@
1689 /*
1690 * This is the "bare minimum". AIO seems to require this.
1691 */
1692 -#define KM_TYPE_NR 16
1693 +#define KM_TYPE_NR 17
1694
1695 #endif
1696 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1697 index 9e614a1..3302cca 100644
1698 --- a/arch/arm/include/asm/mach/dma.h
1699 +++ b/arch/arm/include/asm/mach/dma.h
1700 @@ -22,7 +22,7 @@ struct dma_ops {
1701 int (*residue)(unsigned int, dma_t *); /* optional */
1702 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1703 const char *type;
1704 -};
1705 +} __do_const;
1706
1707 struct dma_struct {
1708 void *addr; /* single DMA address */
1709 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1710 index 2fe141f..192dc01 100644
1711 --- a/arch/arm/include/asm/mach/map.h
1712 +++ b/arch/arm/include/asm/mach/map.h
1713 @@ -27,13 +27,16 @@ struct map_desc {
1714 #define MT_MINICLEAN 6
1715 #define MT_LOW_VECTORS 7
1716 #define MT_HIGH_VECTORS 8
1717 -#define MT_MEMORY 9
1718 +#define MT_MEMORY_RWX 9
1719 #define MT_ROM 10
1720 -#define MT_MEMORY_NONCACHED 11
1721 +#define MT_MEMORY_NONCACHED_RX 11
1722 #define MT_MEMORY_DTCM 12
1723 #define MT_MEMORY_ITCM 13
1724 #define MT_MEMORY_SO 14
1725 #define MT_MEMORY_DMA_READY 15
1726 +#define MT_MEMORY_RW 16
1727 +#define MT_MEMORY_RX 17
1728 +#define MT_MEMORY_NONCACHED_RW 18
1729
1730 #ifdef CONFIG_MMU
1731 extern void iotable_init(struct map_desc *, int);
1732 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1733 index 12f71a1..04e063c 100644
1734 --- a/arch/arm/include/asm/outercache.h
1735 +++ b/arch/arm/include/asm/outercache.h
1736 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1737 #endif
1738 void (*set_debug)(unsigned long);
1739 void (*resume)(void);
1740 -};
1741 +} __no_const;
1742
1743 #ifdef CONFIG_OUTER_CACHE
1744
1745 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1746 index 812a494..71fc0b6 100644
1747 --- a/arch/arm/include/asm/page.h
1748 +++ b/arch/arm/include/asm/page.h
1749 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1750 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1751 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1752 unsigned long vaddr, struct vm_area_struct *vma);
1753 -};
1754 +} __no_const;
1755
1756 #ifdef MULTI_USER
1757 extern struct cpu_user_fns cpu_user;
1758 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1759 index 943504f..c37a730 100644
1760 --- a/arch/arm/include/asm/pgalloc.h
1761 +++ b/arch/arm/include/asm/pgalloc.h
1762 @@ -17,6 +17,7 @@
1763 #include <asm/processor.h>
1764 #include <asm/cacheflush.h>
1765 #include <asm/tlbflush.h>
1766 +#include <asm/system_info.h>
1767
1768 #define check_pgt_cache() do { } while (0)
1769
1770 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1771 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1772 }
1773
1774 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1775 +{
1776 + pud_populate(mm, pud, pmd);
1777 +}
1778 +
1779 #else /* !CONFIG_ARM_LPAE */
1780
1781 /*
1782 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1783 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1784 #define pmd_free(mm, pmd) do { } while (0)
1785 #define pud_populate(mm,pmd,pte) BUG()
1786 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1787
1788 #endif /* CONFIG_ARM_LPAE */
1789
1790 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1791 __free_page(pte);
1792 }
1793
1794 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1795 +{
1796 +#ifdef CONFIG_ARM_LPAE
1797 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1798 +#else
1799 + if (addr & SECTION_SIZE)
1800 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1801 + else
1802 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1803 +#endif
1804 + flush_pmd_entry(pmdp);
1805 +}
1806 +
1807 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1808 pmdval_t prot)
1809 {
1810 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1811 static inline void
1812 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1813 {
1814 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1815 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1816 }
1817 #define pmd_pgtable(pmd) pmd_page(pmd)
1818
1819 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1820 index 5cfba15..f415e1a 100644
1821 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1822 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1823 @@ -20,12 +20,15 @@
1824 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1825 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1826 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1827 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1828 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1829 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1830 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1831 +
1832 /*
1833 * - section
1834 */
1835 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1836 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1837 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1838 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1839 @@ -37,6 +40,7 @@
1840 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1841 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1842 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1843 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1844
1845 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1846 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1847 @@ -66,6 +70,7 @@
1848 * - extended small page/tiny page
1849 */
1850 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1851 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1852 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1853 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1854 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1855 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1856 index f97ee02..07f1be5 100644
1857 --- a/arch/arm/include/asm/pgtable-2level.h
1858 +++ b/arch/arm/include/asm/pgtable-2level.h
1859 @@ -125,6 +125,7 @@
1860 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1861 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1862 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1863 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1864
1865 /*
1866 * These are the memory types, defined to be compatible with
1867 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1868 index 18f5cef..25b8f43 100644
1869 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1870 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1871 @@ -41,6 +41,7 @@
1872 */
1873 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1874 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1875 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1876 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1877 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1878 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1879 @@ -71,6 +72,7 @@
1880 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1881 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1882 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1883 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1884 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1885
1886 /*
1887 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1888 index 86b8fe3..e25f975 100644
1889 --- a/arch/arm/include/asm/pgtable-3level.h
1890 +++ b/arch/arm/include/asm/pgtable-3level.h
1891 @@ -74,6 +74,7 @@
1892 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1893 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1894 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1895 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1896 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1897 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1898 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1899 @@ -82,6 +83,7 @@
1900 /*
1901 * To be used in assembly code with the upper page attributes.
1902 */
1903 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1904 #define L_PTE_XN_HIGH (1 << (54 - 32))
1905 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1906
1907 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1908 index 9bcd262..fba731c 100644
1909 --- a/arch/arm/include/asm/pgtable.h
1910 +++ b/arch/arm/include/asm/pgtable.h
1911 @@ -30,6 +30,9 @@
1912 #include <asm/pgtable-2level.h>
1913 #endif
1914
1915 +#define ktla_ktva(addr) (addr)
1916 +#define ktva_ktla(addr) (addr)
1917 +
1918 /*
1919 * Just any arbitrary offset to the start of the vmalloc VM area: the
1920 * current 8MB value just means that there will be a 8MB "hole" after the
1921 @@ -45,6 +48,9 @@
1922 #define LIBRARY_TEXT_START 0x0c000000
1923
1924 #ifndef __ASSEMBLY__
1925 +extern pteval_t __supported_pte_mask;
1926 +extern pmdval_t __supported_pmd_mask;
1927 +
1928 extern void __pte_error(const char *file, int line, pte_t);
1929 extern void __pmd_error(const char *file, int line, pmd_t);
1930 extern void __pgd_error(const char *file, int line, pgd_t);
1931 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1932 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1933 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1934
1935 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1936 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1937 +
1938 +#ifdef CONFIG_PAX_KERNEXEC
1939 +#include <asm/domain.h>
1940 +#include <linux/thread_info.h>
1941 +#include <linux/preempt.h>
1942 +#endif
1943 +
1944 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1945 +static inline int test_domain(int domain, int domaintype)
1946 +{
1947 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
1948 +}
1949 +#endif
1950 +
1951 +#ifdef CONFIG_PAX_KERNEXEC
1952 +static inline unsigned long pax_open_kernel(void) {
1953 +#ifdef CONFIG_ARM_LPAE
1954 + /* TODO */
1955 +#else
1956 + preempt_disable();
1957 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
1958 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
1959 +#endif
1960 + return 0;
1961 +}
1962 +
1963 +static inline unsigned long pax_close_kernel(void) {
1964 +#ifdef CONFIG_ARM_LPAE
1965 + /* TODO */
1966 +#else
1967 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
1968 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
1969 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
1970 + preempt_enable_no_resched();
1971 +#endif
1972 + return 0;
1973 +}
1974 +#else
1975 +static inline unsigned long pax_open_kernel(void) { return 0; }
1976 +static inline unsigned long pax_close_kernel(void) { return 0; }
1977 +#endif
1978 +
1979 /*
1980 * This is the lowest virtual address we can permit any user space
1981 * mapping to be mapped at. This is particularly important for
1982 @@ -72,8 +122,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1983 /*
1984 * The pgprot_* and protection_map entries will be fixed up in runtime
1985 * to include the cachable and bufferable bits based on memory policy,
1986 - * as well as any architecture dependent bits like global/ASID and SMP
1987 - * shared mapping bits.
1988 + * as well as any architecture dependent bits like global/ASID, PXN,
1989 + * and SMP shared mapping bits.
1990 */
1991 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
1992
1993 @@ -257,7 +307,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
1994 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
1995 {
1996 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
1997 - L_PTE_NONE | L_PTE_VALID;
1998 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
1999 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2000 return pte;
2001 }
2002 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2003 index f3628fb..a0672dd 100644
2004 --- a/arch/arm/include/asm/proc-fns.h
2005 +++ b/arch/arm/include/asm/proc-fns.h
2006 @@ -75,7 +75,7 @@ extern struct processor {
2007 unsigned int suspend_size;
2008 void (*do_suspend)(void *);
2009 void (*do_resume)(void *);
2010 -} processor;
2011 +} __do_const processor;
2012
2013 #ifndef MULTI_CPU
2014 extern void cpu_proc_init(void);
2015 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2016 index 06e7d50..8a8e251 100644
2017 --- a/arch/arm/include/asm/processor.h
2018 +++ b/arch/arm/include/asm/processor.h
2019 @@ -65,9 +65,8 @@ struct thread_struct {
2020 regs->ARM_cpsr |= PSR_ENDSTATE; \
2021 regs->ARM_pc = pc & ~1; /* pc */ \
2022 regs->ARM_sp = sp; /* sp */ \
2023 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2024 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2025 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2026 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2027 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2028 nommu_start_thread(regs); \
2029 })
2030
2031 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2032 index ce0dbe7..c085b6f 100644
2033 --- a/arch/arm/include/asm/psci.h
2034 +++ b/arch/arm/include/asm/psci.h
2035 @@ -29,7 +29,7 @@ struct psci_operations {
2036 int (*cpu_off)(struct psci_power_state state);
2037 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2038 int (*migrate)(unsigned long cpuid);
2039 -};
2040 +} __no_const;
2041
2042 extern struct psci_operations psci_ops;
2043
2044 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2045 index d3a22be..3a69ad5 100644
2046 --- a/arch/arm/include/asm/smp.h
2047 +++ b/arch/arm/include/asm/smp.h
2048 @@ -107,7 +107,7 @@ struct smp_operations {
2049 int (*cpu_disable)(unsigned int cpu);
2050 #endif
2051 #endif
2052 -};
2053 +} __no_const;
2054
2055 /*
2056 * set platform specific SMP operations
2057 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2058 index cddda1f..ff357f7 100644
2059 --- a/arch/arm/include/asm/thread_info.h
2060 +++ b/arch/arm/include/asm/thread_info.h
2061 @@ -77,9 +77,9 @@ struct thread_info {
2062 .flags = 0, \
2063 .preempt_count = INIT_PREEMPT_COUNT, \
2064 .addr_limit = KERNEL_DS, \
2065 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2066 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2067 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2068 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2069 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2070 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2071 .restart_block = { \
2072 .fn = do_no_restart_syscall, \
2073 }, \
2074 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2075 #define TIF_SYSCALL_AUDIT 9
2076 #define TIF_SYSCALL_TRACEPOINT 10
2077 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2078 +
2079 +/* within 8 bits of TIF_SYSCALL_TRACE
2080 + * to meet flexible second operand requirements
2081 + */
2082 +#define TIF_GRSEC_SETXID 12
2083 +
2084 #define TIF_USING_IWMMXT 17
2085 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2086 #define TIF_RESTORE_SIGMASK 20
2087 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2088 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2089 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2090 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2091 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2092
2093 /* Checks for any syscall work in entry-common.S */
2094 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2095 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2096 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2097
2098 /*
2099 * Change these and you break ASM code in entry-common.S
2100 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2101 index 7e1f760..752fcb7 100644
2102 --- a/arch/arm/include/asm/uaccess.h
2103 +++ b/arch/arm/include/asm/uaccess.h
2104 @@ -18,6 +18,7 @@
2105 #include <asm/domain.h>
2106 #include <asm/unified.h>
2107 #include <asm/compiler.h>
2108 +#include <asm/pgtable.h>
2109
2110 #define VERIFY_READ 0
2111 #define VERIFY_WRITE 1
2112 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2113 #define USER_DS TASK_SIZE
2114 #define get_fs() (current_thread_info()->addr_limit)
2115
2116 +static inline void pax_open_userland(void)
2117 +{
2118 +
2119 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2120 + if (get_fs() == USER_DS) {
2121 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2122 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2123 + }
2124 +#endif
2125 +
2126 +}
2127 +
2128 +static inline void pax_close_userland(void)
2129 +{
2130 +
2131 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2132 + if (get_fs() == USER_DS) {
2133 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2134 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2135 + }
2136 +#endif
2137 +
2138 +}
2139 +
2140 static inline void set_fs(mm_segment_t fs)
2141 {
2142 current_thread_info()->addr_limit = fs;
2143 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2144 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2145 }
2146
2147 #define segment_eq(a,b) ((a) == (b))
2148 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2149
2150 #define get_user(x,p) \
2151 ({ \
2152 + int __e; \
2153 might_fault(); \
2154 - __get_user_check(x,p); \
2155 + pax_open_userland(); \
2156 + __e = __get_user_check(x,p); \
2157 + pax_close_userland(); \
2158 + __e; \
2159 })
2160
2161 extern int __put_user_1(void *, unsigned int);
2162 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2163
2164 #define put_user(x,p) \
2165 ({ \
2166 + int __e; \
2167 might_fault(); \
2168 - __put_user_check(x,p); \
2169 + pax_open_userland(); \
2170 + __e = __put_user_check(x,p); \
2171 + pax_close_userland(); \
2172 + __e; \
2173 })
2174
2175 #else /* CONFIG_MMU */
2176 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2177 #define __get_user(x,ptr) \
2178 ({ \
2179 long __gu_err = 0; \
2180 + pax_open_userland(); \
2181 __get_user_err((x),(ptr),__gu_err); \
2182 + pax_close_userland(); \
2183 __gu_err; \
2184 })
2185
2186 #define __get_user_error(x,ptr,err) \
2187 ({ \
2188 + pax_open_userland(); \
2189 __get_user_err((x),(ptr),err); \
2190 + pax_close_userland(); \
2191 (void) 0; \
2192 })
2193
2194 @@ -312,13 +349,17 @@ do { \
2195 #define __put_user(x,ptr) \
2196 ({ \
2197 long __pu_err = 0; \
2198 + pax_open_userland(); \
2199 __put_user_err((x),(ptr),__pu_err); \
2200 + pax_close_userland(); \
2201 __pu_err; \
2202 })
2203
2204 #define __put_user_error(x,ptr,err) \
2205 ({ \
2206 + pax_open_userland(); \
2207 __put_user_err((x),(ptr),err); \
2208 + pax_close_userland(); \
2209 (void) 0; \
2210 })
2211
2212 @@ -418,11 +459,44 @@ do { \
2213
2214
2215 #ifdef CONFIG_MMU
2216 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2217 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2218 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2219 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2220 +
2221 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2222 +{
2223 + unsigned long ret;
2224 +
2225 + check_object_size(to, n, false);
2226 + pax_open_userland();
2227 + ret = ___copy_from_user(to, from, n);
2228 + pax_close_userland();
2229 + return ret;
2230 +}
2231 +
2232 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2233 +{
2234 + unsigned long ret;
2235 +
2236 + check_object_size(from, n, true);
2237 + pax_open_userland();
2238 + ret = ___copy_to_user(to, from, n);
2239 + pax_close_userland();
2240 + return ret;
2241 +}
2242 +
2243 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2244 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2245 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2246 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2247 +
2248 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2249 +{
2250 + unsigned long ret;
2251 + pax_open_userland();
2252 + ret = ___clear_user(addr, n);
2253 + pax_close_userland();
2254 + return ret;
2255 +}
2256 +
2257 #else
2258 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2259 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2260 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2261
2262 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2263 {
2264 + if ((long)n < 0)
2265 + return n;
2266 +
2267 if (access_ok(VERIFY_READ, from, n))
2268 n = __copy_from_user(to, from, n);
2269 else /* security hole - plug it */
2270 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2271
2272 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2273 {
2274 + if ((long)n < 0)
2275 + return n;
2276 +
2277 if (access_ok(VERIFY_WRITE, to, n))
2278 n = __copy_to_user(to, from, n);
2279 return n;
2280 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2281 index 96ee092..37f1844 100644
2282 --- a/arch/arm/include/uapi/asm/ptrace.h
2283 +++ b/arch/arm/include/uapi/asm/ptrace.h
2284 @@ -73,7 +73,7 @@
2285 * ARMv7 groups of PSR bits
2286 */
2287 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2288 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2289 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2290 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2291 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2292
2293 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2294 index 60d3b73..d27ee09 100644
2295 --- a/arch/arm/kernel/armksyms.c
2296 +++ b/arch/arm/kernel/armksyms.c
2297 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2298 #ifdef CONFIG_MMU
2299 EXPORT_SYMBOL(copy_page);
2300
2301 -EXPORT_SYMBOL(__copy_from_user);
2302 -EXPORT_SYMBOL(__copy_to_user);
2303 -EXPORT_SYMBOL(__clear_user);
2304 +EXPORT_SYMBOL(___copy_from_user);
2305 +EXPORT_SYMBOL(___copy_to_user);
2306 +EXPORT_SYMBOL(___clear_user);
2307
2308 EXPORT_SYMBOL(__get_user_1);
2309 EXPORT_SYMBOL(__get_user_2);
2310 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2311 index 0f82098..3dbd3ee 100644
2312 --- a/arch/arm/kernel/entry-armv.S
2313 +++ b/arch/arm/kernel/entry-armv.S
2314 @@ -47,6 +47,87 @@
2315 9997:
2316 .endm
2317
2318 + .macro pax_enter_kernel
2319 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2320 + @ make aligned space for saved DACR
2321 + sub sp, sp, #8
2322 + @ save regs
2323 + stmdb sp!, {r1, r2}
2324 + @ read DACR from cpu_domain into r1
2325 + mov r2, sp
2326 + @ assume 8K pages, since we have to split the immediate in two
2327 + bic r2, r2, #(0x1fc0)
2328 + bic r2, r2, #(0x3f)
2329 + ldr r1, [r2, #TI_CPU_DOMAIN]
2330 + @ store old DACR on stack
2331 + str r1, [sp, #8]
2332 +#ifdef CONFIG_PAX_KERNEXEC
2333 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2334 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2335 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2336 +#endif
2337 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2338 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2339 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2340 +#endif
2341 + @ write r1 to current_thread_info()->cpu_domain
2342 + str r1, [r2, #TI_CPU_DOMAIN]
2343 + @ write r1 to DACR
2344 + mcr p15, 0, r1, c3, c0, 0
2345 + @ instruction sync
2346 + instr_sync
2347 + @ restore regs
2348 + ldmia sp!, {r1, r2}
2349 +#endif
2350 + .endm
2351 +
2352 + .macro pax_open_userland
2353 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2354 + @ save regs
2355 + stmdb sp!, {r0, r1}
2356 + @ read DACR from cpu_domain into r1
2357 + mov r0, sp
2358 + @ assume 8K pages, since we have to split the immediate in two
2359 + bic r0, r0, #(0x1fc0)
2360 + bic r0, r0, #(0x3f)
2361 + ldr r1, [r0, #TI_CPU_DOMAIN]
2362 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2363 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2364 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2365 + @ write r1 to current_thread_info()->cpu_domain
2366 + str r1, [r0, #TI_CPU_DOMAIN]
2367 + @ write r1 to DACR
2368 + mcr p15, 0, r1, c3, c0, 0
2369 + @ instruction sync
2370 + instr_sync
2371 + @ restore regs
2372 + ldmia sp!, {r0, r1}
2373 +#endif
2374 + .endm
2375 +
2376 + .macro pax_close_userland
2377 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2378 + @ save regs
2379 + stmdb sp!, {r0, r1}
2380 + @ read DACR from cpu_domain into r1
2381 + mov r0, sp
2382 + @ assume 8K pages, since we have to split the immediate in two
2383 + bic r0, r0, #(0x1fc0)
2384 + bic r0, r0, #(0x3f)
2385 + ldr r1, [r0, #TI_CPU_DOMAIN]
2386 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2387 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2388 + @ write r1 to current_thread_info()->cpu_domain
2389 + str r1, [r0, #TI_CPU_DOMAIN]
2390 + @ write r1 to DACR
2391 + mcr p15, 0, r1, c3, c0, 0
2392 + @ instruction sync
2393 + instr_sync
2394 + @ restore regs
2395 + ldmia sp!, {r0, r1}
2396 +#endif
2397 + .endm
2398 +
2399 .macro pabt_helper
2400 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2401 #ifdef MULTI_PABORT
2402 @@ -89,11 +170,15 @@
2403 * Invalid mode handlers
2404 */
2405 .macro inv_entry, reason
2406 +
2407 + pax_enter_kernel
2408 +
2409 sub sp, sp, #S_FRAME_SIZE
2410 ARM( stmib sp, {r1 - lr} )
2411 THUMB( stmia sp, {r0 - r12} )
2412 THUMB( str sp, [sp, #S_SP] )
2413 THUMB( str lr, [sp, #S_LR] )
2414 +
2415 mov r1, #\reason
2416 .endm
2417
2418 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2419 .macro svc_entry, stack_hole=0
2420 UNWIND(.fnstart )
2421 UNWIND(.save {r0 - pc} )
2422 +
2423 + pax_enter_kernel
2424 +
2425 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2426 +
2427 #ifdef CONFIG_THUMB2_KERNEL
2428 SPFIX( str r0, [sp] ) @ temporarily saved
2429 SPFIX( mov r0, sp )
2430 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2431 ldmia r0, {r3 - r5}
2432 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2433 mov r6, #-1 @ "" "" "" ""
2434 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2435 + @ offset sp by 8 as done in pax_enter_kernel
2436 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2437 +#else
2438 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2439 +#endif
2440 SPFIX( addeq r2, r2, #4 )
2441 str r3, [sp, #-4]! @ save the "real" r0 copied
2442 @ from the exception stack
2443 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2444 .macro usr_entry
2445 UNWIND(.fnstart )
2446 UNWIND(.cantunwind ) @ don't unwind the user space
2447 +
2448 + pax_enter_kernel_user
2449 +
2450 sub sp, sp, #S_FRAME_SIZE
2451 ARM( stmib sp, {r1 - r12} )
2452 THUMB( stmia sp, {r0 - r12} )
2453 @@ -456,7 +553,9 @@ __und_usr:
2454 tst r3, #PSR_T_BIT @ Thumb mode?
2455 bne __und_usr_thumb
2456 sub r4, r2, #4 @ ARM instr at LR - 4
2457 + pax_open_userland
2458 1: ldrt r0, [r4]
2459 + pax_close_userland
2460 #ifdef CONFIG_CPU_ENDIAN_BE8
2461 rev r0, r0 @ little endian instruction
2462 #endif
2463 @@ -491,10 +590,14 @@ __und_usr_thumb:
2464 */
2465 .arch armv6t2
2466 #endif
2467 + pax_open_userland
2468 2: ldrht r5, [r4]
2469 + pax_close_userland
2470 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2471 blo __und_usr_fault_16 @ 16bit undefined instruction
2472 + pax_open_userland
2473 3: ldrht r0, [r2]
2474 + pax_close_userland
2475 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2476 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2477 orr r0, r0, r5, lsl #16
2478 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2479 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2480 THUMB( str sp, [ip], #4 )
2481 THUMB( str lr, [ip], #4 )
2482 -#ifdef CONFIG_CPU_USE_DOMAINS
2483 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2484 ldr r6, [r2, #TI_CPU_DOMAIN]
2485 #endif
2486 set_tls r3, r4, r5
2487 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2488 ldr r8, =__stack_chk_guard
2489 ldr r7, [r7, #TSK_STACK_CANARY]
2490 #endif
2491 -#ifdef CONFIG_CPU_USE_DOMAINS
2492 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2493 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2494 #endif
2495 mov r5, r0
2496 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2497 index fefd7f9..e6f250e 100644
2498 --- a/arch/arm/kernel/entry-common.S
2499 +++ b/arch/arm/kernel/entry-common.S
2500 @@ -10,18 +10,46 @@
2501
2502 #include <asm/unistd.h>
2503 #include <asm/ftrace.h>
2504 +#include <asm/domain.h>
2505 #include <asm/unwind.h>
2506
2507 +#include "entry-header.S"
2508 +
2509 #ifdef CONFIG_NEED_RET_TO_USER
2510 #include <mach/entry-macro.S>
2511 #else
2512 .macro arch_ret_to_user, tmp1, tmp2
2513 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2514 + @ save regs
2515 + stmdb sp!, {r1, r2}
2516 + @ read DACR from cpu_domain into r1
2517 + mov r2, sp
2518 + @ assume 8K pages, since we have to split the immediate in two
2519 + bic r2, r2, #(0x1fc0)
2520 + bic r2, r2, #(0x3f)
2521 + ldr r1, [r2, #TI_CPU_DOMAIN]
2522 +#ifdef CONFIG_PAX_KERNEXEC
2523 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2524 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2525 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2526 +#endif
2527 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2528 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2529 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2530 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2531 +#endif
2532 + @ write r1 to current_thread_info()->cpu_domain
2533 + str r1, [r2, #TI_CPU_DOMAIN]
2534 + @ write r1 to DACR
2535 + mcr p15, 0, r1, c3, c0, 0
2536 + @ instruction sync
2537 + instr_sync
2538 + @ restore regs
2539 + ldmia sp!, {r1, r2}
2540 +#endif
2541 .endm
2542 #endif
2543
2544 -#include "entry-header.S"
2545 -
2546 -
2547 .align 5
2548 /*
2549 * This is the fast syscall return path. We do as little as
2550 @@ -351,6 +379,7 @@ ENDPROC(ftrace_stub)
2551
2552 .align 5
2553 ENTRY(vector_swi)
2554 +
2555 sub sp, sp, #S_FRAME_SIZE
2556 stmia sp, {r0 - r12} @ Calling r0 - r12
2557 ARM( add r8, sp, #S_PC )
2558 @@ -400,6 +429,12 @@ ENTRY(vector_swi)
2559 ldr scno, [lr, #-4] @ get SWI instruction
2560 #endif
2561
2562 + /*
2563 + * do this here to avoid a performance hit of wrapping the code above
2564 + * that directly dereferences userland to parse the SWI instruction
2565 + */
2566 + pax_enter_kernel_user
2567 +
2568 #ifdef CONFIG_ALIGNMENT_TRAP
2569 ldr ip, __cr_alignment
2570 ldr ip, [ip]
2571 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2572 index 9a8531e..812e287 100644
2573 --- a/arch/arm/kernel/entry-header.S
2574 +++ b/arch/arm/kernel/entry-header.S
2575 @@ -73,9 +73,66 @@
2576 msr cpsr_c, \rtemp @ switch back to the SVC mode
2577 .endm
2578
2579 + .macro pax_enter_kernel_user
2580 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2581 + @ save regs
2582 + stmdb sp!, {r0, r1}
2583 + @ read DACR from cpu_domain into r1
2584 + mov r0, sp
2585 + @ assume 8K pages, since we have to split the immediate in two
2586 + bic r0, r0, #(0x1fc0)
2587 + bic r0, r0, #(0x3f)
2588 + ldr r1, [r0, #TI_CPU_DOMAIN]
2589 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2590 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2591 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2592 +#endif
2593 +#ifdef CONFIG_PAX_KERNEXEC
2594 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2595 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2596 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2597 +#endif
2598 + @ write r1 to current_thread_info()->cpu_domain
2599 + str r1, [r0, #TI_CPU_DOMAIN]
2600 + @ write r1 to DACR
2601 + mcr p15, 0, r1, c3, c0, 0
2602 + @ instruction sync
2603 + instr_sync
2604 + @ restore regs
2605 + ldmia sp!, {r0, r1}
2606 +#endif
2607 + .endm
2608 +
2609 + .macro pax_exit_kernel
2610 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2611 + @ save regs
2612 + stmdb sp!, {r0, r1}
2613 + @ read old DACR from stack into r1
2614 + ldr r1, [sp, #(8 + S_SP)]
2615 + sub r1, r1, #8
2616 + ldr r1, [r1]
2617 +
2618 + @ write r1 to current_thread_info()->cpu_domain
2619 + mov r0, sp
2620 + @ assume 8K pages, since we have to split the immediate in two
2621 + bic r0, r0, #(0x1fc0)
2622 + bic r0, r0, #(0x3f)
2623 + str r1, [r0, #TI_CPU_DOMAIN]
2624 + @ write r1 to DACR
2625 + mcr p15, 0, r1, c3, c0, 0
2626 + @ instruction sync
2627 + instr_sync
2628 + @ restore regs
2629 + ldmia sp!, {r0, r1}
2630 +#endif
2631 + .endm
2632 +
2633 #ifndef CONFIG_THUMB2_KERNEL
2634 .macro svc_exit, rpsr
2635 msr spsr_cxsf, \rpsr
2636 +
2637 + pax_exit_kernel
2638 +
2639 #if defined(CONFIG_CPU_V6)
2640 ldr r0, [sp]
2641 strex r1, r2, [sp] @ clear the exclusive monitor
2642 @@ -121,6 +178,9 @@
2643 .endm
2644 #else /* CONFIG_THUMB2_KERNEL */
2645 .macro svc_exit, rpsr
2646 +
2647 + pax_exit_kernel
2648 +
2649 ldr lr, [sp, #S_SP] @ top of the stack
2650 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2651 clrex @ clear the exclusive monitor
2652 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2653 index 2adda11..7fbe958 100644
2654 --- a/arch/arm/kernel/fiq.c
2655 +++ b/arch/arm/kernel/fiq.c
2656 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2657 #if defined(CONFIG_CPU_USE_DOMAINS)
2658 memcpy((void *)0xffff001c, start, length);
2659 #else
2660 + pax_open_kernel();
2661 memcpy(vectors_page + 0x1c, start, length);
2662 + pax_close_kernel();
2663 #endif
2664 flush_icache_range(0xffff001c, 0xffff001c + length);
2665 if (!vectors_high())
2666 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2667 index 8bac553..caee108 100644
2668 --- a/arch/arm/kernel/head.S
2669 +++ b/arch/arm/kernel/head.S
2670 @@ -52,7 +52,9 @@
2671 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2672
2673 .macro pgtbl, rd, phys
2674 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2675 + mov \rd, #TEXT_OFFSET
2676 + sub \rd, #PG_DIR_SIZE
2677 + add \rd, \rd, \phys
2678 .endm
2679
2680 /*
2681 @@ -434,7 +436,7 @@ __enable_mmu:
2682 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2683 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2684 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2685 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2686 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2687 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2688 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2689 #endif
2690 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2691 index 1fd749e..47adb08 100644
2692 --- a/arch/arm/kernel/hw_breakpoint.c
2693 +++ b/arch/arm/kernel/hw_breakpoint.c
2694 @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2695 return NOTIFY_OK;
2696 }
2697
2698 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2699 +static struct notifier_block dbg_reset_nb = {
2700 .notifier_call = dbg_reset_notify,
2701 };
2702
2703 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2704 index 1e9be5d..03edbc2 100644
2705 --- a/arch/arm/kernel/module.c
2706 +++ b/arch/arm/kernel/module.c
2707 @@ -37,12 +37,37 @@
2708 #endif
2709
2710 #ifdef CONFIG_MMU
2711 -void *module_alloc(unsigned long size)
2712 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2713 {
2714 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2715 + return NULL;
2716 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2717 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2718 + GFP_KERNEL, prot, -1,
2719 __builtin_return_address(0));
2720 }
2721 +
2722 +void *module_alloc(unsigned long size)
2723 +{
2724 +
2725 +#ifdef CONFIG_PAX_KERNEXEC
2726 + return __module_alloc(size, PAGE_KERNEL);
2727 +#else
2728 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2729 +#endif
2730 +
2731 +}
2732 +
2733 +#ifdef CONFIG_PAX_KERNEXEC
2734 +void module_free_exec(struct module *mod, void *module_region)
2735 +{
2736 + module_free(mod, module_region);
2737 +}
2738 +
2739 +void *module_alloc_exec(unsigned long size)
2740 +{
2741 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2742 +}
2743 +#endif
2744 #endif
2745
2746 int
2747 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2748 index 07314af..c46655c 100644
2749 --- a/arch/arm/kernel/patch.c
2750 +++ b/arch/arm/kernel/patch.c
2751 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2752 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2753 int size;
2754
2755 + pax_open_kernel();
2756 if (thumb2 && __opcode_is_thumb16(insn)) {
2757 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2758 size = sizeof(u16);
2759 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2760 *(u32 *)addr = insn;
2761 size = sizeof(u32);
2762 }
2763 + pax_close_kernel();
2764
2765 flush_icache_range((uintptr_t)(addr),
2766 (uintptr_t)(addr) + size);
2767 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2768 index 1f2740e..b36e225 100644
2769 --- a/arch/arm/kernel/perf_event_cpu.c
2770 +++ b/arch/arm/kernel/perf_event_cpu.c
2771 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2772 return NOTIFY_OK;
2773 }
2774
2775 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2776 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2777 .notifier_call = cpu_pmu_notify,
2778 };
2779
2780 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2781 index 047d3e4..7e96107 100644
2782 --- a/arch/arm/kernel/process.c
2783 +++ b/arch/arm/kernel/process.c
2784 @@ -28,7 +28,6 @@
2785 #include <linux/tick.h>
2786 #include <linux/utsname.h>
2787 #include <linux/uaccess.h>
2788 -#include <linux/random.h>
2789 #include <linux/hw_breakpoint.h>
2790 #include <linux/cpuidle.h>
2791 #include <linux/leds.h>
2792 @@ -251,9 +250,10 @@ void machine_power_off(void)
2793 machine_shutdown();
2794 if (pm_power_off)
2795 pm_power_off();
2796 + BUG();
2797 }
2798
2799 -void machine_restart(char *cmd)
2800 +__noreturn void machine_restart(char *cmd)
2801 {
2802 machine_shutdown();
2803
2804 @@ -278,8 +278,8 @@ void __show_regs(struct pt_regs *regs)
2805 init_utsname()->release,
2806 (int)strcspn(init_utsname()->version, " "),
2807 init_utsname()->version);
2808 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2809 - print_symbol("LR is at %s\n", regs->ARM_lr);
2810 + printk("PC is at %pA\n", instruction_pointer(regs));
2811 + printk("LR is at %pA\n", regs->ARM_lr);
2812 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2813 "sp : %08lx ip : %08lx fp : %08lx\n",
2814 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2815 @@ -447,12 +447,6 @@ unsigned long get_wchan(struct task_struct *p)
2816 return 0;
2817 }
2818
2819 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2820 -{
2821 - unsigned long range_end = mm->brk + 0x02000000;
2822 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2823 -}
2824 -
2825 #ifdef CONFIG_MMU
2826 /*
2827 * The vectors page is always readable from user space for the
2828 @@ -465,9 +459,8 @@ static int __init gate_vma_init(void)
2829 {
2830 gate_vma.vm_start = 0xffff0000;
2831 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2832 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2833 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2834 - VM_MAYREAD | VM_MAYEXEC;
2835 + gate_vma.vm_flags = VM_NONE;
2836 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2837 return 0;
2838 }
2839 arch_initcall(gate_vma_init);
2840 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2841 index 3653164..d83e55d 100644
2842 --- a/arch/arm/kernel/psci.c
2843 +++ b/arch/arm/kernel/psci.c
2844 @@ -24,7 +24,7 @@
2845 #include <asm/opcodes-virt.h>
2846 #include <asm/psci.h>
2847
2848 -struct psci_operations psci_ops;
2849 +struct psci_operations psci_ops __read_only;
2850
2851 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2852
2853 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2854 index 03deeff..741ce88 100644
2855 --- a/arch/arm/kernel/ptrace.c
2856 +++ b/arch/arm/kernel/ptrace.c
2857 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2858 return current_thread_info()->syscall;
2859 }
2860
2861 +#ifdef CONFIG_GRKERNSEC_SETXID
2862 +extern void gr_delayed_cred_worker(void);
2863 +#endif
2864 +
2865 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2866 {
2867 current_thread_info()->syscall = scno;
2868
2869 +#ifdef CONFIG_GRKERNSEC_SETXID
2870 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2871 + gr_delayed_cred_worker();
2872 +#endif
2873 +
2874 /* Do the secure computing check first; failures should be fast. */
2875 if (secure_computing(scno) == -1)
2876 return -1;
2877 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2878 index 234e339..81264a1 100644
2879 --- a/arch/arm/kernel/setup.c
2880 +++ b/arch/arm/kernel/setup.c
2881 @@ -96,21 +96,23 @@ EXPORT_SYMBOL(system_serial_high);
2882 unsigned int elf_hwcap __read_mostly;
2883 EXPORT_SYMBOL(elf_hwcap);
2884
2885 +pteval_t __supported_pte_mask __read_only;
2886 +pmdval_t __supported_pmd_mask __read_only;
2887
2888 #ifdef MULTI_CPU
2889 -struct processor processor __read_mostly;
2890 +struct processor processor;
2891 #endif
2892 #ifdef MULTI_TLB
2893 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2894 +struct cpu_tlb_fns cpu_tlb __read_only;
2895 #endif
2896 #ifdef MULTI_USER
2897 -struct cpu_user_fns cpu_user __read_mostly;
2898 +struct cpu_user_fns cpu_user __read_only;
2899 #endif
2900 #ifdef MULTI_CACHE
2901 -struct cpu_cache_fns cpu_cache __read_mostly;
2902 +struct cpu_cache_fns cpu_cache __read_only;
2903 #endif
2904 #ifdef CONFIG_OUTER_CACHE
2905 -struct outer_cache_fns outer_cache __read_mostly;
2906 +struct outer_cache_fns outer_cache __read_only;
2907 EXPORT_SYMBOL(outer_cache);
2908 #endif
2909
2910 @@ -235,9 +237,13 @@ static int __get_cpu_architecture(void)
2911 asm("mrc p15, 0, %0, c0, c1, 4"
2912 : "=r" (mmfr0));
2913 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2914 - (mmfr0 & 0x000000f0) >= 0x00000030)
2915 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2916 cpu_arch = CPU_ARCH_ARMv7;
2917 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2918 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2919 + __supported_pte_mask |= L_PTE_PXN;
2920 + __supported_pmd_mask |= PMD_PXNTABLE;
2921 + }
2922 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2923 (mmfr0 & 0x000000f0) == 0x00000020)
2924 cpu_arch = CPU_ARCH_ARMv6;
2925 else
2926 @@ -478,7 +484,7 @@ static void __init setup_processor(void)
2927 __cpu_architecture = __get_cpu_architecture();
2928
2929 #ifdef MULTI_CPU
2930 - processor = *list->proc;
2931 + memcpy((void *)&processor, list->proc, sizeof processor);
2932 #endif
2933 #ifdef MULTI_TLB
2934 cpu_tlb = *list->tlb;
2935 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
2936 index 296786b..a8d4dd5 100644
2937 --- a/arch/arm/kernel/signal.c
2938 +++ b/arch/arm/kernel/signal.c
2939 @@ -396,22 +396,14 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
2940 __put_user(sigreturn_codes[idx+1], rc+1))
2941 return 1;
2942
2943 - if (cpsr & MODE32_BIT) {
2944 - /*
2945 - * 32-bit code can use the new high-page
2946 - * signal return code support.
2947 - */
2948 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
2949 - } else {
2950 - /*
2951 - * Ensure that the instruction cache sees
2952 - * the return code written onto the stack.
2953 - */
2954 - flush_icache_range((unsigned long)rc,
2955 - (unsigned long)(rc + 2));
2956 + /*
2957 + * Ensure that the instruction cache sees
2958 + * the return code written onto the stack.
2959 + */
2960 + flush_icache_range((unsigned long)rc,
2961 + (unsigned long)(rc + 2));
2962
2963 - retcode = ((unsigned long)rc) + thumb;
2964 - }
2965 + retcode = ((unsigned long)rc) + thumb;
2966 }
2967
2968 regs->ARM_r0 = map_sig(ksig->sig);
2969 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
2970 index 1f2cccc..f40c02e 100644
2971 --- a/arch/arm/kernel/smp.c
2972 +++ b/arch/arm/kernel/smp.c
2973 @@ -70,7 +70,7 @@ enum ipi_msg_type {
2974
2975 static DECLARE_COMPLETION(cpu_running);
2976
2977 -static struct smp_operations smp_ops;
2978 +static struct smp_operations smp_ops __read_only;
2979
2980 void __init smp_set_ops(struct smp_operations *ops)
2981 {
2982 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
2983 index 1c08911..264f009 100644
2984 --- a/arch/arm/kernel/traps.c
2985 +++ b/arch/arm/kernel/traps.c
2986 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
2987 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
2988 {
2989 #ifdef CONFIG_KALLSYMS
2990 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
2991 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
2992 #else
2993 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
2994 #endif
2995 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
2996 static int die_owner = -1;
2997 static unsigned int die_nest_count;
2998
2999 +extern void gr_handle_kernel_exploit(void);
3000 +
3001 static unsigned long oops_begin(void)
3002 {
3003 int cpu;
3004 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3005 panic("Fatal exception in interrupt");
3006 if (panic_on_oops)
3007 panic("Fatal exception");
3008 +
3009 + gr_handle_kernel_exploit();
3010 +
3011 if (signr)
3012 do_exit(signr);
3013 }
3014 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3015 * The user helper at 0xffff0fe0 must be used instead.
3016 * (see entry-armv.S for details)
3017 */
3018 + pax_open_kernel();
3019 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3020 + pax_close_kernel();
3021 }
3022 return 0;
3023
3024 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3025 */
3026 kuser_get_tls_init(vectors);
3027
3028 - /*
3029 - * Copy signal return handlers into the vector page, and
3030 - * set sigreturn to be a pointer to these.
3031 - */
3032 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3033 - sigreturn_codes, sizeof(sigreturn_codes));
3034 -
3035 flush_icache_range(vectors, vectors + PAGE_SIZE);
3036 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3037 +
3038 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3039 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3040 +#endif
3041 +
3042 }
3043 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3044 index b571484..4b2fc9b 100644
3045 --- a/arch/arm/kernel/vmlinux.lds.S
3046 +++ b/arch/arm/kernel/vmlinux.lds.S
3047 @@ -8,7 +8,11 @@
3048 #include <asm/thread_info.h>
3049 #include <asm/memory.h>
3050 #include <asm/page.h>
3051 -
3052 +
3053 +#ifdef CONFIG_PAX_KERNEXEC
3054 +#include <asm/pgtable.h>
3055 +#endif
3056 +
3057 #define PROC_INFO \
3058 . = ALIGN(4); \
3059 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3060 @@ -94,6 +98,11 @@ SECTIONS
3061 _text = .;
3062 HEAD_TEXT
3063 }
3064 +
3065 +#ifdef CONFIG_PAX_KERNEXEC
3066 + . = ALIGN(1<<SECTION_SHIFT);
3067 +#endif
3068 +
3069 .text : { /* Real text segment */
3070 _stext = .; /* Text and read-only data */
3071 __exception_text_start = .;
3072 @@ -116,6 +125,8 @@ SECTIONS
3073 ARM_CPU_KEEP(PROC_INFO)
3074 }
3075
3076 + _etext = .; /* End of text section */
3077 +
3078 RO_DATA(PAGE_SIZE)
3079
3080 . = ALIGN(4);
3081 @@ -146,7 +157,9 @@ SECTIONS
3082
3083 NOTES
3084
3085 - _etext = .; /* End of text and rodata section */
3086 +#ifdef CONFIG_PAX_KERNEXEC
3087 + . = ALIGN(1<<SECTION_SHIFT);
3088 +#endif
3089
3090 #ifndef CONFIG_XIP_KERNEL
3091 . = ALIGN(PAGE_SIZE);
3092 @@ -207,6 +220,11 @@ SECTIONS
3093 . = PAGE_OFFSET + TEXT_OFFSET;
3094 #else
3095 __init_end = .;
3096 +
3097 +#ifdef CONFIG_PAX_KERNEXEC
3098 + . = ALIGN(1<<SECTION_SHIFT);
3099 +#endif
3100 +
3101 . = ALIGN(THREAD_SIZE);
3102 __data_loc = .;
3103 #endif
3104 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3105 index 14a0d98..7771a7d 100644
3106 --- a/arch/arm/lib/clear_user.S
3107 +++ b/arch/arm/lib/clear_user.S
3108 @@ -12,14 +12,14 @@
3109
3110 .text
3111
3112 -/* Prototype: int __clear_user(void *addr, size_t sz)
3113 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3114 * Purpose : clear some user memory
3115 * Params : addr - user memory address to clear
3116 * : sz - number of bytes to clear
3117 * Returns : number of bytes NOT cleared
3118 */
3119 ENTRY(__clear_user_std)
3120 -WEAK(__clear_user)
3121 +WEAK(___clear_user)
3122 stmfd sp!, {r1, lr}
3123 mov r2, #0
3124 cmp r1, #4
3125 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3126 USER( strnebt r2, [r0])
3127 mov r0, #0
3128 ldmfd sp!, {r1, pc}
3129 -ENDPROC(__clear_user)
3130 +ENDPROC(___clear_user)
3131 ENDPROC(__clear_user_std)
3132
3133 .pushsection .fixup,"ax"
3134 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3135 index 66a477a..bee61d3 100644
3136 --- a/arch/arm/lib/copy_from_user.S
3137 +++ b/arch/arm/lib/copy_from_user.S
3138 @@ -16,7 +16,7 @@
3139 /*
3140 * Prototype:
3141 *
3142 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3143 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3144 *
3145 * Purpose:
3146 *
3147 @@ -84,11 +84,11 @@
3148
3149 .text
3150
3151 -ENTRY(__copy_from_user)
3152 +ENTRY(___copy_from_user)
3153
3154 #include "copy_template.S"
3155
3156 -ENDPROC(__copy_from_user)
3157 +ENDPROC(___copy_from_user)
3158
3159 .pushsection .fixup,"ax"
3160 .align 0
3161 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3162 index 6ee2f67..d1cce76 100644
3163 --- a/arch/arm/lib/copy_page.S
3164 +++ b/arch/arm/lib/copy_page.S
3165 @@ -10,6 +10,7 @@
3166 * ASM optimised string functions
3167 */
3168 #include <linux/linkage.h>
3169 +#include <linux/const.h>
3170 #include <asm/assembler.h>
3171 #include <asm/asm-offsets.h>
3172 #include <asm/cache.h>
3173 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3174 index d066df6..df28194 100644
3175 --- a/arch/arm/lib/copy_to_user.S
3176 +++ b/arch/arm/lib/copy_to_user.S
3177 @@ -16,7 +16,7 @@
3178 /*
3179 * Prototype:
3180 *
3181 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3182 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3183 *
3184 * Purpose:
3185 *
3186 @@ -88,11 +88,11 @@
3187 .text
3188
3189 ENTRY(__copy_to_user_std)
3190 -WEAK(__copy_to_user)
3191 +WEAK(___copy_to_user)
3192
3193 #include "copy_template.S"
3194
3195 -ENDPROC(__copy_to_user)
3196 +ENDPROC(___copy_to_user)
3197 ENDPROC(__copy_to_user_std)
3198
3199 .pushsection .fixup,"ax"
3200 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3201 index 7d08b43..f7ca7ea 100644
3202 --- a/arch/arm/lib/csumpartialcopyuser.S
3203 +++ b/arch/arm/lib/csumpartialcopyuser.S
3204 @@ -57,8 +57,8 @@
3205 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3206 */
3207
3208 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3209 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3210 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3211 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3212
3213 #include "csumpartialcopygeneric.S"
3214
3215 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3216 index 64dbfa5..84a3fd9 100644
3217 --- a/arch/arm/lib/delay.c
3218 +++ b/arch/arm/lib/delay.c
3219 @@ -28,7 +28,7 @@
3220 /*
3221 * Default to the loop-based delay implementation.
3222 */
3223 -struct arm_delay_ops arm_delay_ops = {
3224 +struct arm_delay_ops arm_delay_ops __read_only = {
3225 .delay = __loop_delay,
3226 .const_udelay = __loop_const_udelay,
3227 .udelay = __loop_udelay,
3228 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3229 index 025f742..8432b08 100644
3230 --- a/arch/arm/lib/uaccess_with_memcpy.c
3231 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3232 @@ -104,7 +104,7 @@ out:
3233 }
3234
3235 unsigned long
3236 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3237 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3238 {
3239 /*
3240 * This test is stubbed out of the main function above to keep
3241 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3242 index 49792a0..f192052 100644
3243 --- a/arch/arm/mach-kirkwood/common.c
3244 +++ b/arch/arm/mach-kirkwood/common.c
3245 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3246 clk_gate_ops.disable(hw);
3247 }
3248
3249 -static struct clk_ops clk_gate_fn_ops;
3250 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3251 +{
3252 + return clk_gate_ops.is_enabled(hw);
3253 +}
3254 +
3255 +static struct clk_ops clk_gate_fn_ops = {
3256 + .enable = clk_gate_fn_enable,
3257 + .disable = clk_gate_fn_disable,
3258 + .is_enabled = clk_gate_fn_is_enabled,
3259 +};
3260
3261 static struct clk __init *clk_register_gate_fn(struct device *dev,
3262 const char *name,
3263 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3264 gate_fn->fn_en = fn_en;
3265 gate_fn->fn_dis = fn_dis;
3266
3267 - /* ops is the gate ops, but with our enable/disable functions */
3268 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3269 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3270 - clk_gate_fn_ops = clk_gate_ops;
3271 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3272 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3273 - }
3274 -
3275 clk = clk_register(dev, &gate_fn->gate.hw);
3276
3277 if (IS_ERR(clk))
3278 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3279 index f6eeb87..cc90868 100644
3280 --- a/arch/arm/mach-omap2/board-n8x0.c
3281 +++ b/arch/arm/mach-omap2/board-n8x0.c
3282 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3283 }
3284 #endif
3285
3286 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3287 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3288 .late_init = n8x0_menelaus_late_init,
3289 };
3290
3291 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3292 index 410e1ba..1d2dd59 100644
3293 --- a/arch/arm/mach-omap2/gpmc.c
3294 +++ b/arch/arm/mach-omap2/gpmc.c
3295 @@ -145,7 +145,6 @@ struct omap3_gpmc_regs {
3296 };
3297
3298 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3299 -static struct irq_chip gpmc_irq_chip;
3300 static unsigned gpmc_irq_start;
3301
3302 static struct resource gpmc_mem_root;
3303 @@ -707,6 +706,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3304
3305 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3306
3307 +static struct irq_chip gpmc_irq_chip = {
3308 + .name = "gpmc",
3309 + .irq_startup = gpmc_irq_noop_ret,
3310 + .irq_enable = gpmc_irq_enable,
3311 + .irq_disable = gpmc_irq_disable,
3312 + .irq_shutdown = gpmc_irq_noop,
3313 + .irq_ack = gpmc_irq_noop,
3314 + .irq_mask = gpmc_irq_noop,
3315 + .irq_unmask = gpmc_irq_noop,
3316 +
3317 +};
3318 +
3319 static int gpmc_setup_irq(void)
3320 {
3321 int i;
3322 @@ -721,15 +732,6 @@ static int gpmc_setup_irq(void)
3323 return gpmc_irq_start;
3324 }
3325
3326 - gpmc_irq_chip.name = "gpmc";
3327 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3328 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3329 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3330 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3331 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3332 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3333 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3334 -
3335 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3336 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3337
3338 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3339 index f8bb3b9..831e7b8 100644
3340 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3341 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3342 @@ -339,7 +339,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3343 return NOTIFY_OK;
3344 }
3345
3346 -static struct notifier_block __refdata irq_hotplug_notifier = {
3347 +static struct notifier_block irq_hotplug_notifier = {
3348 .notifier_call = irq_cpu_hotplug_notify,
3349 };
3350
3351 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3352 index 381be7a..89b9c7e 100644
3353 --- a/arch/arm/mach-omap2/omap_device.c
3354 +++ b/arch/arm/mach-omap2/omap_device.c
3355 @@ -499,7 +499,7 @@ void omap_device_delete(struct omap_device *od)
3356 struct platform_device __init *omap_device_build(const char *pdev_name,
3357 int pdev_id,
3358 struct omap_hwmod *oh,
3359 - void *pdata, int pdata_len)
3360 + const void *pdata, int pdata_len)
3361 {
3362 struct omap_hwmod *ohs[] = { oh };
3363
3364 @@ -527,7 +527,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3365 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3366 int pdev_id,
3367 struct omap_hwmod **ohs,
3368 - int oh_cnt, void *pdata,
3369 + int oh_cnt, const void *pdata,
3370 int pdata_len)
3371 {
3372 int ret = -ENOMEM;
3373 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3374 index 044c31d..2ee0861 100644
3375 --- a/arch/arm/mach-omap2/omap_device.h
3376 +++ b/arch/arm/mach-omap2/omap_device.h
3377 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3378 /* Core code interface */
3379
3380 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3381 - struct omap_hwmod *oh, void *pdata,
3382 + struct omap_hwmod *oh, const void *pdata,
3383 int pdata_len);
3384
3385 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3386 struct omap_hwmod **oh, int oh_cnt,
3387 - void *pdata, int pdata_len);
3388 + const void *pdata, int pdata_len);
3389
3390 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3391 struct omap_hwmod **ohs, int oh_cnt);
3392 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3393 index a202a47..c430564 100644
3394 --- a/arch/arm/mach-omap2/omap_hwmod.c
3395 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3396 @@ -191,10 +191,10 @@ struct omap_hwmod_soc_ops {
3397 int (*init_clkdm)(struct omap_hwmod *oh);
3398 void (*update_context_lost)(struct omap_hwmod *oh);
3399 int (*get_context_lost)(struct omap_hwmod *oh);
3400 -};
3401 +} __no_const;
3402
3403 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3404 -static struct omap_hwmod_soc_ops soc_ops;
3405 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3406
3407 /* omap_hwmod_list contains all registered struct omap_hwmods */
3408 static LIST_HEAD(omap_hwmod_list);
3409 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3410 index d15c7bb..b2d1f0c 100644
3411 --- a/arch/arm/mach-omap2/wd_timer.c
3412 +++ b/arch/arm/mach-omap2/wd_timer.c
3413 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3414 struct omap_hwmod *oh;
3415 char *oh_name = "wd_timer2";
3416 char *dev_name = "omap_wdt";
3417 - struct omap_wd_timer_platform_data pdata;
3418 + static struct omap_wd_timer_platform_data pdata = {
3419 + .read_reset_sources = prm_read_reset_sources
3420 + };
3421
3422 if (!cpu_class_is_omap2() || of_have_populated_dt())
3423 return 0;
3424 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3425 return -EINVAL;
3426 }
3427
3428 - pdata.read_reset_sources = prm_read_reset_sources;
3429 -
3430 pdev = omap_device_build(dev_name, id, oh, &pdata,
3431 sizeof(struct omap_wd_timer_platform_data));
3432 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3433 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3434 index bddce2b..3eb04e2 100644
3435 --- a/arch/arm/mach-ux500/include/mach/setup.h
3436 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3437 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3438 .type = MT_DEVICE, \
3439 }
3440
3441 -#define __MEM_DEV_DESC(x, sz) { \
3442 - .virtual = IO_ADDRESS(x), \
3443 - .pfn = __phys_to_pfn(x), \
3444 - .length = sz, \
3445 - .type = MT_MEMORY, \
3446 -}
3447 -
3448 extern struct smp_operations ux500_smp_ops;
3449 extern void ux500_cpu_die(unsigned int cpu);
3450
3451 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3452 index 4045c49..4e26c79 100644
3453 --- a/arch/arm/mm/Kconfig
3454 +++ b/arch/arm/mm/Kconfig
3455 @@ -425,7 +425,7 @@ config CPU_32v5
3456
3457 config CPU_32v6
3458 bool
3459 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3460 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3461 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3462
3463 config CPU_32v6K
3464 @@ -574,6 +574,7 @@ config CPU_CP15_MPU
3465
3466 config CPU_USE_DOMAINS
3467 bool
3468 + depends on !ARM_LPAE && !PAX_KERNEXEC
3469 help
3470 This option enables or disables the use of domain switching
3471 via the set_fs() function.
3472 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3473 index db26e2e..ee44569 100644
3474 --- a/arch/arm/mm/alignment.c
3475 +++ b/arch/arm/mm/alignment.c
3476 @@ -211,10 +211,12 @@ union offset_union {
3477 #define __get16_unaligned_check(ins,val,addr) \
3478 do { \
3479 unsigned int err = 0, v, a = addr; \
3480 + pax_open_userland(); \
3481 __get8_unaligned_check(ins,v,a,err); \
3482 val = v << ((BE) ? 8 : 0); \
3483 __get8_unaligned_check(ins,v,a,err); \
3484 val |= v << ((BE) ? 0 : 8); \
3485 + pax_close_userland(); \
3486 if (err) \
3487 goto fault; \
3488 } while (0)
3489 @@ -228,6 +230,7 @@ union offset_union {
3490 #define __get32_unaligned_check(ins,val,addr) \
3491 do { \
3492 unsigned int err = 0, v, a = addr; \
3493 + pax_open_userland(); \
3494 __get8_unaligned_check(ins,v,a,err); \
3495 val = v << ((BE) ? 24 : 0); \
3496 __get8_unaligned_check(ins,v,a,err); \
3497 @@ -236,6 +239,7 @@ union offset_union {
3498 val |= v << ((BE) ? 8 : 16); \
3499 __get8_unaligned_check(ins,v,a,err); \
3500 val |= v << ((BE) ? 0 : 24); \
3501 + pax_close_userland(); \
3502 if (err) \
3503 goto fault; \
3504 } while (0)
3505 @@ -249,6 +253,7 @@ union offset_union {
3506 #define __put16_unaligned_check(ins,val,addr) \
3507 do { \
3508 unsigned int err = 0, v = val, a = addr; \
3509 + pax_open_userland(); \
3510 __asm__( FIRST_BYTE_16 \
3511 ARM( "1: "ins" %1, [%2], #1\n" ) \
3512 THUMB( "1: "ins" %1, [%2]\n" ) \
3513 @@ -268,6 +273,7 @@ union offset_union {
3514 " .popsection\n" \
3515 : "=r" (err), "=&r" (v), "=&r" (a) \
3516 : "0" (err), "1" (v), "2" (a)); \
3517 + pax_close_userland(); \
3518 if (err) \
3519 goto fault; \
3520 } while (0)
3521 @@ -281,6 +287,7 @@ union offset_union {
3522 #define __put32_unaligned_check(ins,val,addr) \
3523 do { \
3524 unsigned int err = 0, v = val, a = addr; \
3525 + pax_open_userland(); \
3526 __asm__( FIRST_BYTE_32 \
3527 ARM( "1: "ins" %1, [%2], #1\n" ) \
3528 THUMB( "1: "ins" %1, [%2]\n" ) \
3529 @@ -310,6 +317,7 @@ union offset_union {
3530 " .popsection\n" \
3531 : "=r" (err), "=&r" (v), "=&r" (a) \
3532 : "0" (err), "1" (v), "2" (a)); \
3533 + pax_close_userland(); \
3534 if (err) \
3535 goto fault; \
3536 } while (0)
3537 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3538 index 5dbf13f..1a60561 100644
3539 --- a/arch/arm/mm/fault.c
3540 +++ b/arch/arm/mm/fault.c
3541 @@ -25,6 +25,7 @@
3542 #include <asm/system_misc.h>
3543 #include <asm/system_info.h>
3544 #include <asm/tlbflush.h>
3545 +#include <asm/sections.h>
3546
3547 #include "fault.h"
3548
3549 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3550 if (fixup_exception(regs))
3551 return;
3552
3553 +#ifdef CONFIG_PAX_KERNEXEC
3554 + if ((fsr & FSR_WRITE) &&
3555 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3556 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3557 + {
3558 + if (current->signal->curr_ip)
3559 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3560 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3561 + else
3562 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3563 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3564 + }
3565 +#endif
3566 +
3567 /*
3568 * No handler, we'll have to terminate things with extreme prejudice.
3569 */
3570 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3571 }
3572 #endif
3573
3574 +#ifdef CONFIG_PAX_PAGEEXEC
3575 + if (fsr & FSR_LNX_PF) {
3576 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3577 + do_group_exit(SIGKILL);
3578 + }
3579 +#endif
3580 +
3581 tsk->thread.address = addr;
3582 tsk->thread.error_code = fsr;
3583 tsk->thread.trap_no = 14;
3584 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3585 }
3586 #endif /* CONFIG_MMU */
3587
3588 +#ifdef CONFIG_PAX_PAGEEXEC
3589 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3590 +{
3591 + long i;
3592 +
3593 + printk(KERN_ERR "PAX: bytes at PC: ");
3594 + for (i = 0; i < 20; i++) {
3595 + unsigned char c;
3596 + if (get_user(c, (__force unsigned char __user *)pc+i))
3597 + printk(KERN_CONT "?? ");
3598 + else
3599 + printk(KERN_CONT "%02x ", c);
3600 + }
3601 + printk("\n");
3602 +
3603 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3604 + for (i = -1; i < 20; i++) {
3605 + unsigned long c;
3606 + if (get_user(c, (__force unsigned long __user *)sp+i))
3607 + printk(KERN_CONT "???????? ");
3608 + else
3609 + printk(KERN_CONT "%08lx ", c);
3610 + }
3611 + printk("\n");
3612 +}
3613 +#endif
3614 +
3615 /*
3616 * First Level Translation Fault Handler
3617 *
3618 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3619 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3620 struct siginfo info;
3621
3622 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3623 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3624 + if (current->signal->curr_ip)
3625 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3626 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3627 + else
3628 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3629 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3630 + goto die;
3631 + }
3632 +#endif
3633 +
3634 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3635 return;
3636
3637 +die:
3638 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3639 inf->name, fsr, addr);
3640
3641 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3642 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3643 struct siginfo info;
3644
3645 + if (user_mode(regs)) {
3646 + if (addr == 0xffff0fe0UL) {
3647 + /*
3648 + * PaX: __kuser_get_tls emulation
3649 + */
3650 + regs->ARM_r0 = current_thread_info()->tp_value;
3651 + regs->ARM_pc = regs->ARM_lr;
3652 + return;
3653 + }
3654 + }
3655 +
3656 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3657 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3658 + if (current->signal->curr_ip)
3659 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3660 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3661 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3662 + else
3663 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3664 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3665 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3666 + goto die;
3667 + }
3668 +#endif
3669 +
3670 +#ifdef CONFIG_PAX_REFCOUNT
3671 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3672 + unsigned int bkpt;
3673 +
3674 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3675 + current->thread.error_code = ifsr;
3676 + current->thread.trap_no = 0;
3677 + pax_report_refcount_overflow(regs);
3678 + fixup_exception(regs);
3679 + return;
3680 + }
3681 + }
3682 +#endif
3683 +
3684 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3685 return;
3686
3687 +die:
3688 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3689 inf->name, ifsr, addr);
3690
3691 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3692 index cf08bdf..772656c 100644
3693 --- a/arch/arm/mm/fault.h
3694 +++ b/arch/arm/mm/fault.h
3695 @@ -3,6 +3,7 @@
3696
3697 /*
3698 * Fault status register encodings. We steal bit 31 for our own purposes.
3699 + * Set when the FSR value is from an instruction fault.
3700 */
3701 #define FSR_LNX_PF (1 << 31)
3702 #define FSR_WRITE (1 << 11)
3703 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3704 }
3705 #endif
3706
3707 +/* valid for LPAE and !LPAE */
3708 +static inline int is_xn_fault(unsigned int fsr)
3709 +{
3710 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3711 +}
3712 +
3713 +static inline int is_domain_fault(unsigned int fsr)
3714 +{
3715 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3716 +}
3717 +
3718 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3719 unsigned long search_exception_table(unsigned long addr);
3720
3721 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3722 index ad722f1..763fdd3 100644
3723 --- a/arch/arm/mm/init.c
3724 +++ b/arch/arm/mm/init.c
3725 @@ -30,6 +30,8 @@
3726 #include <asm/setup.h>
3727 #include <asm/tlb.h>
3728 #include <asm/fixmap.h>
3729 +#include <asm/system_info.h>
3730 +#include <asm/cp15.h>
3731
3732 #include <asm/mach/arch.h>
3733 #include <asm/mach/map.h>
3734 @@ -736,7 +738,46 @@ void free_initmem(void)
3735 {
3736 #ifdef CONFIG_HAVE_TCM
3737 extern char __tcm_start, __tcm_end;
3738 +#endif
3739
3740 +#ifdef CONFIG_PAX_KERNEXEC
3741 + unsigned long addr;
3742 + pgd_t *pgd;
3743 + pud_t *pud;
3744 + pmd_t *pmd;
3745 + int cpu_arch = cpu_architecture();
3746 + unsigned int cr = get_cr();
3747 +
3748 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3749 + /* make pages tables, etc before .text NX */
3750 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3751 + pgd = pgd_offset_k(addr);
3752 + pud = pud_offset(pgd, addr);
3753 + pmd = pmd_offset(pud, addr);
3754 + __section_update(pmd, addr, PMD_SECT_XN);
3755 + }
3756 + /* make init NX */
3757 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3758 + pgd = pgd_offset_k(addr);
3759 + pud = pud_offset(pgd, addr);
3760 + pmd = pmd_offset(pud, addr);
3761 + __section_update(pmd, addr, PMD_SECT_XN);
3762 + }
3763 + /* make kernel code/rodata RX */
3764 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3765 + pgd = pgd_offset_k(addr);
3766 + pud = pud_offset(pgd, addr);
3767 + pmd = pmd_offset(pud, addr);
3768 +#ifdef CONFIG_ARM_LPAE
3769 + __section_update(pmd, addr, PMD_SECT_RDONLY);
3770 +#else
3771 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
3772 +#endif
3773 + }
3774 + }
3775 +#endif
3776 +
3777 +#ifdef CONFIG_HAVE_TCM
3778 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
3779 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
3780 __phys_to_pfn(__pa(&__tcm_end)),
3781 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
3782 index 04d9006..c547d85 100644
3783 --- a/arch/arm/mm/ioremap.c
3784 +++ b/arch/arm/mm/ioremap.c
3785 @@ -392,9 +392,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
3786 unsigned int mtype;
3787
3788 if (cached)
3789 - mtype = MT_MEMORY;
3790 + mtype = MT_MEMORY_RX;
3791 else
3792 - mtype = MT_MEMORY_NONCACHED;
3793 + mtype = MT_MEMORY_NONCACHED_RX;
3794
3795 return __arm_ioremap_caller(phys_addr, size, mtype,
3796 __builtin_return_address(0));
3797 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
3798 index 10062ce..cd34fb9 100644
3799 --- a/arch/arm/mm/mmap.c
3800 +++ b/arch/arm/mm/mmap.c
3801 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3802 struct vm_area_struct *vma;
3803 int do_align = 0;
3804 int aliasing = cache_is_vipt_aliasing();
3805 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3806 struct vm_unmapped_area_info info;
3807
3808 /*
3809 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3810 if (len > TASK_SIZE)
3811 return -ENOMEM;
3812
3813 +#ifdef CONFIG_PAX_RANDMMAP
3814 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3815 +#endif
3816 +
3817 if (addr) {
3818 if (do_align)
3819 addr = COLOUR_ALIGN(addr, pgoff);
3820 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3821 addr = PAGE_ALIGN(addr);
3822
3823 vma = find_vma(mm, addr);
3824 - if (TASK_SIZE - len >= addr &&
3825 - (!vma || addr + len <= vma->vm_start))
3826 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3827 return addr;
3828 }
3829
3830 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3831 info.high_limit = TASK_SIZE;
3832 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3833 info.align_offset = pgoff << PAGE_SHIFT;
3834 + info.threadstack_offset = offset;
3835 return vm_unmapped_area(&info);
3836 }
3837
3838 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3839 unsigned long addr = addr0;
3840 int do_align = 0;
3841 int aliasing = cache_is_vipt_aliasing();
3842 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3843 struct vm_unmapped_area_info info;
3844
3845 /*
3846 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3847 return addr;
3848 }
3849
3850 +#ifdef CONFIG_PAX_RANDMMAP
3851 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3852 +#endif
3853 +
3854 /* requesting a specific address */
3855 if (addr) {
3856 if (do_align)
3857 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3858 else
3859 addr = PAGE_ALIGN(addr);
3860 vma = find_vma(mm, addr);
3861 - if (TASK_SIZE - len >= addr &&
3862 - (!vma || addr + len <= vma->vm_start))
3863 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3864 return addr;
3865 }
3866
3867 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3868 info.high_limit = mm->mmap_base;
3869 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3870 info.align_offset = pgoff << PAGE_SHIFT;
3871 + info.threadstack_offset = offset;
3872 addr = vm_unmapped_area(&info);
3873
3874 /*
3875 @@ -162,6 +172,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3876 VM_BUG_ON(addr != -ENOMEM);
3877 info.flags = 0;
3878 info.low_limit = mm->mmap_base;
3879 +
3880 +#ifdef CONFIG_PAX_RANDMMAP
3881 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3882 + info.low_limit += mm->delta_mmap;
3883 +#endif
3884 +
3885 info.high_limit = TASK_SIZE;
3886 addr = vm_unmapped_area(&info);
3887 }
3888 @@ -173,6 +189,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3889 {
3890 unsigned long random_factor = 0UL;
3891
3892 +#ifdef CONFIG_PAX_RANDMMAP
3893 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3894 +#endif
3895 +
3896 /* 8 bits of randomness in 20 address space bits */
3897 if ((current->flags & PF_RANDOMIZE) &&
3898 !(current->personality & ADDR_NO_RANDOMIZE))
3899 @@ -180,10 +200,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3900
3901 if (mmap_is_legacy()) {
3902 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
3903 +
3904 +#ifdef CONFIG_PAX_RANDMMAP
3905 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3906 + mm->mmap_base += mm->delta_mmap;
3907 +#endif
3908 +
3909 mm->get_unmapped_area = arch_get_unmapped_area;
3910 mm->unmap_area = arch_unmap_area;
3911 } else {
3912 mm->mmap_base = mmap_base(random_factor);
3913 +
3914 +#ifdef CONFIG_PAX_RANDMMAP
3915 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3916 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
3917 +#endif
3918 +
3919 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
3920 mm->unmap_area = arch_unmap_area_topdown;
3921 }
3922 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
3923 index a84ff76..f221c1d 100644
3924 --- a/arch/arm/mm/mmu.c
3925 +++ b/arch/arm/mm/mmu.c
3926 @@ -36,6 +36,22 @@
3927 #include "mm.h"
3928 #include "tcm.h"
3929
3930 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3931 +void modify_domain(unsigned int dom, unsigned int type)
3932 +{
3933 + struct thread_info *thread = current_thread_info();
3934 + unsigned int domain = thread->cpu_domain;
3935 + /*
3936 + * DOMAIN_MANAGER might be defined to some other value,
3937 + * use the arch-defined constant
3938 + */
3939 + domain &= ~domain_val(dom, 3);
3940 + thread->cpu_domain = domain | domain_val(dom, type);
3941 + set_domain(thread->cpu_domain);
3942 +}
3943 +EXPORT_SYMBOL(modify_domain);
3944 +#endif
3945 +
3946 /*
3947 * empty_zero_page is a special page that is used for
3948 * zero-initialized data and COW.
3949 @@ -211,10 +227,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
3950 }
3951 #endif
3952
3953 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
3954 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
3955 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
3956
3957 -static struct mem_type mem_types[] = {
3958 +#ifdef CONFIG_PAX_KERNEXEC
3959 +#define L_PTE_KERNEXEC L_PTE_RDONLY
3960 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
3961 +#else
3962 +#define L_PTE_KERNEXEC L_PTE_DIRTY
3963 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
3964 +#endif
3965 +
3966 +static struct mem_type mem_types[] __read_only = {
3967 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
3968 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
3969 L_PTE_SHARED,
3970 @@ -243,16 +267,16 @@ static struct mem_type mem_types[] = {
3971 [MT_UNCACHED] = {
3972 .prot_pte = PROT_PTE_DEVICE,
3973 .prot_l1 = PMD_TYPE_TABLE,
3974 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
3975 + .prot_sect = PROT_SECT_DEVICE,
3976 .domain = DOMAIN_IO,
3977 },
3978 [MT_CACHECLEAN] = {
3979 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
3980 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
3981 .domain = DOMAIN_KERNEL,
3982 },
3983 #ifndef CONFIG_ARM_LPAE
3984 [MT_MINICLEAN] = {
3985 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
3986 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
3987 .domain = DOMAIN_KERNEL,
3988 },
3989 #endif
3990 @@ -260,36 +284,54 @@ static struct mem_type mem_types[] = {
3991 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
3992 L_PTE_RDONLY,
3993 .prot_l1 = PMD_TYPE_TABLE,
3994 - .domain = DOMAIN_USER,
3995 + .domain = DOMAIN_VECTORS,
3996 },
3997 [MT_HIGH_VECTORS] = {
3998 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
3999 - L_PTE_USER | L_PTE_RDONLY,
4000 + L_PTE_RDONLY,
4001 .prot_l1 = PMD_TYPE_TABLE,
4002 - .domain = DOMAIN_USER,
4003 + .domain = DOMAIN_VECTORS,
4004 },
4005 - [MT_MEMORY] = {
4006 + [MT_MEMORY_RWX] = {
4007 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4008 .prot_l1 = PMD_TYPE_TABLE,
4009 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4010 .domain = DOMAIN_KERNEL,
4011 },
4012 + [MT_MEMORY_RW] = {
4013 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4014 + .prot_l1 = PMD_TYPE_TABLE,
4015 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4016 + .domain = DOMAIN_KERNEL,
4017 + },
4018 + [MT_MEMORY_RX] = {
4019 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4020 + .prot_l1 = PMD_TYPE_TABLE,
4021 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4022 + .domain = DOMAIN_KERNEL,
4023 + },
4024 [MT_ROM] = {
4025 - .prot_sect = PMD_TYPE_SECT,
4026 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4027 .domain = DOMAIN_KERNEL,
4028 },
4029 - [MT_MEMORY_NONCACHED] = {
4030 + [MT_MEMORY_NONCACHED_RW] = {
4031 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4032 L_PTE_MT_BUFFERABLE,
4033 .prot_l1 = PMD_TYPE_TABLE,
4034 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4035 .domain = DOMAIN_KERNEL,
4036 },
4037 + [MT_MEMORY_NONCACHED_RX] = {
4038 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4039 + L_PTE_MT_BUFFERABLE,
4040 + .prot_l1 = PMD_TYPE_TABLE,
4041 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4042 + .domain = DOMAIN_KERNEL,
4043 + },
4044 [MT_MEMORY_DTCM] = {
4045 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4046 - L_PTE_XN,
4047 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4048 .prot_l1 = PMD_TYPE_TABLE,
4049 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4050 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4051 .domain = DOMAIN_KERNEL,
4052 },
4053 [MT_MEMORY_ITCM] = {
4054 @@ -299,10 +341,10 @@ static struct mem_type mem_types[] = {
4055 },
4056 [MT_MEMORY_SO] = {
4057 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4058 - L_PTE_MT_UNCACHED | L_PTE_XN,
4059 + L_PTE_MT_UNCACHED,
4060 .prot_l1 = PMD_TYPE_TABLE,
4061 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4062 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4063 + PMD_SECT_UNCACHED,
4064 .domain = DOMAIN_KERNEL,
4065 },
4066 [MT_MEMORY_DMA_READY] = {
4067 @@ -388,9 +430,35 @@ static void __init build_mem_type_table(void)
4068 * to prevent speculative instruction fetches.
4069 */
4070 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4071 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4072 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4073 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4074 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4075 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4076 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4077 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4078 +
4079 + /* Mark other regions on ARMv6+ as execute-never */
4080 +
4081 +#ifdef CONFIG_PAX_KERNEXEC
4082 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4083 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4084 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4085 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4086 +#ifndef CONFIG_ARM_LPAE
4087 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4088 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4089 +#endif
4090 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4091 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4092 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4093 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4094 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4095 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4096 +#endif
4097 +
4098 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4099 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4100 }
4101 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4102 /*
4103 @@ -451,6 +519,9 @@ static void __init build_mem_type_table(void)
4104 * from SVC mode and no access from userspace.
4105 */
4106 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4107 +#ifdef CONFIG_PAX_KERNEXEC
4108 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4109 +#endif
4110 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4111 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4112 #endif
4113 @@ -468,11 +539,17 @@ static void __init build_mem_type_table(void)
4114 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4115 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4116 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4117 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4118 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4119 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4120 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4121 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4122 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4123 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4124 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4125 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4126 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4127 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4128 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4129 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4130 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4131 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4132 }
4133 }
4134
4135 @@ -483,15 +560,20 @@ static void __init build_mem_type_table(void)
4136 if (cpu_arch >= CPU_ARCH_ARMv6) {
4137 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4138 /* Non-cacheable Normal is XCB = 001 */
4139 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4140 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4141 + PMD_SECT_BUFFERED;
4142 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4143 PMD_SECT_BUFFERED;
4144 } else {
4145 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4146 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4147 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4148 + PMD_SECT_TEX(1);
4149 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4150 PMD_SECT_TEX(1);
4151 }
4152 } else {
4153 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4154 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4155 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4156 }
4157
4158 #ifdef CONFIG_ARM_LPAE
4159 @@ -507,6 +589,8 @@ static void __init build_mem_type_table(void)
4160 vecs_pgprot |= PTE_EXT_AF;
4161 #endif
4162
4163 + user_pgprot |= __supported_pte_mask;
4164 +
4165 for (i = 0; i < 16; i++) {
4166 pteval_t v = pgprot_val(protection_map[i]);
4167 protection_map[i] = __pgprot(v | user_pgprot);
4168 @@ -524,10 +608,15 @@ static void __init build_mem_type_table(void)
4169
4170 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4171 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4172 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4173 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4174 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4175 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4176 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4177 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4178 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4179 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4180 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4181 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4182 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4183 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4184 mem_types[MT_ROM].prot_sect |= cp->pmd;
4185
4186 switch (cp->pmd) {
4187 @@ -1147,18 +1236,15 @@ void __init arm_mm_memblock_reserve(void)
4188 * called function. This means you can't use any function or debugging
4189 * method which may touch any device, otherwise the kernel _will_ crash.
4190 */
4191 +
4192 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4193 +
4194 static void __init devicemaps_init(struct machine_desc *mdesc)
4195 {
4196 struct map_desc map;
4197 unsigned long addr;
4198 - void *vectors;
4199
4200 - /*
4201 - * Allocate the vector page early.
4202 - */
4203 - vectors = early_alloc(PAGE_SIZE);
4204 -
4205 - early_trap_init(vectors);
4206 + early_trap_init(&vectors);
4207
4208 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4209 pmd_clear(pmd_off_k(addr));
4210 @@ -1198,7 +1284,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4211 * location (0xffff0000). If we aren't using high-vectors, also
4212 * create a mapping at the low-vectors virtual address.
4213 */
4214 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4215 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4216 map.virtual = 0xffff0000;
4217 map.length = PAGE_SIZE;
4218 map.type = MT_HIGH_VECTORS;
4219 @@ -1256,8 +1342,39 @@ static void __init map_lowmem(void)
4220 map.pfn = __phys_to_pfn(start);
4221 map.virtual = __phys_to_virt(start);
4222 map.length = end - start;
4223 - map.type = MT_MEMORY;
4224
4225 +#ifdef CONFIG_PAX_KERNEXEC
4226 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4227 + struct map_desc kernel;
4228 + struct map_desc initmap;
4229 +
4230 + /* when freeing initmem we will make this RW */
4231 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4232 + initmap.virtual = (unsigned long)__init_begin;
4233 + initmap.length = _sdata - __init_begin;
4234 + initmap.type = MT_MEMORY_RWX;
4235 + create_mapping(&initmap);
4236 +
4237 + /* when freeing initmem we will make this RX */
4238 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4239 + kernel.virtual = (unsigned long)_stext;
4240 + kernel.length = __init_begin - _stext;
4241 + kernel.type = MT_MEMORY_RWX;
4242 + create_mapping(&kernel);
4243 +
4244 + if (map.virtual < (unsigned long)_stext) {
4245 + map.length = (unsigned long)_stext - map.virtual;
4246 + map.type = MT_MEMORY_RWX;
4247 + create_mapping(&map);
4248 + }
4249 +
4250 + map.pfn = __phys_to_pfn(__pa(_sdata));
4251 + map.virtual = (unsigned long)_sdata;
4252 + map.length = end - __pa(_sdata);
4253 + }
4254 +#endif
4255 +
4256 + map.type = MT_MEMORY_RW;
4257 create_mapping(&map);
4258 }
4259 }
4260 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4261 index 78f520b..31f0cb6 100644
4262 --- a/arch/arm/mm/proc-v7-2level.S
4263 +++ b/arch/arm/mm/proc-v7-2level.S
4264 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4265 tst r1, #L_PTE_XN
4266 orrne r3, r3, #PTE_EXT_XN
4267
4268 + tst r1, #L_PTE_PXN
4269 + orrne r3, r3, #PTE_EXT_PXN
4270 +
4271 tst r1, #L_PTE_YOUNG
4272 tstne r1, #L_PTE_VALID
4273 #ifndef CONFIG_CPU_USE_DOMAINS
4274 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4275 index a5bc92d..0bb4730 100644
4276 --- a/arch/arm/plat-omap/sram.c
4277 +++ b/arch/arm/plat-omap/sram.c
4278 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4279 * Looks like we need to preserve some bootloader code at the
4280 * beginning of SRAM for jumping to flash for reboot to work...
4281 */
4282 + pax_open_kernel();
4283 memset_io(omap_sram_base + omap_sram_skip, 0,
4284 omap_sram_size - omap_sram_skip);
4285 + pax_close_kernel();
4286 }
4287 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4288 index 1141782..0959d64 100644
4289 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4290 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4291 @@ -48,7 +48,7 @@ struct samsung_dma_ops {
4292 int (*started)(unsigned ch);
4293 int (*flush)(unsigned ch);
4294 int (*stop)(unsigned ch);
4295 -};
4296 +} __no_const;
4297
4298 extern void *samsung_dmadev_get_ops(void);
4299 extern void *s3c_dma_get_ops(void);
4300 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4301 index f4726dc..39ed646 100644
4302 --- a/arch/arm64/kernel/debug-monitors.c
4303 +++ b/arch/arm64/kernel/debug-monitors.c
4304 @@ -149,7 +149,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4305 return NOTIFY_OK;
4306 }
4307
4308 -static struct notifier_block __cpuinitdata os_lock_nb = {
4309 +static struct notifier_block os_lock_nb = {
4310 .notifier_call = os_lock_notify,
4311 };
4312
4313 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4314 index 5ab825c..96aaec8 100644
4315 --- a/arch/arm64/kernel/hw_breakpoint.c
4316 +++ b/arch/arm64/kernel/hw_breakpoint.c
4317 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4318 return NOTIFY_OK;
4319 }
4320
4321 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4322 +static struct notifier_block hw_breakpoint_reset_nb = {
4323 .notifier_call = hw_breakpoint_reset_notify,
4324 };
4325
4326 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4327 index c3a58a1..78fbf54 100644
4328 --- a/arch/avr32/include/asm/cache.h
4329 +++ b/arch/avr32/include/asm/cache.h
4330 @@ -1,8 +1,10 @@
4331 #ifndef __ASM_AVR32_CACHE_H
4332 #define __ASM_AVR32_CACHE_H
4333
4334 +#include <linux/const.h>
4335 +
4336 #define L1_CACHE_SHIFT 5
4337 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4338 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4339
4340 /*
4341 * Memory returned by kmalloc() may be used for DMA, so we must make
4342 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4343 index d232888..87c8df1 100644
4344 --- a/arch/avr32/include/asm/elf.h
4345 +++ b/arch/avr32/include/asm/elf.h
4346 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4347 the loader. We need to make sure that it is out of the way of the program
4348 that it will "exec", and that there is sufficient room for the brk. */
4349
4350 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4351 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4352
4353 +#ifdef CONFIG_PAX_ASLR
4354 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4355 +
4356 +#define PAX_DELTA_MMAP_LEN 15
4357 +#define PAX_DELTA_STACK_LEN 15
4358 +#endif
4359
4360 /* This yields a mask that user programs can use to figure out what
4361 instruction set this CPU supports. This could be done in user space,
4362 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4363 index 479330b..53717a8 100644
4364 --- a/arch/avr32/include/asm/kmap_types.h
4365 +++ b/arch/avr32/include/asm/kmap_types.h
4366 @@ -2,9 +2,9 @@
4367 #define __ASM_AVR32_KMAP_TYPES_H
4368
4369 #ifdef CONFIG_DEBUG_HIGHMEM
4370 -# define KM_TYPE_NR 29
4371 +# define KM_TYPE_NR 30
4372 #else
4373 -# define KM_TYPE_NR 14
4374 +# define KM_TYPE_NR 15
4375 #endif
4376
4377 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4378 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4379 index b2f2d2d..d1c85cb 100644
4380 --- a/arch/avr32/mm/fault.c
4381 +++ b/arch/avr32/mm/fault.c
4382 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4383
4384 int exception_trace = 1;
4385
4386 +#ifdef CONFIG_PAX_PAGEEXEC
4387 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4388 +{
4389 + unsigned long i;
4390 +
4391 + printk(KERN_ERR "PAX: bytes at PC: ");
4392 + for (i = 0; i < 20; i++) {
4393 + unsigned char c;
4394 + if (get_user(c, (unsigned char *)pc+i))
4395 + printk(KERN_CONT "???????? ");
4396 + else
4397 + printk(KERN_CONT "%02x ", c);
4398 + }
4399 + printk("\n");
4400 +}
4401 +#endif
4402 +
4403 /*
4404 * This routine handles page faults. It determines the address and the
4405 * problem, and then passes it off to one of the appropriate routines.
4406 @@ -174,6 +191,16 @@ bad_area:
4407 up_read(&mm->mmap_sem);
4408
4409 if (user_mode(regs)) {
4410 +
4411 +#ifdef CONFIG_PAX_PAGEEXEC
4412 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4413 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4414 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4415 + do_group_exit(SIGKILL);
4416 + }
4417 + }
4418 +#endif
4419 +
4420 if (exception_trace && printk_ratelimit())
4421 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4422 "sp %08lx ecr %lu\n",
4423 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4424 index 568885a..f8008df 100644
4425 --- a/arch/blackfin/include/asm/cache.h
4426 +++ b/arch/blackfin/include/asm/cache.h
4427 @@ -7,6 +7,7 @@
4428 #ifndef __ARCH_BLACKFIN_CACHE_H
4429 #define __ARCH_BLACKFIN_CACHE_H
4430
4431 +#include <linux/const.h>
4432 #include <linux/linkage.h> /* for asmlinkage */
4433
4434 /*
4435 @@ -14,7 +15,7 @@
4436 * Blackfin loads 32 bytes for cache
4437 */
4438 #define L1_CACHE_SHIFT 5
4439 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4440 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4441 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4442
4443 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4444 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4445 index aea2718..3639a60 100644
4446 --- a/arch/cris/include/arch-v10/arch/cache.h
4447 +++ b/arch/cris/include/arch-v10/arch/cache.h
4448 @@ -1,8 +1,9 @@
4449 #ifndef _ASM_ARCH_CACHE_H
4450 #define _ASM_ARCH_CACHE_H
4451
4452 +#include <linux/const.h>
4453 /* Etrax 100LX have 32-byte cache-lines. */
4454 -#define L1_CACHE_BYTES 32
4455 #define L1_CACHE_SHIFT 5
4456 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4457
4458 #endif /* _ASM_ARCH_CACHE_H */
4459 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4460 index 7caf25d..ee65ac5 100644
4461 --- a/arch/cris/include/arch-v32/arch/cache.h
4462 +++ b/arch/cris/include/arch-v32/arch/cache.h
4463 @@ -1,11 +1,12 @@
4464 #ifndef _ASM_CRIS_ARCH_CACHE_H
4465 #define _ASM_CRIS_ARCH_CACHE_H
4466
4467 +#include <linux/const.h>
4468 #include <arch/hwregs/dma.h>
4469
4470 /* A cache-line is 32 bytes. */
4471 -#define L1_CACHE_BYTES 32
4472 #define L1_CACHE_SHIFT 5
4473 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4474
4475 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4476
4477 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4478 index b86329d..6709906 100644
4479 --- a/arch/frv/include/asm/atomic.h
4480 +++ b/arch/frv/include/asm/atomic.h
4481 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4482 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4483 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4484
4485 +#define atomic64_read_unchecked(v) atomic64_read(v)
4486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4494 +
4495 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4496 {
4497 int c, old;
4498 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4499 index 2797163..c2a401d 100644
4500 --- a/arch/frv/include/asm/cache.h
4501 +++ b/arch/frv/include/asm/cache.h
4502 @@ -12,10 +12,11 @@
4503 #ifndef __ASM_CACHE_H
4504 #define __ASM_CACHE_H
4505
4506 +#include <linux/const.h>
4507
4508 /* bytes per L1 cache line */
4509 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4510 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4511 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4512
4513 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4514 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4515 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4516 index 43901f2..0d8b865 100644
4517 --- a/arch/frv/include/asm/kmap_types.h
4518 +++ b/arch/frv/include/asm/kmap_types.h
4519 @@ -2,6 +2,6 @@
4520 #ifndef _ASM_KMAP_TYPES_H
4521 #define _ASM_KMAP_TYPES_H
4522
4523 -#define KM_TYPE_NR 17
4524 +#define KM_TYPE_NR 18
4525
4526 #endif
4527 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4528 index 836f147..4cf23f5 100644
4529 --- a/arch/frv/mm/elf-fdpic.c
4530 +++ b/arch/frv/mm/elf-fdpic.c
4531 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4532 {
4533 struct vm_area_struct *vma;
4534 struct vm_unmapped_area_info info;
4535 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4536
4537 if (len > TASK_SIZE)
4538 return -ENOMEM;
4539 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4540 if (addr) {
4541 addr = PAGE_ALIGN(addr);
4542 vma = find_vma(current->mm, addr);
4543 - if (TASK_SIZE - len >= addr &&
4544 - (!vma || addr + len <= vma->vm_start))
4545 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4546 goto success;
4547 }
4548
4549 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4550 info.high_limit = (current->mm->start_stack - 0x00200000);
4551 info.align_mask = 0;
4552 info.align_offset = 0;
4553 + info.threadstack_offset = offset;
4554 addr = vm_unmapped_area(&info);
4555 if (!(addr & ~PAGE_MASK))
4556 goto success;
4557 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4558 index f4ca594..adc72fd6 100644
4559 --- a/arch/hexagon/include/asm/cache.h
4560 +++ b/arch/hexagon/include/asm/cache.h
4561 @@ -21,9 +21,11 @@
4562 #ifndef __ASM_CACHE_H
4563 #define __ASM_CACHE_H
4564
4565 +#include <linux/const.h>
4566 +
4567 /* Bytes per L1 cache line */
4568 -#define L1_CACHE_SHIFT (5)
4569 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4570 +#define L1_CACHE_SHIFT 5
4571 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4572
4573 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4574 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4575 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4576 index 6e6fe18..a6ae668 100644
4577 --- a/arch/ia64/include/asm/atomic.h
4578 +++ b/arch/ia64/include/asm/atomic.h
4579 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4580 #define atomic64_inc(v) atomic64_add(1, (v))
4581 #define atomic64_dec(v) atomic64_sub(1, (v))
4582
4583 +#define atomic64_read_unchecked(v) atomic64_read(v)
4584 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4585 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4586 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4587 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4588 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4589 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4590 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4591 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4592 +
4593 /* Atomic operations are already serializing */
4594 #define smp_mb__before_atomic_dec() barrier()
4595 #define smp_mb__after_atomic_dec() barrier()
4596 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4597 index 988254a..e1ee885 100644
4598 --- a/arch/ia64/include/asm/cache.h
4599 +++ b/arch/ia64/include/asm/cache.h
4600 @@ -1,6 +1,7 @@
4601 #ifndef _ASM_IA64_CACHE_H
4602 #define _ASM_IA64_CACHE_H
4603
4604 +#include <linux/const.h>
4605
4606 /*
4607 * Copyright (C) 1998-2000 Hewlett-Packard Co
4608 @@ -9,7 +10,7 @@
4609
4610 /* Bytes per L1 (data) cache line. */
4611 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4612 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4613 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4614
4615 #ifdef CONFIG_SMP
4616 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4617 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4618 index 5a83c5c..4d7f553 100644
4619 --- a/arch/ia64/include/asm/elf.h
4620 +++ b/arch/ia64/include/asm/elf.h
4621 @@ -42,6 +42,13 @@
4622 */
4623 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4624
4625 +#ifdef CONFIG_PAX_ASLR
4626 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4627 +
4628 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4629 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4630 +#endif
4631 +
4632 #define PT_IA_64_UNWIND 0x70000001
4633
4634 /* IA-64 relocations: */
4635 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4636 index 96a8d92..617a1cf 100644
4637 --- a/arch/ia64/include/asm/pgalloc.h
4638 +++ b/arch/ia64/include/asm/pgalloc.h
4639 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4640 pgd_val(*pgd_entry) = __pa(pud);
4641 }
4642
4643 +static inline void
4644 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4645 +{
4646 + pgd_populate(mm, pgd_entry, pud);
4647 +}
4648 +
4649 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4650 {
4651 return quicklist_alloc(0, GFP_KERNEL, NULL);
4652 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4653 pud_val(*pud_entry) = __pa(pmd);
4654 }
4655
4656 +static inline void
4657 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4658 +{
4659 + pud_populate(mm, pud_entry, pmd);
4660 +}
4661 +
4662 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4663 {
4664 return quicklist_alloc(0, GFP_KERNEL, NULL);
4665 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4666 index 815810c..d60bd4c 100644
4667 --- a/arch/ia64/include/asm/pgtable.h
4668 +++ b/arch/ia64/include/asm/pgtable.h
4669 @@ -12,7 +12,7 @@
4670 * David Mosberger-Tang <davidm@hpl.hp.com>
4671 */
4672
4673 -
4674 +#include <linux/const.h>
4675 #include <asm/mman.h>
4676 #include <asm/page.h>
4677 #include <asm/processor.h>
4678 @@ -142,6 +142,17 @@
4679 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4680 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4681 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4682 +
4683 +#ifdef CONFIG_PAX_PAGEEXEC
4684 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4685 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4686 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4687 +#else
4688 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4689 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4690 +# define PAGE_COPY_NOEXEC PAGE_COPY
4691 +#endif
4692 +
4693 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4694 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4695 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4696 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4697 index 54ff557..70c88b7 100644
4698 --- a/arch/ia64/include/asm/spinlock.h
4699 +++ b/arch/ia64/include/asm/spinlock.h
4700 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4701 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4702
4703 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4704 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4705 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4706 }
4707
4708 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4709 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4710 index 449c8c0..18965fb 100644
4711 --- a/arch/ia64/include/asm/uaccess.h
4712 +++ b/arch/ia64/include/asm/uaccess.h
4713 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4714 static inline unsigned long
4715 __copy_to_user (void __user *to, const void *from, unsigned long count)
4716 {
4717 + if (count > INT_MAX)
4718 + return count;
4719 +
4720 + if (!__builtin_constant_p(count))
4721 + check_object_size(from, count, true);
4722 +
4723 return __copy_user(to, (__force void __user *) from, count);
4724 }
4725
4726 static inline unsigned long
4727 __copy_from_user (void *to, const void __user *from, unsigned long count)
4728 {
4729 + if (count > INT_MAX)
4730 + return count;
4731 +
4732 + if (!__builtin_constant_p(count))
4733 + check_object_size(to, count, false);
4734 +
4735 return __copy_user((__force void __user *) to, from, count);
4736 }
4737
4738 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4739 ({ \
4740 void __user *__cu_to = (to); \
4741 const void *__cu_from = (from); \
4742 - long __cu_len = (n); \
4743 + unsigned long __cu_len = (n); \
4744 \
4745 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4746 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4747 + if (!__builtin_constant_p(n)) \
4748 + check_object_size(__cu_from, __cu_len, true); \
4749 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4750 + } \
4751 __cu_len; \
4752 })
4753
4754 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4755 ({ \
4756 void *__cu_to = (to); \
4757 const void __user *__cu_from = (from); \
4758 - long __cu_len = (n); \
4759 + unsigned long __cu_len = (n); \
4760 \
4761 __chk_user_ptr(__cu_from); \
4762 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4763 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4764 + if (!__builtin_constant_p(n)) \
4765 + check_object_size(__cu_to, __cu_len, false); \
4766 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4767 + } \
4768 __cu_len; \
4769 })
4770
4771 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4772 index 2d67317..07d8bfa 100644
4773 --- a/arch/ia64/kernel/err_inject.c
4774 +++ b/arch/ia64/kernel/err_inject.c
4775 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4776 return NOTIFY_OK;
4777 }
4778
4779 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4780 +static struct notifier_block err_inject_cpu_notifier =
4781 {
4782 .notifier_call = err_inject_cpu_callback,
4783 };
4784 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4785 index d7396db..b33e873 100644
4786 --- a/arch/ia64/kernel/mca.c
4787 +++ b/arch/ia64/kernel/mca.c
4788 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4789 return NOTIFY_OK;
4790 }
4791
4792 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4793 +static struct notifier_block mca_cpu_notifier = {
4794 .notifier_call = mca_cpu_callback
4795 };
4796
4797 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4798 index 24603be..948052d 100644
4799 --- a/arch/ia64/kernel/module.c
4800 +++ b/arch/ia64/kernel/module.c
4801 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4802 void
4803 module_free (struct module *mod, void *module_region)
4804 {
4805 - if (mod && mod->arch.init_unw_table &&
4806 - module_region == mod->module_init) {
4807 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4808 unw_remove_unwind_table(mod->arch.init_unw_table);
4809 mod->arch.init_unw_table = NULL;
4810 }
4811 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4812 }
4813
4814 static inline int
4815 +in_init_rx (const struct module *mod, uint64_t addr)
4816 +{
4817 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4818 +}
4819 +
4820 +static inline int
4821 +in_init_rw (const struct module *mod, uint64_t addr)
4822 +{
4823 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4824 +}
4825 +
4826 +static inline int
4827 in_init (const struct module *mod, uint64_t addr)
4828 {
4829 - return addr - (uint64_t) mod->module_init < mod->init_size;
4830 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4831 +}
4832 +
4833 +static inline int
4834 +in_core_rx (const struct module *mod, uint64_t addr)
4835 +{
4836 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4837 +}
4838 +
4839 +static inline int
4840 +in_core_rw (const struct module *mod, uint64_t addr)
4841 +{
4842 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4843 }
4844
4845 static inline int
4846 in_core (const struct module *mod, uint64_t addr)
4847 {
4848 - return addr - (uint64_t) mod->module_core < mod->core_size;
4849 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4850 }
4851
4852 static inline int
4853 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4854 break;
4855
4856 case RV_BDREL:
4857 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4858 + if (in_init_rx(mod, val))
4859 + val -= (uint64_t) mod->module_init_rx;
4860 + else if (in_init_rw(mod, val))
4861 + val -= (uint64_t) mod->module_init_rw;
4862 + else if (in_core_rx(mod, val))
4863 + val -= (uint64_t) mod->module_core_rx;
4864 + else if (in_core_rw(mod, val))
4865 + val -= (uint64_t) mod->module_core_rw;
4866 break;
4867
4868 case RV_LTV:
4869 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4870 * addresses have been selected...
4871 */
4872 uint64_t gp;
4873 - if (mod->core_size > MAX_LTOFF)
4874 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4875 /*
4876 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4877 * at the end of the module.
4878 */
4879 - gp = mod->core_size - MAX_LTOFF / 2;
4880 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4881 else
4882 - gp = mod->core_size / 2;
4883 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4884 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4885 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4886 mod->arch.gp = gp;
4887 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4888 }
4889 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4890 index 79521d5..43dddff 100644
4891 --- a/arch/ia64/kernel/palinfo.c
4892 +++ b/arch/ia64/kernel/palinfo.c
4893 @@ -1006,7 +1006,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4894 return NOTIFY_OK;
4895 }
4896
4897 -static struct notifier_block __refdata palinfo_cpu_notifier =
4898 +static struct notifier_block palinfo_cpu_notifier =
4899 {
4900 .notifier_call = palinfo_cpu_callback,
4901 .priority = 0,
4902 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4903 index aa527d7..f237752 100644
4904 --- a/arch/ia64/kernel/salinfo.c
4905 +++ b/arch/ia64/kernel/salinfo.c
4906 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4907 return NOTIFY_OK;
4908 }
4909
4910 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
4911 +static struct notifier_block salinfo_cpu_notifier =
4912 {
4913 .notifier_call = salinfo_cpu_callback,
4914 .priority = 0,
4915 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4916 index 41e33f8..65180b2 100644
4917 --- a/arch/ia64/kernel/sys_ia64.c
4918 +++ b/arch/ia64/kernel/sys_ia64.c
4919 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4920 unsigned long align_mask = 0;
4921 struct mm_struct *mm = current->mm;
4922 struct vm_unmapped_area_info info;
4923 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4924
4925 if (len > RGN_MAP_LIMIT)
4926 return -ENOMEM;
4927 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4928 if (REGION_NUMBER(addr) == RGN_HPAGE)
4929 addr = 0;
4930 #endif
4931 +
4932 +#ifdef CONFIG_PAX_RANDMMAP
4933 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4934 + addr = mm->free_area_cache;
4935 + else
4936 +#endif
4937 +
4938 if (!addr)
4939 addr = TASK_UNMAPPED_BASE;
4940
4941 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4942 info.high_limit = TASK_SIZE;
4943 info.align_mask = align_mask;
4944 info.align_offset = 0;
4945 + info.threadstack_offset = offset;
4946 return vm_unmapped_area(&info);
4947 }
4948
4949 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
4950 index dc00b2c..cce53c2 100644
4951 --- a/arch/ia64/kernel/topology.c
4952 +++ b/arch/ia64/kernel/topology.c
4953 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
4954 return NOTIFY_OK;
4955 }
4956
4957 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
4958 +static struct notifier_block cache_cpu_notifier =
4959 {
4960 .notifier_call = cache_cpu_callback
4961 };
4962 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
4963 index 0ccb28f..8992469 100644
4964 --- a/arch/ia64/kernel/vmlinux.lds.S
4965 +++ b/arch/ia64/kernel/vmlinux.lds.S
4966 @@ -198,7 +198,7 @@ SECTIONS {
4967 /* Per-cpu data: */
4968 . = ALIGN(PERCPU_PAGE_SIZE);
4969 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
4970 - __phys_per_cpu_start = __per_cpu_load;
4971 + __phys_per_cpu_start = per_cpu_load;
4972 /*
4973 * ensure percpu data fits
4974 * into percpu page size
4975 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
4976 index 6cf0341..d352594 100644
4977 --- a/arch/ia64/mm/fault.c
4978 +++ b/arch/ia64/mm/fault.c
4979 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
4980 return pte_present(pte);
4981 }
4982
4983 +#ifdef CONFIG_PAX_PAGEEXEC
4984 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4985 +{
4986 + unsigned long i;
4987 +
4988 + printk(KERN_ERR "PAX: bytes at PC: ");
4989 + for (i = 0; i < 8; i++) {
4990 + unsigned int c;
4991 + if (get_user(c, (unsigned int *)pc+i))
4992 + printk(KERN_CONT "???????? ");
4993 + else
4994 + printk(KERN_CONT "%08x ", c);
4995 + }
4996 + printk("\n");
4997 +}
4998 +#endif
4999 +
5000 # define VM_READ_BIT 0
5001 # define VM_WRITE_BIT 1
5002 # define VM_EXEC_BIT 2
5003 @@ -149,8 +166,21 @@ retry:
5004 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5005 goto bad_area;
5006
5007 - if ((vma->vm_flags & mask) != mask)
5008 + if ((vma->vm_flags & mask) != mask) {
5009 +
5010 +#ifdef CONFIG_PAX_PAGEEXEC
5011 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5012 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5013 + goto bad_area;
5014 +
5015 + up_read(&mm->mmap_sem);
5016 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5017 + do_group_exit(SIGKILL);
5018 + }
5019 +#endif
5020 +
5021 goto bad_area;
5022 + }
5023
5024 /*
5025 * If for any reason at all we couldn't handle the fault, make
5026 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5027 index 76069c1..c2aa816 100644
5028 --- a/arch/ia64/mm/hugetlbpage.c
5029 +++ b/arch/ia64/mm/hugetlbpage.c
5030 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5031 unsigned long pgoff, unsigned long flags)
5032 {
5033 struct vm_unmapped_area_info info;
5034 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5035
5036 if (len > RGN_MAP_LIMIT)
5037 return -ENOMEM;
5038 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5039 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5040 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5041 info.align_offset = 0;
5042 + info.threadstack_offset = offset;
5043 return vm_unmapped_area(&info);
5044 }
5045
5046 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5047 index 20bc967..a26993e 100644
5048 --- a/arch/ia64/mm/init.c
5049 +++ b/arch/ia64/mm/init.c
5050 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5051 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5052 vma->vm_end = vma->vm_start + PAGE_SIZE;
5053 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5054 +
5055 +#ifdef CONFIG_PAX_PAGEEXEC
5056 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5057 + vma->vm_flags &= ~VM_EXEC;
5058 +
5059 +#ifdef CONFIG_PAX_MPROTECT
5060 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5061 + vma->vm_flags &= ~VM_MAYEXEC;
5062 +#endif
5063 +
5064 + }
5065 +#endif
5066 +
5067 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5068 down_write(&current->mm->mmap_sem);
5069 if (insert_vm_struct(current->mm, vma)) {
5070 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5071 index 40b3ee9..8c2c112 100644
5072 --- a/arch/m32r/include/asm/cache.h
5073 +++ b/arch/m32r/include/asm/cache.h
5074 @@ -1,8 +1,10 @@
5075 #ifndef _ASM_M32R_CACHE_H
5076 #define _ASM_M32R_CACHE_H
5077
5078 +#include <linux/const.h>
5079 +
5080 /* L1 cache line size */
5081 #define L1_CACHE_SHIFT 4
5082 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5083 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5084
5085 #endif /* _ASM_M32R_CACHE_H */
5086 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5087 index 82abd15..d95ae5d 100644
5088 --- a/arch/m32r/lib/usercopy.c
5089 +++ b/arch/m32r/lib/usercopy.c
5090 @@ -14,6 +14,9 @@
5091 unsigned long
5092 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5093 {
5094 + if ((long)n < 0)
5095 + return n;
5096 +
5097 prefetch(from);
5098 if (access_ok(VERIFY_WRITE, to, n))
5099 __copy_user(to,from,n);
5100 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5101 unsigned long
5102 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5103 {
5104 + if ((long)n < 0)
5105 + return n;
5106 +
5107 prefetchw(to);
5108 if (access_ok(VERIFY_READ, from, n))
5109 __copy_user_zeroing(to,from,n);
5110 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5111 index 0395c51..5f26031 100644
5112 --- a/arch/m68k/include/asm/cache.h
5113 +++ b/arch/m68k/include/asm/cache.h
5114 @@ -4,9 +4,11 @@
5115 #ifndef __ARCH_M68K_CACHE_H
5116 #define __ARCH_M68K_CACHE_H
5117
5118 +#include <linux/const.h>
5119 +
5120 /* bytes per L1 cache line */
5121 #define L1_CACHE_SHIFT 4
5122 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5123 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5124
5125 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5126
5127 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5128 index 3c52fa6..11b2ad8 100644
5129 --- a/arch/metag/mm/hugetlbpage.c
5130 +++ b/arch/metag/mm/hugetlbpage.c
5131 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5132 info.high_limit = TASK_SIZE;
5133 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5134 info.align_offset = 0;
5135 + info.threadstack_offset = 0;
5136 return vm_unmapped_area(&info);
5137 }
5138
5139 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5140 index 4efe96a..60e8699 100644
5141 --- a/arch/microblaze/include/asm/cache.h
5142 +++ b/arch/microblaze/include/asm/cache.h
5143 @@ -13,11 +13,12 @@
5144 #ifndef _ASM_MICROBLAZE_CACHE_H
5145 #define _ASM_MICROBLAZE_CACHE_H
5146
5147 +#include <linux/const.h>
5148 #include <asm/registers.h>
5149
5150 #define L1_CACHE_SHIFT 5
5151 /* word-granular cache in microblaze */
5152 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5153 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5154
5155 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5156
5157 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5158 index 08b6079..eb272cf 100644
5159 --- a/arch/mips/include/asm/atomic.h
5160 +++ b/arch/mips/include/asm/atomic.h
5161 @@ -21,6 +21,10 @@
5162 #include <asm/cmpxchg.h>
5163 #include <asm/war.h>
5164
5165 +#ifdef CONFIG_GENERIC_ATOMIC64
5166 +#include <asm-generic/atomic64.h>
5167 +#endif
5168 +
5169 #define ATOMIC_INIT(i) { (i) }
5170
5171 /*
5172 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5173 */
5174 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5175
5176 +#define atomic64_read_unchecked(v) atomic64_read(v)
5177 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5178 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5179 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5180 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5181 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5182 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5183 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5184 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5185 +
5186 #endif /* CONFIG_64BIT */
5187
5188 /*
5189 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5190 index b4db69f..8f3b093 100644
5191 --- a/arch/mips/include/asm/cache.h
5192 +++ b/arch/mips/include/asm/cache.h
5193 @@ -9,10 +9,11 @@
5194 #ifndef _ASM_CACHE_H
5195 #define _ASM_CACHE_H
5196
5197 +#include <linux/const.h>
5198 #include <kmalloc.h>
5199
5200 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5201 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5202 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5203
5204 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5205 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5206 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5207 index cf3ae24..238d22f 100644
5208 --- a/arch/mips/include/asm/elf.h
5209 +++ b/arch/mips/include/asm/elf.h
5210 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5211 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5212 #endif
5213
5214 +#ifdef CONFIG_PAX_ASLR
5215 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5216 +
5217 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5218 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5219 +#endif
5220 +
5221 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5222 struct linux_binprm;
5223 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5224 int uses_interp);
5225
5226 -struct mm_struct;
5227 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5228 -#define arch_randomize_brk arch_randomize_brk
5229 -
5230 #endif /* _ASM_ELF_H */
5231 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5232 index c1f6afa..38cc6e9 100644
5233 --- a/arch/mips/include/asm/exec.h
5234 +++ b/arch/mips/include/asm/exec.h
5235 @@ -12,6 +12,6 @@
5236 #ifndef _ASM_EXEC_H
5237 #define _ASM_EXEC_H
5238
5239 -extern unsigned long arch_align_stack(unsigned long sp);
5240 +#define arch_align_stack(x) ((x) & ~0xfUL)
5241
5242 #endif /* _ASM_EXEC_H */
5243 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5244 index eab99e5..607c98e 100644
5245 --- a/arch/mips/include/asm/page.h
5246 +++ b/arch/mips/include/asm/page.h
5247 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5248 #ifdef CONFIG_CPU_MIPS32
5249 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5250 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5251 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5252 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5253 #else
5254 typedef struct { unsigned long long pte; } pte_t;
5255 #define pte_val(x) ((x).pte)
5256 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5257 index 881d18b..cea38bc 100644
5258 --- a/arch/mips/include/asm/pgalloc.h
5259 +++ b/arch/mips/include/asm/pgalloc.h
5260 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5261 {
5262 set_pud(pud, __pud((unsigned long)pmd));
5263 }
5264 +
5265 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5266 +{
5267 + pud_populate(mm, pud, pmd);
5268 +}
5269 #endif
5270
5271 /*
5272 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5273 index 178f792..8ebc510 100644
5274 --- a/arch/mips/include/asm/thread_info.h
5275 +++ b/arch/mips/include/asm/thread_info.h
5276 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5277 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5278 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5279 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5280 +/* li takes a 32bit immediate */
5281 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5282 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5283
5284 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5285 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5286 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5287 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5288 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5289 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5290 +
5291 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5292
5293 /* work to do in syscall_trace_leave() */
5294 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5295 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5296
5297 /* work to do on interrupt/exception return */
5298 #define _TIF_WORK_MASK \
5299 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5300 /* work to do on any return to u-space */
5301 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5302 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5303
5304 #endif /* __KERNEL__ */
5305
5306 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5307 index e06f777..3244284 100644
5308 --- a/arch/mips/kernel/binfmt_elfn32.c
5309 +++ b/arch/mips/kernel/binfmt_elfn32.c
5310 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5311 #undef ELF_ET_DYN_BASE
5312 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5313
5314 +#ifdef CONFIG_PAX_ASLR
5315 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5316 +
5317 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5318 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5319 +#endif
5320 +
5321 #include <asm/processor.h>
5322 #include <linux/module.h>
5323 #include <linux/elfcore.h>
5324 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5325 index 556a435..b4fd2e3 100644
5326 --- a/arch/mips/kernel/binfmt_elfo32.c
5327 +++ b/arch/mips/kernel/binfmt_elfo32.c
5328 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5329 #undef ELF_ET_DYN_BASE
5330 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5331
5332 +#ifdef CONFIG_PAX_ASLR
5333 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5334 +
5335 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5336 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5337 +#endif
5338 +
5339 #include <asm/processor.h>
5340
5341 /*
5342 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5343 index 3be4405..a799827 100644
5344 --- a/arch/mips/kernel/process.c
5345 +++ b/arch/mips/kernel/process.c
5346 @@ -461,15 +461,3 @@ unsigned long get_wchan(struct task_struct *task)
5347 out:
5348 return pc;
5349 }
5350 -
5351 -/*
5352 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5353 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5354 - */
5355 -unsigned long arch_align_stack(unsigned long sp)
5356 -{
5357 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5358 - sp -= get_random_int() & ~PAGE_MASK;
5359 -
5360 - return sp & ALMASK;
5361 -}
5362 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5363 index 9c6299c..2fb4c22 100644
5364 --- a/arch/mips/kernel/ptrace.c
5365 +++ b/arch/mips/kernel/ptrace.c
5366 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5367 return arch;
5368 }
5369
5370 +#ifdef CONFIG_GRKERNSEC_SETXID
5371 +extern void gr_delayed_cred_worker(void);
5372 +#endif
5373 +
5374 /*
5375 * Notification of system call entry/exit
5376 * - triggered by current->work.syscall_trace
5377 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5378 /* do the secure computing check first */
5379 secure_computing_strict(regs->regs[2]);
5380
5381 +#ifdef CONFIG_GRKERNSEC_SETXID
5382 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5383 + gr_delayed_cred_worker();
5384 +#endif
5385 +
5386 if (!(current->ptrace & PT_PTRACED))
5387 goto out;
5388
5389 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5390 index 9ea2964..c4329c3 100644
5391 --- a/arch/mips/kernel/scall32-o32.S
5392 +++ b/arch/mips/kernel/scall32-o32.S
5393 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5394
5395 stack_done:
5396 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5397 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5398 + li t1, _TIF_SYSCALL_WORK
5399 and t0, t1
5400 bnez t0, syscall_trace_entry # -> yes
5401
5402 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5403 index 36cfd40..b1436e0 100644
5404 --- a/arch/mips/kernel/scall64-64.S
5405 +++ b/arch/mips/kernel/scall64-64.S
5406 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5407
5408 sd a3, PT_R26(sp) # save a3 for syscall restarting
5409
5410 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5411 + li t1, _TIF_SYSCALL_WORK
5412 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5413 and t0, t1, t0
5414 bnez t0, syscall_trace_entry
5415 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5416 index 693d60b..ae0ba75 100644
5417 --- a/arch/mips/kernel/scall64-n32.S
5418 +++ b/arch/mips/kernel/scall64-n32.S
5419 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5420
5421 sd a3, PT_R26(sp) # save a3 for syscall restarting
5422
5423 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5424 + li t1, _TIF_SYSCALL_WORK
5425 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5426 and t0, t1, t0
5427 bnez t0, n32_syscall_trace_entry
5428 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5429 index af8887f..611ccb6 100644
5430 --- a/arch/mips/kernel/scall64-o32.S
5431 +++ b/arch/mips/kernel/scall64-o32.S
5432 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5433 PTR 4b, bad_stack
5434 .previous
5435
5436 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5437 + li t1, _TIF_SYSCALL_WORK
5438 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5439 and t0, t1, t0
5440 bnez t0, trace_a_syscall
5441 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5442 index 0fead53..a2c0fb5 100644
5443 --- a/arch/mips/mm/fault.c
5444 +++ b/arch/mips/mm/fault.c
5445 @@ -27,6 +27,23 @@
5446 #include <asm/highmem.h> /* For VMALLOC_END */
5447 #include <linux/kdebug.h>
5448
5449 +#ifdef CONFIG_PAX_PAGEEXEC
5450 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5451 +{
5452 + unsigned long i;
5453 +
5454 + printk(KERN_ERR "PAX: bytes at PC: ");
5455 + for (i = 0; i < 5; i++) {
5456 + unsigned int c;
5457 + if (get_user(c, (unsigned int *)pc+i))
5458 + printk(KERN_CONT "???????? ");
5459 + else
5460 + printk(KERN_CONT "%08x ", c);
5461 + }
5462 + printk("\n");
5463 +}
5464 +#endif
5465 +
5466 /*
5467 * This routine handles page faults. It determines the address,
5468 * and the problem, and then passes it off to one of the appropriate
5469 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5470 index 7e5fe27..9656513 100644
5471 --- a/arch/mips/mm/mmap.c
5472 +++ b/arch/mips/mm/mmap.c
5473 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5474 struct vm_area_struct *vma;
5475 unsigned long addr = addr0;
5476 int do_color_align;
5477 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5478 struct vm_unmapped_area_info info;
5479
5480 if (unlikely(len > TASK_SIZE))
5481 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5482 do_color_align = 1;
5483
5484 /* requesting a specific address */
5485 +
5486 +#ifdef CONFIG_PAX_RANDMMAP
5487 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5488 +#endif
5489 +
5490 if (addr) {
5491 if (do_color_align)
5492 addr = COLOUR_ALIGN(addr, pgoff);
5493 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5494 addr = PAGE_ALIGN(addr);
5495
5496 vma = find_vma(mm, addr);
5497 - if (TASK_SIZE - len >= addr &&
5498 - (!vma || addr + len <= vma->vm_start))
5499 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5500 return addr;
5501 }
5502
5503 info.length = len;
5504 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
5505 info.align_offset = pgoff << PAGE_SHIFT;
5506 + info.threadstack_offset = offset;
5507
5508 if (dir == DOWN) {
5509 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
5510 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5511 {
5512 unsigned long random_factor = 0UL;
5513
5514 +#ifdef CONFIG_PAX_RANDMMAP
5515 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5516 +#endif
5517 +
5518 if (current->flags & PF_RANDOMIZE) {
5519 random_factor = get_random_int();
5520 random_factor = random_factor << PAGE_SHIFT;
5521 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5522
5523 if (mmap_is_legacy()) {
5524 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5525 +
5526 +#ifdef CONFIG_PAX_RANDMMAP
5527 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5528 + mm->mmap_base += mm->delta_mmap;
5529 +#endif
5530 +
5531 mm->get_unmapped_area = arch_get_unmapped_area;
5532 mm->unmap_area = arch_unmap_area;
5533 } else {
5534 mm->mmap_base = mmap_base(random_factor);
5535 +
5536 +#ifdef CONFIG_PAX_RANDMMAP
5537 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5538 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5539 +#endif
5540 +
5541 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5542 mm->unmap_area = arch_unmap_area_topdown;
5543 }
5544 }
5545
5546 -static inline unsigned long brk_rnd(void)
5547 -{
5548 - unsigned long rnd = get_random_int();
5549 -
5550 - rnd = rnd << PAGE_SHIFT;
5551 - /* 8MB for 32bit, 256MB for 64bit */
5552 - if (TASK_IS_32BIT_ADDR)
5553 - rnd = rnd & 0x7ffffful;
5554 - else
5555 - rnd = rnd & 0xffffffful;
5556 -
5557 - return rnd;
5558 -}
5559 -
5560 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5561 -{
5562 - unsigned long base = mm->brk;
5563 - unsigned long ret;
5564 -
5565 - ret = PAGE_ALIGN(base + brk_rnd());
5566 -
5567 - if (ret < mm->brk)
5568 - return mm->brk;
5569 -
5570 - return ret;
5571 -}
5572 -
5573 int __virt_addr_valid(const volatile void *kaddr)
5574 {
5575 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5576 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5577 index 967d144..db12197 100644
5578 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5579 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5580 @@ -11,12 +11,14 @@
5581 #ifndef _ASM_PROC_CACHE_H
5582 #define _ASM_PROC_CACHE_H
5583
5584 +#include <linux/const.h>
5585 +
5586 /* L1 cache */
5587
5588 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5589 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5590 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5591 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5592 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5593 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5594
5595 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5596 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5597 index bcb5df2..84fabd2 100644
5598 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5599 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5600 @@ -16,13 +16,15 @@
5601 #ifndef _ASM_PROC_CACHE_H
5602 #define _ASM_PROC_CACHE_H
5603
5604 +#include <linux/const.h>
5605 +
5606 /*
5607 * L1 cache
5608 */
5609 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5610 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5611 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5612 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5613 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5614 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5615
5616 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5617 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5618 index 4ce7a01..449202a 100644
5619 --- a/arch/openrisc/include/asm/cache.h
5620 +++ b/arch/openrisc/include/asm/cache.h
5621 @@ -19,11 +19,13 @@
5622 #ifndef __ASM_OPENRISC_CACHE_H
5623 #define __ASM_OPENRISC_CACHE_H
5624
5625 +#include <linux/const.h>
5626 +
5627 /* FIXME: How can we replace these with values from the CPU...
5628 * they shouldn't be hard-coded!
5629 */
5630
5631 -#define L1_CACHE_BYTES 16
5632 #define L1_CACHE_SHIFT 4
5633 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5634
5635 #endif /* __ASM_OPENRISC_CACHE_H */
5636 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5637 index f38e198..4179e38 100644
5638 --- a/arch/parisc/include/asm/atomic.h
5639 +++ b/arch/parisc/include/asm/atomic.h
5640 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5641
5642 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5643
5644 +#define atomic64_read_unchecked(v) atomic64_read(v)
5645 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5646 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5647 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5648 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5649 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5650 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5651 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5652 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5653 +
5654 #endif /* !CONFIG_64BIT */
5655
5656
5657 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5658 index 47f11c7..3420df2 100644
5659 --- a/arch/parisc/include/asm/cache.h
5660 +++ b/arch/parisc/include/asm/cache.h
5661 @@ -5,6 +5,7 @@
5662 #ifndef __ARCH_PARISC_CACHE_H
5663 #define __ARCH_PARISC_CACHE_H
5664
5665 +#include <linux/const.h>
5666
5667 /*
5668 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5669 @@ -15,13 +16,13 @@
5670 * just ruin performance.
5671 */
5672 #ifdef CONFIG_PA20
5673 -#define L1_CACHE_BYTES 64
5674 #define L1_CACHE_SHIFT 6
5675 #else
5676 -#define L1_CACHE_BYTES 32
5677 #define L1_CACHE_SHIFT 5
5678 #endif
5679
5680 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5681 +
5682 #ifndef __ASSEMBLY__
5683
5684 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5685 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5686 index ad2b503..bdf1651 100644
5687 --- a/arch/parisc/include/asm/elf.h
5688 +++ b/arch/parisc/include/asm/elf.h
5689 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5690
5691 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5692
5693 +#ifdef CONFIG_PAX_ASLR
5694 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5695 +
5696 +#define PAX_DELTA_MMAP_LEN 16
5697 +#define PAX_DELTA_STACK_LEN 16
5698 +#endif
5699 +
5700 /* This yields a mask that user programs can use to figure out what
5701 instruction set this CPU supports. This could be done in user space,
5702 but it's not easy, and we've already done it here. */
5703 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5704 index fc987a1..6e068ef 100644
5705 --- a/arch/parisc/include/asm/pgalloc.h
5706 +++ b/arch/parisc/include/asm/pgalloc.h
5707 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5708 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5709 }
5710
5711 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5712 +{
5713 + pgd_populate(mm, pgd, pmd);
5714 +}
5715 +
5716 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5717 {
5718 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5719 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5720 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5721 #define pmd_free(mm, x) do { } while (0)
5722 #define pgd_populate(mm, pmd, pte) BUG()
5723 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5724
5725 #endif
5726
5727 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5728 index 1e40d7f..a3eb445 100644
5729 --- a/arch/parisc/include/asm/pgtable.h
5730 +++ b/arch/parisc/include/asm/pgtable.h
5731 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5732 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5733 #define PAGE_COPY PAGE_EXECREAD
5734 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5735 +
5736 +#ifdef CONFIG_PAX_PAGEEXEC
5737 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5738 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5739 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5740 +#else
5741 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5742 +# define PAGE_COPY_NOEXEC PAGE_COPY
5743 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5744 +#endif
5745 +
5746 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5747 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5748 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5749 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5750 index e0a8235..ce2f1e1 100644
5751 --- a/arch/parisc/include/asm/uaccess.h
5752 +++ b/arch/parisc/include/asm/uaccess.h
5753 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5754 const void __user *from,
5755 unsigned long n)
5756 {
5757 - int sz = __compiletime_object_size(to);
5758 + size_t sz = __compiletime_object_size(to);
5759 int ret = -EFAULT;
5760
5761 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5762 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5763 ret = __copy_from_user(to, from, n);
5764 else
5765 copy_from_user_overflow();
5766 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5767 index 2a625fb..9908930 100644
5768 --- a/arch/parisc/kernel/module.c
5769 +++ b/arch/parisc/kernel/module.c
5770 @@ -98,16 +98,38 @@
5771
5772 /* three functions to determine where in the module core
5773 * or init pieces the location is */
5774 +static inline int in_init_rx(struct module *me, void *loc)
5775 +{
5776 + return (loc >= me->module_init_rx &&
5777 + loc < (me->module_init_rx + me->init_size_rx));
5778 +}
5779 +
5780 +static inline int in_init_rw(struct module *me, void *loc)
5781 +{
5782 + return (loc >= me->module_init_rw &&
5783 + loc < (me->module_init_rw + me->init_size_rw));
5784 +}
5785 +
5786 static inline int in_init(struct module *me, void *loc)
5787 {
5788 - return (loc >= me->module_init &&
5789 - loc <= (me->module_init + me->init_size));
5790 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5791 +}
5792 +
5793 +static inline int in_core_rx(struct module *me, void *loc)
5794 +{
5795 + return (loc >= me->module_core_rx &&
5796 + loc < (me->module_core_rx + me->core_size_rx));
5797 +}
5798 +
5799 +static inline int in_core_rw(struct module *me, void *loc)
5800 +{
5801 + return (loc >= me->module_core_rw &&
5802 + loc < (me->module_core_rw + me->core_size_rw));
5803 }
5804
5805 static inline int in_core(struct module *me, void *loc)
5806 {
5807 - return (loc >= me->module_core &&
5808 - loc <= (me->module_core + me->core_size));
5809 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5810 }
5811
5812 static inline int in_local(struct module *me, void *loc)
5813 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5814 }
5815
5816 /* align things a bit */
5817 - me->core_size = ALIGN(me->core_size, 16);
5818 - me->arch.got_offset = me->core_size;
5819 - me->core_size += gots * sizeof(struct got_entry);
5820 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5821 + me->arch.got_offset = me->core_size_rw;
5822 + me->core_size_rw += gots * sizeof(struct got_entry);
5823
5824 - me->core_size = ALIGN(me->core_size, 16);
5825 - me->arch.fdesc_offset = me->core_size;
5826 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5827 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5828 + me->arch.fdesc_offset = me->core_size_rw;
5829 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5830
5831 me->arch.got_max = gots;
5832 me->arch.fdesc_max = fdescs;
5833 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5834
5835 BUG_ON(value == 0);
5836
5837 - got = me->module_core + me->arch.got_offset;
5838 + got = me->module_core_rw + me->arch.got_offset;
5839 for (i = 0; got[i].addr; i++)
5840 if (got[i].addr == value)
5841 goto out;
5842 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5843 #ifdef CONFIG_64BIT
5844 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5845 {
5846 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5847 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5848
5849 if (!value) {
5850 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5851 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5852
5853 /* Create new one */
5854 fdesc->addr = value;
5855 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5856 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5857 return (Elf_Addr)fdesc;
5858 }
5859 #endif /* CONFIG_64BIT */
5860 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5861
5862 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5863 end = table + sechdrs[me->arch.unwind_section].sh_size;
5864 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5865 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5866
5867 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5868 me->arch.unwind_section, table, end, gp);
5869 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5870 index 5dfd248..64914ac 100644
5871 --- a/arch/parisc/kernel/sys_parisc.c
5872 +++ b/arch/parisc/kernel/sys_parisc.c
5873 @@ -33,9 +33,11 @@
5874 #include <linux/utsname.h>
5875 #include <linux/personality.h>
5876
5877 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5878 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5879 + unsigned long flags)
5880 {
5881 struct vm_unmapped_area_info info;
5882 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5883
5884 info.flags = 0;
5885 info.length = len;
5886 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5887 info.high_limit = TASK_SIZE;
5888 info.align_mask = 0;
5889 info.align_offset = 0;
5890 + info.threadstack_offset = offset;
5891 return vm_unmapped_area(&info);
5892 }
5893
5894 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
5895 return (unsigned long) mapping >> 8;
5896 }
5897
5898 -static unsigned long get_shared_area(struct address_space *mapping,
5899 - unsigned long addr, unsigned long len, unsigned long pgoff)
5900 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5901 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5902 {
5903 struct vm_unmapped_area_info info;
5904 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5905
5906 info.flags = 0;
5907 info.length = len;
5908 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5909 info.high_limit = TASK_SIZE;
5910 info.align_mask = PAGE_MASK & (SHMLBA - 1);
5911 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
5912 + info.threadstack_offset = offset;
5913 return vm_unmapped_area(&info);
5914 }
5915
5916 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5917 return -EINVAL;
5918 return addr;
5919 }
5920 - if (!addr)
5921 + if (!addr) {
5922 addr = TASK_UNMAPPED_BASE;
5923
5924 +#ifdef CONFIG_PAX_RANDMMAP
5925 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
5926 + addr += current->mm->delta_mmap;
5927 +#endif
5928 +
5929 + }
5930 +
5931 if (filp) {
5932 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
5933 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
5934 } else if(flags & MAP_SHARED) {
5935 - addr = get_shared_area(NULL, addr, len, pgoff);
5936 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
5937 } else {
5938 - addr = get_unshared_area(addr, len);
5939 + addr = get_unshared_area(filp, addr, len, flags);
5940 }
5941 return addr;
5942 }
5943 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
5944 index aeb8f8f..27a6c2f 100644
5945 --- a/arch/parisc/kernel/traps.c
5946 +++ b/arch/parisc/kernel/traps.c
5947 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
5948
5949 down_read(&current->mm->mmap_sem);
5950 vma = find_vma(current->mm,regs->iaoq[0]);
5951 - if (vma && (regs->iaoq[0] >= vma->vm_start)
5952 - && (vma->vm_flags & VM_EXEC)) {
5953 -
5954 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
5955 fault_address = regs->iaoq[0];
5956 fault_space = regs->iasq[0];
5957
5958 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
5959 index f247a34..dc0f219 100644
5960 --- a/arch/parisc/mm/fault.c
5961 +++ b/arch/parisc/mm/fault.c
5962 @@ -15,6 +15,7 @@
5963 #include <linux/sched.h>
5964 #include <linux/interrupt.h>
5965 #include <linux/module.h>
5966 +#include <linux/unistd.h>
5967
5968 #include <asm/uaccess.h>
5969 #include <asm/traps.h>
5970 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
5971 static unsigned long
5972 parisc_acctyp(unsigned long code, unsigned int inst)
5973 {
5974 - if (code == 6 || code == 16)
5975 + if (code == 6 || code == 7 || code == 16)
5976 return VM_EXEC;
5977
5978 switch (inst & 0xf0000000) {
5979 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
5980 }
5981 #endif
5982
5983 +#ifdef CONFIG_PAX_PAGEEXEC
5984 +/*
5985 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
5986 + *
5987 + * returns 1 when task should be killed
5988 + * 2 when rt_sigreturn trampoline was detected
5989 + * 3 when unpatched PLT trampoline was detected
5990 + */
5991 +static int pax_handle_fetch_fault(struct pt_regs *regs)
5992 +{
5993 +
5994 +#ifdef CONFIG_PAX_EMUPLT
5995 + int err;
5996 +
5997 + do { /* PaX: unpatched PLT emulation */
5998 + unsigned int bl, depwi;
5999 +
6000 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6001 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6002 +
6003 + if (err)
6004 + break;
6005 +
6006 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6007 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6008 +
6009 + err = get_user(ldw, (unsigned int *)addr);
6010 + err |= get_user(bv, (unsigned int *)(addr+4));
6011 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6012 +
6013 + if (err)
6014 + break;
6015 +
6016 + if (ldw == 0x0E801096U &&
6017 + bv == 0xEAC0C000U &&
6018 + ldw2 == 0x0E881095U)
6019 + {
6020 + unsigned int resolver, map;
6021 +
6022 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6023 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6024 + if (err)
6025 + break;
6026 +
6027 + regs->gr[20] = instruction_pointer(regs)+8;
6028 + regs->gr[21] = map;
6029 + regs->gr[22] = resolver;
6030 + regs->iaoq[0] = resolver | 3UL;
6031 + regs->iaoq[1] = regs->iaoq[0] + 4;
6032 + return 3;
6033 + }
6034 + }
6035 + } while (0);
6036 +#endif
6037 +
6038 +#ifdef CONFIG_PAX_EMUTRAMP
6039 +
6040 +#ifndef CONFIG_PAX_EMUSIGRT
6041 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6042 + return 1;
6043 +#endif
6044 +
6045 + do { /* PaX: rt_sigreturn emulation */
6046 + unsigned int ldi1, ldi2, bel, nop;
6047 +
6048 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6049 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6050 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6051 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6052 +
6053 + if (err)
6054 + break;
6055 +
6056 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6057 + ldi2 == 0x3414015AU &&
6058 + bel == 0xE4008200U &&
6059 + nop == 0x08000240U)
6060 + {
6061 + regs->gr[25] = (ldi1 & 2) >> 1;
6062 + regs->gr[20] = __NR_rt_sigreturn;
6063 + regs->gr[31] = regs->iaoq[1] + 16;
6064 + regs->sr[0] = regs->iasq[1];
6065 + regs->iaoq[0] = 0x100UL;
6066 + regs->iaoq[1] = regs->iaoq[0] + 4;
6067 + regs->iasq[0] = regs->sr[2];
6068 + regs->iasq[1] = regs->sr[2];
6069 + return 2;
6070 + }
6071 + } while (0);
6072 +#endif
6073 +
6074 + return 1;
6075 +}
6076 +
6077 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6078 +{
6079 + unsigned long i;
6080 +
6081 + printk(KERN_ERR "PAX: bytes at PC: ");
6082 + for (i = 0; i < 5; i++) {
6083 + unsigned int c;
6084 + if (get_user(c, (unsigned int *)pc+i))
6085 + printk(KERN_CONT "???????? ");
6086 + else
6087 + printk(KERN_CONT "%08x ", c);
6088 + }
6089 + printk("\n");
6090 +}
6091 +#endif
6092 +
6093 int fixup_exception(struct pt_regs *regs)
6094 {
6095 const struct exception_table_entry *fix;
6096 @@ -194,8 +305,33 @@ good_area:
6097
6098 acc_type = parisc_acctyp(code,regs->iir);
6099
6100 - if ((vma->vm_flags & acc_type) != acc_type)
6101 + if ((vma->vm_flags & acc_type) != acc_type) {
6102 +
6103 +#ifdef CONFIG_PAX_PAGEEXEC
6104 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6105 + (address & ~3UL) == instruction_pointer(regs))
6106 + {
6107 + up_read(&mm->mmap_sem);
6108 + switch (pax_handle_fetch_fault(regs)) {
6109 +
6110 +#ifdef CONFIG_PAX_EMUPLT
6111 + case 3:
6112 + return;
6113 +#endif
6114 +
6115 +#ifdef CONFIG_PAX_EMUTRAMP
6116 + case 2:
6117 + return;
6118 +#endif
6119 +
6120 + }
6121 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6122 + do_group_exit(SIGKILL);
6123 + }
6124 +#endif
6125 +
6126 goto bad_area;
6127 + }
6128
6129 /*
6130 * If for any reason at all we couldn't handle the fault, make
6131 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6132 index e3b1d41..8e81edf 100644
6133 --- a/arch/powerpc/include/asm/atomic.h
6134 +++ b/arch/powerpc/include/asm/atomic.h
6135 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6136 return t1;
6137 }
6138
6139 +#define atomic64_read_unchecked(v) atomic64_read(v)
6140 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6141 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6142 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6143 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6144 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6145 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6146 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6147 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6148 +
6149 #endif /* __powerpc64__ */
6150
6151 #endif /* __KERNEL__ */
6152 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6153 index 9e495c9..b6878e5 100644
6154 --- a/arch/powerpc/include/asm/cache.h
6155 +++ b/arch/powerpc/include/asm/cache.h
6156 @@ -3,6 +3,7 @@
6157
6158 #ifdef __KERNEL__
6159
6160 +#include <linux/const.h>
6161
6162 /* bytes per L1 cache line */
6163 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6164 @@ -22,7 +23,7 @@
6165 #define L1_CACHE_SHIFT 7
6166 #endif
6167
6168 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6169 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6170
6171 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6172
6173 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6174 index ac9790f..6d30741 100644
6175 --- a/arch/powerpc/include/asm/elf.h
6176 +++ b/arch/powerpc/include/asm/elf.h
6177 @@ -28,8 +28,19 @@
6178 the loader. We need to make sure that it is out of the way of the program
6179 that it will "exec", and that there is sufficient room for the brk. */
6180
6181 -extern unsigned long randomize_et_dyn(unsigned long base);
6182 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6183 +#define ELF_ET_DYN_BASE (0x20000000)
6184 +
6185 +#ifdef CONFIG_PAX_ASLR
6186 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6187 +
6188 +#ifdef __powerpc64__
6189 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6190 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6191 +#else
6192 +#define PAX_DELTA_MMAP_LEN 15
6193 +#define PAX_DELTA_STACK_LEN 15
6194 +#endif
6195 +#endif
6196
6197 /*
6198 * Our registers are always unsigned longs, whether we're a 32 bit
6199 @@ -122,10 +133,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6200 (0x7ff >> (PAGE_SHIFT - 12)) : \
6201 (0x3ffff >> (PAGE_SHIFT - 12)))
6202
6203 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6204 -#define arch_randomize_brk arch_randomize_brk
6205 -
6206 -
6207 #ifdef CONFIG_SPU_BASE
6208 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6209 #define NT_SPU 1
6210 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6211 index 8196e9c..d83a9f3 100644
6212 --- a/arch/powerpc/include/asm/exec.h
6213 +++ b/arch/powerpc/include/asm/exec.h
6214 @@ -4,6 +4,6 @@
6215 #ifndef _ASM_POWERPC_EXEC_H
6216 #define _ASM_POWERPC_EXEC_H
6217
6218 -extern unsigned long arch_align_stack(unsigned long sp);
6219 +#define arch_align_stack(x) ((x) & ~0xfUL)
6220
6221 #endif /* _ASM_POWERPC_EXEC_H */
6222 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6223 index 5acabbd..7ea14fa 100644
6224 --- a/arch/powerpc/include/asm/kmap_types.h
6225 +++ b/arch/powerpc/include/asm/kmap_types.h
6226 @@ -10,7 +10,7 @@
6227 * 2 of the License, or (at your option) any later version.
6228 */
6229
6230 -#define KM_TYPE_NR 16
6231 +#define KM_TYPE_NR 17
6232
6233 #endif /* __KERNEL__ */
6234 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6235 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6236 index 8565c25..2865190 100644
6237 --- a/arch/powerpc/include/asm/mman.h
6238 +++ b/arch/powerpc/include/asm/mman.h
6239 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6240 }
6241 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6242
6243 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6244 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6245 {
6246 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6247 }
6248 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6249 index f072e97..b436dee 100644
6250 --- a/arch/powerpc/include/asm/page.h
6251 +++ b/arch/powerpc/include/asm/page.h
6252 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6253 * and needs to be executable. This means the whole heap ends
6254 * up being executable.
6255 */
6256 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6257 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6258 +#define VM_DATA_DEFAULT_FLAGS32 \
6259 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6260 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6261
6262 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6263 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6264 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6265 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6266 #endif
6267
6268 +#define ktla_ktva(addr) (addr)
6269 +#define ktva_ktla(addr) (addr)
6270 +
6271 /*
6272 * Use the top bit of the higher-level page table entries to indicate whether
6273 * the entries we point to contain hugepages. This works because we know that
6274 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6275 index cd915d6..c10cee8 100644
6276 --- a/arch/powerpc/include/asm/page_64.h
6277 +++ b/arch/powerpc/include/asm/page_64.h
6278 @@ -154,15 +154,18 @@ do { \
6279 * stack by default, so in the absence of a PT_GNU_STACK program header
6280 * we turn execute permission off.
6281 */
6282 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6283 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6284 +#define VM_STACK_DEFAULT_FLAGS32 \
6285 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6286 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6287
6288 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6289 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6290
6291 +#ifndef CONFIG_PAX_PAGEEXEC
6292 #define VM_STACK_DEFAULT_FLAGS \
6293 (is_32bit_task() ? \
6294 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6295 +#endif
6296
6297 #include <asm-generic/getorder.h>
6298
6299 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6300 index 292725c..f87ae14 100644
6301 --- a/arch/powerpc/include/asm/pgalloc-64.h
6302 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6303 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6304 #ifndef CONFIG_PPC_64K_PAGES
6305
6306 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6307 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6308
6309 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6310 {
6311 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6312 pud_set(pud, (unsigned long)pmd);
6313 }
6314
6315 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6316 +{
6317 + pud_populate(mm, pud, pmd);
6318 +}
6319 +
6320 #define pmd_populate(mm, pmd, pte_page) \
6321 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6322 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6323 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6324 #else /* CONFIG_PPC_64K_PAGES */
6325
6326 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6327 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6328
6329 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6330 pte_t *pte)
6331 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6332 index a9cbd3b..3b67efa 100644
6333 --- a/arch/powerpc/include/asm/pgtable.h
6334 +++ b/arch/powerpc/include/asm/pgtable.h
6335 @@ -2,6 +2,7 @@
6336 #define _ASM_POWERPC_PGTABLE_H
6337 #ifdef __KERNEL__
6338
6339 +#include <linux/const.h>
6340 #ifndef __ASSEMBLY__
6341 #include <asm/processor.h> /* For TASK_SIZE */
6342 #include <asm/mmu.h>
6343 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6344 index 4aad413..85d86bf 100644
6345 --- a/arch/powerpc/include/asm/pte-hash32.h
6346 +++ b/arch/powerpc/include/asm/pte-hash32.h
6347 @@ -21,6 +21,7 @@
6348 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6349 #define _PAGE_USER 0x004 /* usermode access allowed */
6350 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6351 +#define _PAGE_EXEC _PAGE_GUARDED
6352 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6353 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6354 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6355 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6356 index c9c67fc..e10c012 100644
6357 --- a/arch/powerpc/include/asm/reg.h
6358 +++ b/arch/powerpc/include/asm/reg.h
6359 @@ -245,6 +245,7 @@
6360 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6361 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6362 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6363 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6364 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6365 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6366 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6367 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6368 index 195ce2a..ab5c614 100644
6369 --- a/arch/powerpc/include/asm/smp.h
6370 +++ b/arch/powerpc/include/asm/smp.h
6371 @@ -50,7 +50,7 @@ struct smp_ops_t {
6372 int (*cpu_disable)(void);
6373 void (*cpu_die)(unsigned int nr);
6374 int (*cpu_bootable)(unsigned int nr);
6375 -};
6376 +} __no_const;
6377
6378 extern void smp_send_debugger_break(void);
6379 extern void start_secondary_resume(void);
6380 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6381 index 406b7b9..af63426 100644
6382 --- a/arch/powerpc/include/asm/thread_info.h
6383 +++ b/arch/powerpc/include/asm/thread_info.h
6384 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6385 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6386 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6387 #define TIF_SINGLESTEP 8 /* singlestepping active */
6388 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6389 #define TIF_SECCOMP 10 /* secure computing */
6390 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6391 #define TIF_NOERROR 12 /* Force successful syscall return */
6392 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6393 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6394 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6395 for stack store? */
6396 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6397 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6398 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6399
6400 /* as above, but as bit values */
6401 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6402 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6403 #define _TIF_UPROBE (1<<TIF_UPROBE)
6404 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6405 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6406 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6407 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6408 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6409 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6410 + _TIF_GRSEC_SETXID)
6411
6412 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6413 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6414 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6415 index 4db4959..aba5c41 100644
6416 --- a/arch/powerpc/include/asm/uaccess.h
6417 +++ b/arch/powerpc/include/asm/uaccess.h
6418 @@ -318,52 +318,6 @@ do { \
6419 extern unsigned long __copy_tofrom_user(void __user *to,
6420 const void __user *from, unsigned long size);
6421
6422 -#ifndef __powerpc64__
6423 -
6424 -static inline unsigned long copy_from_user(void *to,
6425 - const void __user *from, unsigned long n)
6426 -{
6427 - unsigned long over;
6428 -
6429 - if (access_ok(VERIFY_READ, from, n))
6430 - return __copy_tofrom_user((__force void __user *)to, from, n);
6431 - if ((unsigned long)from < TASK_SIZE) {
6432 - over = (unsigned long)from + n - TASK_SIZE;
6433 - return __copy_tofrom_user((__force void __user *)to, from,
6434 - n - over) + over;
6435 - }
6436 - return n;
6437 -}
6438 -
6439 -static inline unsigned long copy_to_user(void __user *to,
6440 - const void *from, unsigned long n)
6441 -{
6442 - unsigned long over;
6443 -
6444 - if (access_ok(VERIFY_WRITE, to, n))
6445 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6446 - if ((unsigned long)to < TASK_SIZE) {
6447 - over = (unsigned long)to + n - TASK_SIZE;
6448 - return __copy_tofrom_user(to, (__force void __user *)from,
6449 - n - over) + over;
6450 - }
6451 - return n;
6452 -}
6453 -
6454 -#else /* __powerpc64__ */
6455 -
6456 -#define __copy_in_user(to, from, size) \
6457 - __copy_tofrom_user((to), (from), (size))
6458 -
6459 -extern unsigned long copy_from_user(void *to, const void __user *from,
6460 - unsigned long n);
6461 -extern unsigned long copy_to_user(void __user *to, const void *from,
6462 - unsigned long n);
6463 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6464 - unsigned long n);
6465 -
6466 -#endif /* __powerpc64__ */
6467 -
6468 static inline unsigned long __copy_from_user_inatomic(void *to,
6469 const void __user *from, unsigned long n)
6470 {
6471 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6472 if (ret == 0)
6473 return 0;
6474 }
6475 +
6476 + if (!__builtin_constant_p(n))
6477 + check_object_size(to, n, false);
6478 +
6479 return __copy_tofrom_user((__force void __user *)to, from, n);
6480 }
6481
6482 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6483 if (ret == 0)
6484 return 0;
6485 }
6486 +
6487 + if (!__builtin_constant_p(n))
6488 + check_object_size(from, n, true);
6489 +
6490 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6491 }
6492
6493 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6494 return __copy_to_user_inatomic(to, from, size);
6495 }
6496
6497 +#ifndef __powerpc64__
6498 +
6499 +static inline unsigned long __must_check copy_from_user(void *to,
6500 + const void __user *from, unsigned long n)
6501 +{
6502 + unsigned long over;
6503 +
6504 + if ((long)n < 0)
6505 + return n;
6506 +
6507 + if (access_ok(VERIFY_READ, from, n)) {
6508 + if (!__builtin_constant_p(n))
6509 + check_object_size(to, n, false);
6510 + return __copy_tofrom_user((__force void __user *)to, from, n);
6511 + }
6512 + if ((unsigned long)from < TASK_SIZE) {
6513 + over = (unsigned long)from + n - TASK_SIZE;
6514 + if (!__builtin_constant_p(n - over))
6515 + check_object_size(to, n - over, false);
6516 + return __copy_tofrom_user((__force void __user *)to, from,
6517 + n - over) + over;
6518 + }
6519 + return n;
6520 +}
6521 +
6522 +static inline unsigned long __must_check copy_to_user(void __user *to,
6523 + const void *from, unsigned long n)
6524 +{
6525 + unsigned long over;
6526 +
6527 + if ((long)n < 0)
6528 + return n;
6529 +
6530 + if (access_ok(VERIFY_WRITE, to, n)) {
6531 + if (!__builtin_constant_p(n))
6532 + check_object_size(from, n, true);
6533 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6534 + }
6535 + if ((unsigned long)to < TASK_SIZE) {
6536 + over = (unsigned long)to + n - TASK_SIZE;
6537 + if (!__builtin_constant_p(n))
6538 + check_object_size(from, n - over, true);
6539 + return __copy_tofrom_user(to, (__force void __user *)from,
6540 + n - over) + over;
6541 + }
6542 + return n;
6543 +}
6544 +
6545 +#else /* __powerpc64__ */
6546 +
6547 +#define __copy_in_user(to, from, size) \
6548 + __copy_tofrom_user((to), (from), (size))
6549 +
6550 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6551 +{
6552 + if ((long)n < 0 || n > INT_MAX)
6553 + return n;
6554 +
6555 + if (!__builtin_constant_p(n))
6556 + check_object_size(to, n, false);
6557 +
6558 + if (likely(access_ok(VERIFY_READ, from, n)))
6559 + n = __copy_from_user(to, from, n);
6560 + else
6561 + memset(to, 0, n);
6562 + return n;
6563 +}
6564 +
6565 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6566 +{
6567 + if ((long)n < 0 || n > INT_MAX)
6568 + return n;
6569 +
6570 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6571 + if (!__builtin_constant_p(n))
6572 + check_object_size(from, n, true);
6573 + n = __copy_to_user(to, from, n);
6574 + }
6575 + return n;
6576 +}
6577 +
6578 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6579 + unsigned long n);
6580 +
6581 +#endif /* __powerpc64__ */
6582 +
6583 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6584
6585 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6586 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6587 index ae54553..cf2184d 100644
6588 --- a/arch/powerpc/kernel/exceptions-64e.S
6589 +++ b/arch/powerpc/kernel/exceptions-64e.S
6590 @@ -716,6 +716,7 @@ storage_fault_common:
6591 std r14,_DAR(r1)
6592 std r15,_DSISR(r1)
6593 addi r3,r1,STACK_FRAME_OVERHEAD
6594 + bl .save_nvgprs
6595 mr r4,r14
6596 mr r5,r15
6597 ld r14,PACA_EXGEN+EX_R14(r13)
6598 @@ -724,8 +725,7 @@ storage_fault_common:
6599 cmpdi r3,0
6600 bne- 1f
6601 b .ret_from_except_lite
6602 -1: bl .save_nvgprs
6603 - mr r5,r3
6604 +1: mr r5,r3
6605 addi r3,r1,STACK_FRAME_OVERHEAD
6606 ld r4,_DAR(r1)
6607 bl .bad_page_fault
6608 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6609 index 3bbe7ed..14ec3eb 100644
6610 --- a/arch/powerpc/kernel/exceptions-64s.S
6611 +++ b/arch/powerpc/kernel/exceptions-64s.S
6612 @@ -1390,10 +1390,10 @@ handle_page_fault:
6613 11: ld r4,_DAR(r1)
6614 ld r5,_DSISR(r1)
6615 addi r3,r1,STACK_FRAME_OVERHEAD
6616 + bl .save_nvgprs
6617 bl .do_page_fault
6618 cmpdi r3,0
6619 beq+ 12f
6620 - bl .save_nvgprs
6621 mr r5,r3
6622 addi r3,r1,STACK_FRAME_OVERHEAD
6623 lwz r4,_DAR(r1)
6624 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6625 index 2e3200c..72095ce 100644
6626 --- a/arch/powerpc/kernel/module_32.c
6627 +++ b/arch/powerpc/kernel/module_32.c
6628 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6629 me->arch.core_plt_section = i;
6630 }
6631 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6632 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6633 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6634 return -ENOEXEC;
6635 }
6636
6637 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6638
6639 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6640 /* Init, or core PLT? */
6641 - if (location >= mod->module_core
6642 - && location < mod->module_core + mod->core_size)
6643 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6644 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6645 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6646 - else
6647 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6648 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6649 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6650 + else {
6651 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6652 + return ~0UL;
6653 + }
6654
6655 /* Find this entry, or if that fails, the next avail. entry */
6656 while (entry->jump[0]) {
6657 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6658 index 16e77a8..4501b41 100644
6659 --- a/arch/powerpc/kernel/process.c
6660 +++ b/arch/powerpc/kernel/process.c
6661 @@ -870,8 +870,8 @@ void show_regs(struct pt_regs * regs)
6662 * Lookup NIP late so we have the best change of getting the
6663 * above info out without failing
6664 */
6665 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6666 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6667 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6668 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6669 #endif
6670 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6671 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6672 @@ -1330,10 +1330,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6673 newsp = stack[0];
6674 ip = stack[STACK_FRAME_LR_SAVE];
6675 if (!firstframe || ip != lr) {
6676 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6677 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6678 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6679 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6680 - printk(" (%pS)",
6681 + printk(" (%pA)",
6682 (void *)current->ret_stack[curr_frame].ret);
6683 curr_frame--;
6684 }
6685 @@ -1353,7 +1353,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6686 struct pt_regs *regs = (struct pt_regs *)
6687 (sp + STACK_FRAME_OVERHEAD);
6688 lr = regs->link;
6689 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6690 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6691 regs->trap, (void *)regs->nip, (void *)lr);
6692 firstframe = 1;
6693 }
6694 @@ -1395,58 +1395,3 @@ void __ppc64_runlatch_off(void)
6695 mtspr(SPRN_CTRLT, ctrl);
6696 }
6697 #endif /* CONFIG_PPC64 */
6698 -
6699 -unsigned long arch_align_stack(unsigned long sp)
6700 -{
6701 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6702 - sp -= get_random_int() & ~PAGE_MASK;
6703 - return sp & ~0xf;
6704 -}
6705 -
6706 -static inline unsigned long brk_rnd(void)
6707 -{
6708 - unsigned long rnd = 0;
6709 -
6710 - /* 8MB for 32bit, 1GB for 64bit */
6711 - if (is_32bit_task())
6712 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6713 - else
6714 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6715 -
6716 - return rnd << PAGE_SHIFT;
6717 -}
6718 -
6719 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6720 -{
6721 - unsigned long base = mm->brk;
6722 - unsigned long ret;
6723 -
6724 -#ifdef CONFIG_PPC_STD_MMU_64
6725 - /*
6726 - * If we are using 1TB segments and we are allowed to randomise
6727 - * the heap, we can put it above 1TB so it is backed by a 1TB
6728 - * segment. Otherwise the heap will be in the bottom 1TB
6729 - * which always uses 256MB segments and this may result in a
6730 - * performance penalty.
6731 - */
6732 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6733 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6734 -#endif
6735 -
6736 - ret = PAGE_ALIGN(base + brk_rnd());
6737 -
6738 - if (ret < mm->brk)
6739 - return mm->brk;
6740 -
6741 - return ret;
6742 -}
6743 -
6744 -unsigned long randomize_et_dyn(unsigned long base)
6745 -{
6746 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6747 -
6748 - if (ret < base)
6749 - return base;
6750 -
6751 - return ret;
6752 -}
6753 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6754 index f9b30c6..d72e7a3 100644
6755 --- a/arch/powerpc/kernel/ptrace.c
6756 +++ b/arch/powerpc/kernel/ptrace.c
6757 @@ -1771,6 +1771,10 @@ long arch_ptrace(struct task_struct *child, long request,
6758 return ret;
6759 }
6760
6761 +#ifdef CONFIG_GRKERNSEC_SETXID
6762 +extern void gr_delayed_cred_worker(void);
6763 +#endif
6764 +
6765 /*
6766 * We must return the syscall number to actually look up in the table.
6767 * This can be -1L to skip running any syscall at all.
6768 @@ -1781,6 +1785,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6769
6770 secure_computing_strict(regs->gpr[0]);
6771
6772 +#ifdef CONFIG_GRKERNSEC_SETXID
6773 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6774 + gr_delayed_cred_worker();
6775 +#endif
6776 +
6777 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6778 tracehook_report_syscall_entry(regs))
6779 /*
6780 @@ -1815,6 +1824,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6781 {
6782 int step;
6783
6784 +#ifdef CONFIG_GRKERNSEC_SETXID
6785 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6786 + gr_delayed_cred_worker();
6787 +#endif
6788 +
6789 audit_syscall_exit(regs);
6790
6791 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6792 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6793 index 95068bf..9ba1814 100644
6794 --- a/arch/powerpc/kernel/signal_32.c
6795 +++ b/arch/powerpc/kernel/signal_32.c
6796 @@ -982,7 +982,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6797 /* Save user registers on the stack */
6798 frame = &rt_sf->uc.uc_mcontext;
6799 addr = frame;
6800 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6801 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6802 sigret = 0;
6803 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6804 } else {
6805 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6806 index c179428..58acdaa 100644
6807 --- a/arch/powerpc/kernel/signal_64.c
6808 +++ b/arch/powerpc/kernel/signal_64.c
6809 @@ -758,7 +758,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6810 #endif
6811
6812 /* Set up to return from userspace. */
6813 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6814 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6815 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6816 } else {
6817 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6818 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6819 index 3ce1f86..c30e629 100644
6820 --- a/arch/powerpc/kernel/sysfs.c
6821 +++ b/arch/powerpc/kernel/sysfs.c
6822 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6823 return NOTIFY_OK;
6824 }
6825
6826 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6827 +static struct notifier_block sysfs_cpu_nb = {
6828 .notifier_call = sysfs_cpu_notify,
6829 };
6830
6831 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6832 index 83efa2f..6bb5839 100644
6833 --- a/arch/powerpc/kernel/traps.c
6834 +++ b/arch/powerpc/kernel/traps.c
6835 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6836 return flags;
6837 }
6838
6839 +extern void gr_handle_kernel_exploit(void);
6840 +
6841 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6842 int signr)
6843 {
6844 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6845 panic("Fatal exception in interrupt");
6846 if (panic_on_oops)
6847 panic("Fatal exception");
6848 +
6849 + gr_handle_kernel_exploit();
6850 +
6851 do_exit(signr);
6852 }
6853
6854 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6855 index 1b2076f..835e4be 100644
6856 --- a/arch/powerpc/kernel/vdso.c
6857 +++ b/arch/powerpc/kernel/vdso.c
6858 @@ -34,6 +34,7 @@
6859 #include <asm/firmware.h>
6860 #include <asm/vdso.h>
6861 #include <asm/vdso_datapage.h>
6862 +#include <asm/mman.h>
6863
6864 #include "setup.h"
6865
6866 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6867 vdso_base = VDSO32_MBASE;
6868 #endif
6869
6870 - current->mm->context.vdso_base = 0;
6871 + current->mm->context.vdso_base = ~0UL;
6872
6873 /* vDSO has a problem and was disabled, just don't "enable" it for the
6874 * process
6875 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6876 vdso_base = get_unmapped_area(NULL, vdso_base,
6877 (vdso_pages << PAGE_SHIFT) +
6878 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6879 - 0, 0);
6880 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6881 if (IS_ERR_VALUE(vdso_base)) {
6882 rc = vdso_base;
6883 goto fail_mmapsem;
6884 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6885 index 5eea6f3..5d10396 100644
6886 --- a/arch/powerpc/lib/usercopy_64.c
6887 +++ b/arch/powerpc/lib/usercopy_64.c
6888 @@ -9,22 +9,6 @@
6889 #include <linux/module.h>
6890 #include <asm/uaccess.h>
6891
6892 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6893 -{
6894 - if (likely(access_ok(VERIFY_READ, from, n)))
6895 - n = __copy_from_user(to, from, n);
6896 - else
6897 - memset(to, 0, n);
6898 - return n;
6899 -}
6900 -
6901 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6902 -{
6903 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6904 - n = __copy_to_user(to, from, n);
6905 - return n;
6906 -}
6907 -
6908 unsigned long copy_in_user(void __user *to, const void __user *from,
6909 unsigned long n)
6910 {
6911 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6912 return n;
6913 }
6914
6915 -EXPORT_SYMBOL(copy_from_user);
6916 -EXPORT_SYMBOL(copy_to_user);
6917 EXPORT_SYMBOL(copy_in_user);
6918
6919 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6920 index 229951f..cdeca42 100644
6921 --- a/arch/powerpc/mm/fault.c
6922 +++ b/arch/powerpc/mm/fault.c
6923 @@ -32,6 +32,10 @@
6924 #include <linux/perf_event.h>
6925 #include <linux/magic.h>
6926 #include <linux/ratelimit.h>
6927 +#include <linux/slab.h>
6928 +#include <linux/pagemap.h>
6929 +#include <linux/compiler.h>
6930 +#include <linux/unistd.h>
6931
6932 #include <asm/firmware.h>
6933 #include <asm/page.h>
6934 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
6935 }
6936 #endif
6937
6938 +#ifdef CONFIG_PAX_PAGEEXEC
6939 +/*
6940 + * PaX: decide what to do with offenders (regs->nip = fault address)
6941 + *
6942 + * returns 1 when task should be killed
6943 + */
6944 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6945 +{
6946 + return 1;
6947 +}
6948 +
6949 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6950 +{
6951 + unsigned long i;
6952 +
6953 + printk(KERN_ERR "PAX: bytes at PC: ");
6954 + for (i = 0; i < 5; i++) {
6955 + unsigned int c;
6956 + if (get_user(c, (unsigned int __user *)pc+i))
6957 + printk(KERN_CONT "???????? ");
6958 + else
6959 + printk(KERN_CONT "%08x ", c);
6960 + }
6961 + printk("\n");
6962 +}
6963 +#endif
6964 +
6965 /*
6966 * Check whether the instruction at regs->nip is a store using
6967 * an update addressing form which will update r1.
6968 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
6969 * indicate errors in DSISR but can validly be set in SRR1.
6970 */
6971 if (trap == 0x400)
6972 - error_code &= 0x48200000;
6973 + error_code &= 0x58200000;
6974 else
6975 is_write = error_code & DSISR_ISSTORE;
6976 #else
6977 @@ -364,7 +395,7 @@ good_area:
6978 * "undefined". Of those that can be set, this is the only
6979 * one which seems bad.
6980 */
6981 - if (error_code & 0x10000000)
6982 + if (error_code & DSISR_GUARDED)
6983 /* Guarded storage error. */
6984 goto bad_area;
6985 #endif /* CONFIG_8xx */
6986 @@ -379,7 +410,7 @@ good_area:
6987 * processors use the same I/D cache coherency mechanism
6988 * as embedded.
6989 */
6990 - if (error_code & DSISR_PROTFAULT)
6991 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
6992 goto bad_area;
6993 #endif /* CONFIG_PPC_STD_MMU */
6994
6995 @@ -462,6 +493,23 @@ bad_area:
6996 bad_area_nosemaphore:
6997 /* User mode accesses cause a SIGSEGV */
6998 if (user_mode(regs)) {
6999 +
7000 +#ifdef CONFIG_PAX_PAGEEXEC
7001 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7002 +#ifdef CONFIG_PPC_STD_MMU
7003 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7004 +#else
7005 + if (is_exec && regs->nip == address) {
7006 +#endif
7007 + switch (pax_handle_fetch_fault(regs)) {
7008 + }
7009 +
7010 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7011 + do_group_exit(SIGKILL);
7012 + }
7013 + }
7014 +#endif
7015 +
7016 _exception(SIGSEGV, regs, code, address);
7017 return 0;
7018 }
7019 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7020 index 67a42ed..cd463e0 100644
7021 --- a/arch/powerpc/mm/mmap_64.c
7022 +++ b/arch/powerpc/mm/mmap_64.c
7023 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7024 {
7025 unsigned long rnd = 0;
7026
7027 +#ifdef CONFIG_PAX_RANDMMAP
7028 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7029 +#endif
7030 +
7031 if (current->flags & PF_RANDOMIZE) {
7032 /* 8MB for 32bit, 1GB for 64bit */
7033 if (is_32bit_task())
7034 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7035 */
7036 if (mmap_is_legacy()) {
7037 mm->mmap_base = TASK_UNMAPPED_BASE;
7038 +
7039 +#ifdef CONFIG_PAX_RANDMMAP
7040 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7041 + mm->mmap_base += mm->delta_mmap;
7042 +#endif
7043 +
7044 mm->get_unmapped_area = arch_get_unmapped_area;
7045 mm->unmap_area = arch_unmap_area;
7046 } else {
7047 mm->mmap_base = mmap_base();
7048 +
7049 +#ifdef CONFIG_PAX_RANDMMAP
7050 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7051 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7052 +#endif
7053 +
7054 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7055 mm->unmap_area = arch_unmap_area_topdown;
7056 }
7057 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7058 index e779642..e5bb889 100644
7059 --- a/arch/powerpc/mm/mmu_context_nohash.c
7060 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7061 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7062 return NOTIFY_OK;
7063 }
7064
7065 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7066 +static struct notifier_block mmu_context_cpu_nb = {
7067 .notifier_call = mmu_context_cpu_notify,
7068 };
7069
7070 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7071 index 6a252c4..3024d81 100644
7072 --- a/arch/powerpc/mm/numa.c
7073 +++ b/arch/powerpc/mm/numa.c
7074 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7075 return ret;
7076 }
7077
7078 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7079 +static struct notifier_block ppc64_numa_nb = {
7080 .notifier_call = cpu_numa_callback,
7081 .priority = 1 /* Must run before sched domains notifier. */
7082 };
7083 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7084 index cf9dada..241529f 100644
7085 --- a/arch/powerpc/mm/slice.c
7086 +++ b/arch/powerpc/mm/slice.c
7087 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7088 if ((mm->task_size - len) < addr)
7089 return 0;
7090 vma = find_vma(mm, addr);
7091 - return (!vma || (addr + len) <= vma->vm_start);
7092 + return check_heap_stack_gap(vma, addr, len, 0);
7093 }
7094
7095 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7096 @@ -272,7 +272,7 @@ full_search:
7097 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7098 continue;
7099 }
7100 - if (!vma || addr + len <= vma->vm_start) {
7101 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7102 /*
7103 * Remember the place where we stopped the search:
7104 */
7105 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7106 }
7107 }
7108
7109 - addr = mm->mmap_base;
7110 - while (addr > len) {
7111 + if (mm->mmap_base < len)
7112 + addr = -ENOMEM;
7113 + else
7114 + addr = mm->mmap_base - len;
7115 +
7116 + while (!IS_ERR_VALUE(addr)) {
7117 /* Go down by chunk size */
7118 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7119 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7120
7121 /* Check for hit with different page size */
7122 mask = slice_range_to_mask(addr, len);
7123 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7124 * return with success:
7125 */
7126 vma = find_vma(mm, addr);
7127 - if (!vma || (addr + len) <= vma->vm_start) {
7128 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7129 /* remember the address as a hint for next time */
7130 if (use_cache)
7131 mm->free_area_cache = addr;
7132 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7133 mm->cached_hole_size = vma->vm_start - addr;
7134
7135 /* try just below the current vma->vm_start */
7136 - addr = vma->vm_start;
7137 + addr = skip_heap_stack_gap(vma, len, 0);
7138 }
7139
7140 /*
7141 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7142 if (fixed && addr > (mm->task_size - len))
7143 return -EINVAL;
7144
7145 +#ifdef CONFIG_PAX_RANDMMAP
7146 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7147 + addr = 0;
7148 +#endif
7149 +
7150 /* If hint, make sure it matches our alignment restrictions */
7151 if (!fixed && addr) {
7152 addr = _ALIGN_UP(addr, 1ul << pshift);
7153 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7154 index 68c57d3..1fdcfb2 100644
7155 --- a/arch/powerpc/platforms/cell/spufs/file.c
7156 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7157 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7158 return VM_FAULT_NOPAGE;
7159 }
7160
7161 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7162 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7163 unsigned long address,
7164 - void *buf, int len, int write)
7165 + void *buf, size_t len, int write)
7166 {
7167 struct spu_context *ctx = vma->vm_file->private_data;
7168 unsigned long offset = address - vma->vm_start;
7169 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7170 index bdb738a..49c9f95 100644
7171 --- a/arch/powerpc/platforms/powermac/smp.c
7172 +++ b/arch/powerpc/platforms/powermac/smp.c
7173 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7174 return NOTIFY_OK;
7175 }
7176
7177 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7178 +static struct notifier_block smp_core99_cpu_nb = {
7179 .notifier_call = smp_core99_cpu_notify,
7180 };
7181 #endif /* CONFIG_HOTPLUG_CPU */
7182 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7183 index c797832..ce575c8 100644
7184 --- a/arch/s390/include/asm/atomic.h
7185 +++ b/arch/s390/include/asm/atomic.h
7186 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7187 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7188 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7189
7190 +#define atomic64_read_unchecked(v) atomic64_read(v)
7191 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7192 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7193 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7194 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7195 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7196 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7197 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7198 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7199 +
7200 #define smp_mb__before_atomic_dec() smp_mb()
7201 #define smp_mb__after_atomic_dec() smp_mb()
7202 #define smp_mb__before_atomic_inc() smp_mb()
7203 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7204 index 4d7ccac..d03d0ad 100644
7205 --- a/arch/s390/include/asm/cache.h
7206 +++ b/arch/s390/include/asm/cache.h
7207 @@ -9,8 +9,10 @@
7208 #ifndef __ARCH_S390_CACHE_H
7209 #define __ARCH_S390_CACHE_H
7210
7211 -#define L1_CACHE_BYTES 256
7212 +#include <linux/const.h>
7213 +
7214 #define L1_CACHE_SHIFT 8
7215 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7216 #define NET_SKB_PAD 32
7217
7218 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7219 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7220 index 1bfdf24..9c9ab2e 100644
7221 --- a/arch/s390/include/asm/elf.h
7222 +++ b/arch/s390/include/asm/elf.h
7223 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7224 the loader. We need to make sure that it is out of the way of the program
7225 that it will "exec", and that there is sufficient room for the brk. */
7226
7227 -extern unsigned long randomize_et_dyn(unsigned long base);
7228 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7229 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7230 +
7231 +#ifdef CONFIG_PAX_ASLR
7232 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7233 +
7234 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7235 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7236 +#endif
7237
7238 /* This yields a mask that user programs can use to figure out what
7239 instruction set this CPU supports. */
7240 @@ -207,9 +213,6 @@ struct linux_binprm;
7241 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7242 int arch_setup_additional_pages(struct linux_binprm *, int);
7243
7244 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7245 -#define arch_randomize_brk arch_randomize_brk
7246 -
7247 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7248
7249 #endif
7250 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7251 index c4a93d6..4d2a9b4 100644
7252 --- a/arch/s390/include/asm/exec.h
7253 +++ b/arch/s390/include/asm/exec.h
7254 @@ -7,6 +7,6 @@
7255 #ifndef __ASM_EXEC_H
7256 #define __ASM_EXEC_H
7257
7258 -extern unsigned long arch_align_stack(unsigned long sp);
7259 +#define arch_align_stack(x) ((x) & ~0xfUL)
7260
7261 #endif /* __ASM_EXEC_H */
7262 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7263 index 9c33ed4..e40cbef 100644
7264 --- a/arch/s390/include/asm/uaccess.h
7265 +++ b/arch/s390/include/asm/uaccess.h
7266 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7267 copy_to_user(void __user *to, const void *from, unsigned long n)
7268 {
7269 might_fault();
7270 +
7271 + if ((long)n < 0)
7272 + return n;
7273 +
7274 return __copy_to_user(to, from, n);
7275 }
7276
7277 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7278 static inline unsigned long __must_check
7279 __copy_from_user(void *to, const void __user *from, unsigned long n)
7280 {
7281 + if ((long)n < 0)
7282 + return n;
7283 +
7284 if (__builtin_constant_p(n) && (n <= 256))
7285 return uaccess.copy_from_user_small(n, from, to);
7286 else
7287 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7288 static inline unsigned long __must_check
7289 copy_from_user(void *to, const void __user *from, unsigned long n)
7290 {
7291 - unsigned int sz = __compiletime_object_size(to);
7292 + size_t sz = __compiletime_object_size(to);
7293
7294 might_fault();
7295 - if (unlikely(sz != -1 && sz < n)) {
7296 +
7297 + if ((long)n < 0)
7298 + return n;
7299 +
7300 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7301 copy_from_user_overflow();
7302 return n;
7303 }
7304 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7305 index 7845e15..59c4353 100644
7306 --- a/arch/s390/kernel/module.c
7307 +++ b/arch/s390/kernel/module.c
7308 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7309
7310 /* Increase core size by size of got & plt and set start
7311 offsets for got and plt. */
7312 - me->core_size = ALIGN(me->core_size, 4);
7313 - me->arch.got_offset = me->core_size;
7314 - me->core_size += me->arch.got_size;
7315 - me->arch.plt_offset = me->core_size;
7316 - me->core_size += me->arch.plt_size;
7317 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7318 + me->arch.got_offset = me->core_size_rw;
7319 + me->core_size_rw += me->arch.got_size;
7320 + me->arch.plt_offset = me->core_size_rx;
7321 + me->core_size_rx += me->arch.plt_size;
7322 return 0;
7323 }
7324
7325 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7326 if (info->got_initialized == 0) {
7327 Elf_Addr *gotent;
7328
7329 - gotent = me->module_core + me->arch.got_offset +
7330 + gotent = me->module_core_rw + me->arch.got_offset +
7331 info->got_offset;
7332 *gotent = val;
7333 info->got_initialized = 1;
7334 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7335 rc = apply_rela_bits(loc, val, 0, 64, 0);
7336 else if (r_type == R_390_GOTENT ||
7337 r_type == R_390_GOTPLTENT) {
7338 - val += (Elf_Addr) me->module_core - loc;
7339 + val += (Elf_Addr) me->module_core_rw - loc;
7340 rc = apply_rela_bits(loc, val, 1, 32, 1);
7341 }
7342 break;
7343 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7344 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7345 if (info->plt_initialized == 0) {
7346 unsigned int *ip;
7347 - ip = me->module_core + me->arch.plt_offset +
7348 + ip = me->module_core_rx + me->arch.plt_offset +
7349 info->plt_offset;
7350 #ifndef CONFIG_64BIT
7351 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7352 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7353 val - loc + 0xffffUL < 0x1ffffeUL) ||
7354 (r_type == R_390_PLT32DBL &&
7355 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7356 - val = (Elf_Addr) me->module_core +
7357 + val = (Elf_Addr) me->module_core_rx +
7358 me->arch.plt_offset +
7359 info->plt_offset;
7360 val += rela->r_addend - loc;
7361 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7362 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7363 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7364 val = val + rela->r_addend -
7365 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7366 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7367 if (r_type == R_390_GOTOFF16)
7368 rc = apply_rela_bits(loc, val, 0, 16, 0);
7369 else if (r_type == R_390_GOTOFF32)
7370 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7371 break;
7372 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7373 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7374 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7375 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7376 rela->r_addend - loc;
7377 if (r_type == R_390_GOTPC)
7378 rc = apply_rela_bits(loc, val, 1, 32, 0);
7379 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7380 index 536d645..4a5bd9e 100644
7381 --- a/arch/s390/kernel/process.c
7382 +++ b/arch/s390/kernel/process.c
7383 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7384 }
7385 return 0;
7386 }
7387 -
7388 -unsigned long arch_align_stack(unsigned long sp)
7389 -{
7390 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7391 - sp -= get_random_int() & ~PAGE_MASK;
7392 - return sp & ~0xf;
7393 -}
7394 -
7395 -static inline unsigned long brk_rnd(void)
7396 -{
7397 - /* 8MB for 32bit, 1GB for 64bit */
7398 - if (is_32bit_task())
7399 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7400 - else
7401 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7402 -}
7403 -
7404 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7405 -{
7406 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7407 -
7408 - if (ret < mm->brk)
7409 - return mm->brk;
7410 - return ret;
7411 -}
7412 -
7413 -unsigned long randomize_et_dyn(unsigned long base)
7414 -{
7415 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7416 -
7417 - if (!(current->flags & PF_RANDOMIZE))
7418 - return base;
7419 - if (ret < base)
7420 - return base;
7421 - return ret;
7422 -}
7423 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7424 index 06bafec..2bca531 100644
7425 --- a/arch/s390/mm/mmap.c
7426 +++ b/arch/s390/mm/mmap.c
7427 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7428 */
7429 if (mmap_is_legacy()) {
7430 mm->mmap_base = TASK_UNMAPPED_BASE;
7431 +
7432 +#ifdef CONFIG_PAX_RANDMMAP
7433 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7434 + mm->mmap_base += mm->delta_mmap;
7435 +#endif
7436 +
7437 mm->get_unmapped_area = arch_get_unmapped_area;
7438 mm->unmap_area = arch_unmap_area;
7439 } else {
7440 mm->mmap_base = mmap_base();
7441 +
7442 +#ifdef CONFIG_PAX_RANDMMAP
7443 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7444 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7445 +#endif
7446 +
7447 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7448 mm->unmap_area = arch_unmap_area_topdown;
7449 }
7450 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7451 */
7452 if (mmap_is_legacy()) {
7453 mm->mmap_base = TASK_UNMAPPED_BASE;
7454 +
7455 +#ifdef CONFIG_PAX_RANDMMAP
7456 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7457 + mm->mmap_base += mm->delta_mmap;
7458 +#endif
7459 +
7460 mm->get_unmapped_area = s390_get_unmapped_area;
7461 mm->unmap_area = arch_unmap_area;
7462 } else {
7463 mm->mmap_base = mmap_base();
7464 +
7465 +#ifdef CONFIG_PAX_RANDMMAP
7466 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7467 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7468 +#endif
7469 +
7470 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7471 mm->unmap_area = arch_unmap_area_topdown;
7472 }
7473 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7474 index ae3d59f..f65f075 100644
7475 --- a/arch/score/include/asm/cache.h
7476 +++ b/arch/score/include/asm/cache.h
7477 @@ -1,7 +1,9 @@
7478 #ifndef _ASM_SCORE_CACHE_H
7479 #define _ASM_SCORE_CACHE_H
7480
7481 +#include <linux/const.h>
7482 +
7483 #define L1_CACHE_SHIFT 4
7484 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7485 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7486
7487 #endif /* _ASM_SCORE_CACHE_H */
7488 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7489 index f9f3cd5..58ff438 100644
7490 --- a/arch/score/include/asm/exec.h
7491 +++ b/arch/score/include/asm/exec.h
7492 @@ -1,6 +1,6 @@
7493 #ifndef _ASM_SCORE_EXEC_H
7494 #define _ASM_SCORE_EXEC_H
7495
7496 -extern unsigned long arch_align_stack(unsigned long sp);
7497 +#define arch_align_stack(x) (x)
7498
7499 #endif /* _ASM_SCORE_EXEC_H */
7500 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7501 index 7956846..5f37677 100644
7502 --- a/arch/score/kernel/process.c
7503 +++ b/arch/score/kernel/process.c
7504 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7505
7506 return task_pt_regs(task)->cp0_epc;
7507 }
7508 -
7509 -unsigned long arch_align_stack(unsigned long sp)
7510 -{
7511 - return sp;
7512 -}
7513 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7514 index ef9e555..331bd29 100644
7515 --- a/arch/sh/include/asm/cache.h
7516 +++ b/arch/sh/include/asm/cache.h
7517 @@ -9,10 +9,11 @@
7518 #define __ASM_SH_CACHE_H
7519 #ifdef __KERNEL__
7520
7521 +#include <linux/const.h>
7522 #include <linux/init.h>
7523 #include <cpu/cache.h>
7524
7525 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7526 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7527
7528 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7529
7530 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7531 index 03f2b55..b0270327 100644
7532 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7533 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7534 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7535 return NOTIFY_OK;
7536 }
7537
7538 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7539 +static struct notifier_block shx3_cpu_notifier = {
7540 .notifier_call = shx3_cpu_callback,
7541 };
7542
7543 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7544 index 6777177..cb5e44f 100644
7545 --- a/arch/sh/mm/mmap.c
7546 +++ b/arch/sh/mm/mmap.c
7547 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7548 struct mm_struct *mm = current->mm;
7549 struct vm_area_struct *vma;
7550 int do_colour_align;
7551 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7552 struct vm_unmapped_area_info info;
7553
7554 if (flags & MAP_FIXED) {
7555 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7556 if (filp || (flags & MAP_SHARED))
7557 do_colour_align = 1;
7558
7559 +#ifdef CONFIG_PAX_RANDMMAP
7560 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7561 +#endif
7562 +
7563 if (addr) {
7564 if (do_colour_align)
7565 addr = COLOUR_ALIGN(addr, pgoff);
7566 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7567 addr = PAGE_ALIGN(addr);
7568
7569 vma = find_vma(mm, addr);
7570 - if (TASK_SIZE - len >= addr &&
7571 - (!vma || addr + len <= vma->vm_start))
7572 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7573 return addr;
7574 }
7575
7576 info.flags = 0;
7577 info.length = len;
7578 - info.low_limit = TASK_UNMAPPED_BASE;
7579 + info.low_limit = mm->mmap_base;
7580 info.high_limit = TASK_SIZE;
7581 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7582 info.align_offset = pgoff << PAGE_SHIFT;
7583 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7584 struct mm_struct *mm = current->mm;
7585 unsigned long addr = addr0;
7586 int do_colour_align;
7587 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7588 struct vm_unmapped_area_info info;
7589
7590 if (flags & MAP_FIXED) {
7591 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7592 if (filp || (flags & MAP_SHARED))
7593 do_colour_align = 1;
7594
7595 +#ifdef CONFIG_PAX_RANDMMAP
7596 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7597 +#endif
7598 +
7599 /* requesting a specific address */
7600 if (addr) {
7601 if (do_colour_align)
7602 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7603 addr = PAGE_ALIGN(addr);
7604
7605 vma = find_vma(mm, addr);
7606 - if (TASK_SIZE - len >= addr &&
7607 - (!vma || addr + len <= vma->vm_start))
7608 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7609 return addr;
7610 }
7611
7612 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7613 VM_BUG_ON(addr != -ENOMEM);
7614 info.flags = 0;
7615 info.low_limit = TASK_UNMAPPED_BASE;
7616 +
7617 +#ifdef CONFIG_PAX_RANDMMAP
7618 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7619 + info.low_limit += mm->delta_mmap;
7620 +#endif
7621 +
7622 info.high_limit = TASK_SIZE;
7623 addr = vm_unmapped_area(&info);
7624 }
7625 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7626 index be56a24..443328f 100644
7627 --- a/arch/sparc/include/asm/atomic_64.h
7628 +++ b/arch/sparc/include/asm/atomic_64.h
7629 @@ -14,18 +14,40 @@
7630 #define ATOMIC64_INIT(i) { (i) }
7631
7632 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7633 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7634 +{
7635 + return v->counter;
7636 +}
7637 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7638 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7639 +{
7640 + return v->counter;
7641 +}
7642
7643 #define atomic_set(v, i) (((v)->counter) = i)
7644 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7645 +{
7646 + v->counter = i;
7647 +}
7648 #define atomic64_set(v, i) (((v)->counter) = i)
7649 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7650 +{
7651 + v->counter = i;
7652 +}
7653
7654 extern void atomic_add(int, atomic_t *);
7655 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7656 extern void atomic64_add(long, atomic64_t *);
7657 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7658 extern void atomic_sub(int, atomic_t *);
7659 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7660 extern void atomic64_sub(long, atomic64_t *);
7661 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7662
7663 extern int atomic_add_ret(int, atomic_t *);
7664 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7665 extern long atomic64_add_ret(long, atomic64_t *);
7666 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7667 extern int atomic_sub_ret(int, atomic_t *);
7668 extern long atomic64_sub_ret(long, atomic64_t *);
7669
7670 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7671 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7672
7673 #define atomic_inc_return(v) atomic_add_ret(1, v)
7674 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7675 +{
7676 + return atomic_add_ret_unchecked(1, v);
7677 +}
7678 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7679 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7680 +{
7681 + return atomic64_add_ret_unchecked(1, v);
7682 +}
7683
7684 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7685 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7686
7687 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7688 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7689 +{
7690 + return atomic_add_ret_unchecked(i, v);
7691 +}
7692 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7693 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7694 +{
7695 + return atomic64_add_ret_unchecked(i, v);
7696 +}
7697
7698 /*
7699 * atomic_inc_and_test - increment and test
7700 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7701 * other cases.
7702 */
7703 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7704 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7705 +{
7706 + return atomic_inc_return_unchecked(v) == 0;
7707 +}
7708 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7709
7710 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7711 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7712 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7713
7714 #define atomic_inc(v) atomic_add(1, v)
7715 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7716 +{
7717 + atomic_add_unchecked(1, v);
7718 +}
7719 #define atomic64_inc(v) atomic64_add(1, v)
7720 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7721 +{
7722 + atomic64_add_unchecked(1, v);
7723 +}
7724
7725 #define atomic_dec(v) atomic_sub(1, v)
7726 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7727 +{
7728 + atomic_sub_unchecked(1, v);
7729 +}
7730 #define atomic64_dec(v) atomic64_sub(1, v)
7731 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7732 +{
7733 + atomic64_sub_unchecked(1, v);
7734 +}
7735
7736 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7737 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7738
7739 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7740 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7741 +{
7742 + return cmpxchg(&v->counter, old, new);
7743 +}
7744 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7745 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7746 +{
7747 + return xchg(&v->counter, new);
7748 +}
7749
7750 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7751 {
7752 - int c, old;
7753 + int c, old, new;
7754 c = atomic_read(v);
7755 for (;;) {
7756 - if (unlikely(c == (u)))
7757 + if (unlikely(c == u))
7758 break;
7759 - old = atomic_cmpxchg((v), c, c + (a));
7760 +
7761 + asm volatile("addcc %2, %0, %0\n"
7762 +
7763 +#ifdef CONFIG_PAX_REFCOUNT
7764 + "tvs %%icc, 6\n"
7765 +#endif
7766 +
7767 + : "=r" (new)
7768 + : "0" (c), "ir" (a)
7769 + : "cc");
7770 +
7771 + old = atomic_cmpxchg(v, c, new);
7772 if (likely(old == c))
7773 break;
7774 c = old;
7775 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7776 #define atomic64_cmpxchg(v, o, n) \
7777 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7778 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7779 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7780 +{
7781 + return xchg(&v->counter, new);
7782 +}
7783
7784 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7785 {
7786 - long c, old;
7787 + long c, old, new;
7788 c = atomic64_read(v);
7789 for (;;) {
7790 - if (unlikely(c == (u)))
7791 + if (unlikely(c == u))
7792 break;
7793 - old = atomic64_cmpxchg((v), c, c + (a));
7794 +
7795 + asm volatile("addcc %2, %0, %0\n"
7796 +
7797 +#ifdef CONFIG_PAX_REFCOUNT
7798 + "tvs %%xcc, 6\n"
7799 +#endif
7800 +
7801 + : "=r" (new)
7802 + : "0" (c), "ir" (a)
7803 + : "cc");
7804 +
7805 + old = atomic64_cmpxchg(v, c, new);
7806 if (likely(old == c))
7807 break;
7808 c = old;
7809 }
7810 - return c != (u);
7811 + return c != u;
7812 }
7813
7814 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7815 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7816 index 5bb6991..5c2132e 100644
7817 --- a/arch/sparc/include/asm/cache.h
7818 +++ b/arch/sparc/include/asm/cache.h
7819 @@ -7,10 +7,12 @@
7820 #ifndef _SPARC_CACHE_H
7821 #define _SPARC_CACHE_H
7822
7823 +#include <linux/const.h>
7824 +
7825 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7826
7827 #define L1_CACHE_SHIFT 5
7828 -#define L1_CACHE_BYTES 32
7829 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7830
7831 #ifdef CONFIG_SPARC32
7832 #define SMP_CACHE_BYTES_SHIFT 5
7833 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7834 index a24e41f..47677ff 100644
7835 --- a/arch/sparc/include/asm/elf_32.h
7836 +++ b/arch/sparc/include/asm/elf_32.h
7837 @@ -114,6 +114,13 @@ typedef struct {
7838
7839 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7840
7841 +#ifdef CONFIG_PAX_ASLR
7842 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7843 +
7844 +#define PAX_DELTA_MMAP_LEN 16
7845 +#define PAX_DELTA_STACK_LEN 16
7846 +#endif
7847 +
7848 /* This yields a mask that user programs can use to figure out what
7849 instruction set this cpu supports. This can NOT be done in userspace
7850 on Sparc. */
7851 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7852 index 370ca1e..d4f4a98 100644
7853 --- a/arch/sparc/include/asm/elf_64.h
7854 +++ b/arch/sparc/include/asm/elf_64.h
7855 @@ -189,6 +189,13 @@ typedef struct {
7856 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7857 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7858
7859 +#ifdef CONFIG_PAX_ASLR
7860 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7861 +
7862 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7863 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7864 +#endif
7865 +
7866 extern unsigned long sparc64_elf_hwcap;
7867 #define ELF_HWCAP sparc64_elf_hwcap
7868
7869 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7870 index 9b1c36d..209298b 100644
7871 --- a/arch/sparc/include/asm/pgalloc_32.h
7872 +++ b/arch/sparc/include/asm/pgalloc_32.h
7873 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7874 }
7875
7876 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7877 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7878
7879 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7880 unsigned long address)
7881 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7882 index bcfe063..b333142 100644
7883 --- a/arch/sparc/include/asm/pgalloc_64.h
7884 +++ b/arch/sparc/include/asm/pgalloc_64.h
7885 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7886 }
7887
7888 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7889 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7890
7891 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7892 {
7893 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7894 index 6fc1348..390c50a 100644
7895 --- a/arch/sparc/include/asm/pgtable_32.h
7896 +++ b/arch/sparc/include/asm/pgtable_32.h
7897 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7898 #define PAGE_SHARED SRMMU_PAGE_SHARED
7899 #define PAGE_COPY SRMMU_PAGE_COPY
7900 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7901 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7902 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7903 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7904 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7905
7906 /* Top-level page directory - dummy used by init-mm.
7907 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7908
7909 /* xwr */
7910 #define __P000 PAGE_NONE
7911 -#define __P001 PAGE_READONLY
7912 -#define __P010 PAGE_COPY
7913 -#define __P011 PAGE_COPY
7914 +#define __P001 PAGE_READONLY_NOEXEC
7915 +#define __P010 PAGE_COPY_NOEXEC
7916 +#define __P011 PAGE_COPY_NOEXEC
7917 #define __P100 PAGE_READONLY
7918 #define __P101 PAGE_READONLY
7919 #define __P110 PAGE_COPY
7920 #define __P111 PAGE_COPY
7921
7922 #define __S000 PAGE_NONE
7923 -#define __S001 PAGE_READONLY
7924 -#define __S010 PAGE_SHARED
7925 -#define __S011 PAGE_SHARED
7926 +#define __S001 PAGE_READONLY_NOEXEC
7927 +#define __S010 PAGE_SHARED_NOEXEC
7928 +#define __S011 PAGE_SHARED_NOEXEC
7929 #define __S100 PAGE_READONLY
7930 #define __S101 PAGE_READONLY
7931 #define __S110 PAGE_SHARED
7932 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7933 index 79da178..c2eede8 100644
7934 --- a/arch/sparc/include/asm/pgtsrmmu.h
7935 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7936 @@ -115,6 +115,11 @@
7937 SRMMU_EXEC | SRMMU_REF)
7938 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7939 SRMMU_EXEC | SRMMU_REF)
7940 +
7941 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7942 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7943 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7944 +
7945 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7946 SRMMU_DIRTY | SRMMU_REF)
7947
7948 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
7949 index 9689176..63c18ea 100644
7950 --- a/arch/sparc/include/asm/spinlock_64.h
7951 +++ b/arch/sparc/include/asm/spinlock_64.h
7952 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
7953
7954 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
7955
7956 -static void inline arch_read_lock(arch_rwlock_t *lock)
7957 +static inline void arch_read_lock(arch_rwlock_t *lock)
7958 {
7959 unsigned long tmp1, tmp2;
7960
7961 __asm__ __volatile__ (
7962 "1: ldsw [%2], %0\n"
7963 " brlz,pn %0, 2f\n"
7964 -"4: add %0, 1, %1\n"
7965 +"4: addcc %0, 1, %1\n"
7966 +
7967 +#ifdef CONFIG_PAX_REFCOUNT
7968 +" tvs %%icc, 6\n"
7969 +#endif
7970 +
7971 " cas [%2], %0, %1\n"
7972 " cmp %0, %1\n"
7973 " bne,pn %%icc, 1b\n"
7974 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
7975 " .previous"
7976 : "=&r" (tmp1), "=&r" (tmp2)
7977 : "r" (lock)
7978 - : "memory");
7979 + : "memory", "cc");
7980 }
7981
7982 -static int inline arch_read_trylock(arch_rwlock_t *lock)
7983 +static inline int arch_read_trylock(arch_rwlock_t *lock)
7984 {
7985 int tmp1, tmp2;
7986
7987 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
7988 "1: ldsw [%2], %0\n"
7989 " brlz,a,pn %0, 2f\n"
7990 " mov 0, %0\n"
7991 -" add %0, 1, %1\n"
7992 +" addcc %0, 1, %1\n"
7993 +
7994 +#ifdef CONFIG_PAX_REFCOUNT
7995 +" tvs %%icc, 6\n"
7996 +#endif
7997 +
7998 " cas [%2], %0, %1\n"
7999 " cmp %0, %1\n"
8000 " bne,pn %%icc, 1b\n"
8001 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8002 return tmp1;
8003 }
8004
8005 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8006 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8007 {
8008 unsigned long tmp1, tmp2;
8009
8010 __asm__ __volatile__(
8011 "1: lduw [%2], %0\n"
8012 -" sub %0, 1, %1\n"
8013 +" subcc %0, 1, %1\n"
8014 +
8015 +#ifdef CONFIG_PAX_REFCOUNT
8016 +" tvs %%icc, 6\n"
8017 +#endif
8018 +
8019 " cas [%2], %0, %1\n"
8020 " cmp %0, %1\n"
8021 " bne,pn %%xcc, 1b\n"
8022 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8023 : "memory");
8024 }
8025
8026 -static void inline arch_write_lock(arch_rwlock_t *lock)
8027 +static inline void arch_write_lock(arch_rwlock_t *lock)
8028 {
8029 unsigned long mask, tmp1, tmp2;
8030
8031 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8032 : "memory");
8033 }
8034
8035 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8036 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8037 {
8038 __asm__ __volatile__(
8039 " stw %%g0, [%0]"
8040 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8041 : "memory");
8042 }
8043
8044 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8045 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8046 {
8047 unsigned long mask, tmp1, tmp2, result;
8048
8049 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8050 index 25849ae..924c54b 100644
8051 --- a/arch/sparc/include/asm/thread_info_32.h
8052 +++ b/arch/sparc/include/asm/thread_info_32.h
8053 @@ -49,6 +49,8 @@ struct thread_info {
8054 unsigned long w_saved;
8055
8056 struct restart_block restart_block;
8057 +
8058 + unsigned long lowest_stack;
8059 };
8060
8061 /*
8062 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8063 index 269bd92..e46a9b8 100644
8064 --- a/arch/sparc/include/asm/thread_info_64.h
8065 +++ b/arch/sparc/include/asm/thread_info_64.h
8066 @@ -63,6 +63,8 @@ struct thread_info {
8067 struct pt_regs *kern_una_regs;
8068 unsigned int kern_una_insn;
8069
8070 + unsigned long lowest_stack;
8071 +
8072 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8073 };
8074
8075 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8076 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8077 /* flag bit 6 is available */
8078 #define TIF_32BIT 7 /* 32-bit binary */
8079 -/* flag bit 8 is available */
8080 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8081 #define TIF_SECCOMP 9 /* secure computing */
8082 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8083 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8084 +
8085 /* NOTE: Thread flags >= 12 should be ones we have no interest
8086 * in using in assembly, else we can't use the mask as
8087 * an immediate value in instructions such as andcc.
8088 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8089 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8090 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8091 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8092 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8093
8094 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8095 _TIF_DO_NOTIFY_RESUME_MASK | \
8096 _TIF_NEED_RESCHED)
8097 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8098
8099 +#define _TIF_WORK_SYSCALL \
8100 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8101 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8102 +
8103 +
8104 /*
8105 * Thread-synchronous status.
8106 *
8107 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8108 index 0167d26..767bb0c 100644
8109 --- a/arch/sparc/include/asm/uaccess.h
8110 +++ b/arch/sparc/include/asm/uaccess.h
8111 @@ -1,5 +1,6 @@
8112 #ifndef ___ASM_SPARC_UACCESS_H
8113 #define ___ASM_SPARC_UACCESS_H
8114 +
8115 #if defined(__sparc__) && defined(__arch64__)
8116 #include <asm/uaccess_64.h>
8117 #else
8118 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8119 index 53a28dd..50c38c3 100644
8120 --- a/arch/sparc/include/asm/uaccess_32.h
8121 +++ b/arch/sparc/include/asm/uaccess_32.h
8122 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8123
8124 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8125 {
8126 - if (n && __access_ok((unsigned long) to, n))
8127 + if ((long)n < 0)
8128 + return n;
8129 +
8130 + if (n && __access_ok((unsigned long) to, n)) {
8131 + if (!__builtin_constant_p(n))
8132 + check_object_size(from, n, true);
8133 return __copy_user(to, (__force void __user *) from, n);
8134 - else
8135 + } else
8136 return n;
8137 }
8138
8139 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8140 {
8141 + if ((long)n < 0)
8142 + return n;
8143 +
8144 + if (!__builtin_constant_p(n))
8145 + check_object_size(from, n, true);
8146 +
8147 return __copy_user(to, (__force void __user *) from, n);
8148 }
8149
8150 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8151 {
8152 - if (n && __access_ok((unsigned long) from, n))
8153 + if ((long)n < 0)
8154 + return n;
8155 +
8156 + if (n && __access_ok((unsigned long) from, n)) {
8157 + if (!__builtin_constant_p(n))
8158 + check_object_size(to, n, false);
8159 return __copy_user((__force void __user *) to, from, n);
8160 - else
8161 + } else
8162 return n;
8163 }
8164
8165 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8166 {
8167 + if ((long)n < 0)
8168 + return n;
8169 +
8170 return __copy_user((__force void __user *) to, from, n);
8171 }
8172
8173 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8174 index e562d3c..191f176 100644
8175 --- a/arch/sparc/include/asm/uaccess_64.h
8176 +++ b/arch/sparc/include/asm/uaccess_64.h
8177 @@ -10,6 +10,7 @@
8178 #include <linux/compiler.h>
8179 #include <linux/string.h>
8180 #include <linux/thread_info.h>
8181 +#include <linux/kernel.h>
8182 #include <asm/asi.h>
8183 #include <asm/spitfire.h>
8184 #include <asm-generic/uaccess-unaligned.h>
8185 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8186 static inline unsigned long __must_check
8187 copy_from_user(void *to, const void __user *from, unsigned long size)
8188 {
8189 - unsigned long ret = ___copy_from_user(to, from, size);
8190 + unsigned long ret;
8191
8192 + if ((long)size < 0 || size > INT_MAX)
8193 + return size;
8194 +
8195 + if (!__builtin_constant_p(size))
8196 + check_object_size(to, size, false);
8197 +
8198 + ret = ___copy_from_user(to, from, size);
8199 if (unlikely(ret))
8200 ret = copy_from_user_fixup(to, from, size);
8201
8202 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8203 static inline unsigned long __must_check
8204 copy_to_user(void __user *to, const void *from, unsigned long size)
8205 {
8206 - unsigned long ret = ___copy_to_user(to, from, size);
8207 + unsigned long ret;
8208
8209 + if ((long)size < 0 || size > INT_MAX)
8210 + return size;
8211 +
8212 + if (!__builtin_constant_p(size))
8213 + check_object_size(from, size, true);
8214 +
8215 + ret = ___copy_to_user(to, from, size);
8216 if (unlikely(ret))
8217 ret = copy_to_user_fixup(to, from, size);
8218 return ret;
8219 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8220 index 6cf591b..b49e65a 100644
8221 --- a/arch/sparc/kernel/Makefile
8222 +++ b/arch/sparc/kernel/Makefile
8223 @@ -3,7 +3,7 @@
8224 #
8225
8226 asflags-y := -ansi
8227 -ccflags-y := -Werror
8228 +#ccflags-y := -Werror
8229
8230 extra-y := head_$(BITS).o
8231
8232 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8233 index 62eede1..9c5b904 100644
8234 --- a/arch/sparc/kernel/process_32.c
8235 +++ b/arch/sparc/kernel/process_32.c
8236 @@ -125,14 +125,14 @@ void show_regs(struct pt_regs *r)
8237
8238 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8239 r->psr, r->pc, r->npc, r->y, print_tainted());
8240 - printk("PC: <%pS>\n", (void *) r->pc);
8241 + printk("PC: <%pA>\n", (void *) r->pc);
8242 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8243 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8244 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8245 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8246 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8247 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8248 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8249 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8250
8251 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8252 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8253 @@ -167,7 +167,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8254 rw = (struct reg_window32 *) fp;
8255 pc = rw->ins[7];
8256 printk("[%08lx : ", pc);
8257 - printk("%pS ] ", (void *) pc);
8258 + printk("%pA ] ", (void *) pc);
8259 fp = rw->ins[6];
8260 } while (++count < 16);
8261 printk("\n");
8262 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8263 index cdb80b2..5ca141d 100644
8264 --- a/arch/sparc/kernel/process_64.c
8265 +++ b/arch/sparc/kernel/process_64.c
8266 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8267 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8268 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8269 if (regs->tstate & TSTATE_PRIV)
8270 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8271 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8272 }
8273
8274 void show_regs(struct pt_regs *regs)
8275 {
8276 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8277 regs->tpc, regs->tnpc, regs->y, print_tainted());
8278 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8279 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8280 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8281 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8282 regs->u_regs[3]);
8283 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8284 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8285 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8286 regs->u_regs[15]);
8287 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8288 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8289 show_regwindow(regs);
8290 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8291 }
8292 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8293 ((tp && tp->task) ? tp->task->pid : -1));
8294
8295 if (gp->tstate & TSTATE_PRIV) {
8296 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8297 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8298 (void *) gp->tpc,
8299 (void *) gp->o7,
8300 (void *) gp->i7,
8301 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8302 index 9f20566..67eb41b 100644
8303 --- a/arch/sparc/kernel/prom_common.c
8304 +++ b/arch/sparc/kernel/prom_common.c
8305 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8306
8307 unsigned int prom_early_allocated __initdata;
8308
8309 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8310 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8311 .nextprop = prom_common_nextprop,
8312 .getproplen = prom_getproplen,
8313 .getproperty = prom_getproperty,
8314 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8315 index 7ff45e4..a58f271 100644
8316 --- a/arch/sparc/kernel/ptrace_64.c
8317 +++ b/arch/sparc/kernel/ptrace_64.c
8318 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8319 return ret;
8320 }
8321
8322 +#ifdef CONFIG_GRKERNSEC_SETXID
8323 +extern void gr_delayed_cred_worker(void);
8324 +#endif
8325 +
8326 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8327 {
8328 int ret = 0;
8329 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8330 /* do the secure computing check first */
8331 secure_computing_strict(regs->u_regs[UREG_G1]);
8332
8333 +#ifdef CONFIG_GRKERNSEC_SETXID
8334 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8335 + gr_delayed_cred_worker();
8336 +#endif
8337 +
8338 if (test_thread_flag(TIF_SYSCALL_TRACE))
8339 ret = tracehook_report_syscall_entry(regs);
8340
8341 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8342
8343 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8344 {
8345 +#ifdef CONFIG_GRKERNSEC_SETXID
8346 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8347 + gr_delayed_cred_worker();
8348 +#endif
8349 +
8350 audit_syscall_exit(regs);
8351
8352 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8353 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8354 index 3a8d184..49498a8 100644
8355 --- a/arch/sparc/kernel/sys_sparc_32.c
8356 +++ b/arch/sparc/kernel/sys_sparc_32.c
8357 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8358 if (len > TASK_SIZE - PAGE_SIZE)
8359 return -ENOMEM;
8360 if (!addr)
8361 - addr = TASK_UNMAPPED_BASE;
8362 + addr = current->mm->mmap_base;
8363
8364 info.flags = 0;
8365 info.length = len;
8366 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8367 index 708bc29..6bfdfad 100644
8368 --- a/arch/sparc/kernel/sys_sparc_64.c
8369 +++ b/arch/sparc/kernel/sys_sparc_64.c
8370 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8371 struct vm_area_struct * vma;
8372 unsigned long task_size = TASK_SIZE;
8373 int do_color_align;
8374 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8375 struct vm_unmapped_area_info info;
8376
8377 if (flags & MAP_FIXED) {
8378 /* We do not accept a shared mapping if it would violate
8379 * cache aliasing constraints.
8380 */
8381 - if ((flags & MAP_SHARED) &&
8382 + if ((filp || (flags & MAP_SHARED)) &&
8383 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8384 return -EINVAL;
8385 return addr;
8386 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8387 if (filp || (flags & MAP_SHARED))
8388 do_color_align = 1;
8389
8390 +#ifdef CONFIG_PAX_RANDMMAP
8391 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8392 +#endif
8393 +
8394 if (addr) {
8395 if (do_color_align)
8396 addr = COLOR_ALIGN(addr, pgoff);
8397 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8398 addr = PAGE_ALIGN(addr);
8399
8400 vma = find_vma(mm, addr);
8401 - if (task_size - len >= addr &&
8402 - (!vma || addr + len <= vma->vm_start))
8403 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8404 return addr;
8405 }
8406
8407 info.flags = 0;
8408 info.length = len;
8409 - info.low_limit = TASK_UNMAPPED_BASE;
8410 + info.low_limit = mm->mmap_base;
8411 info.high_limit = min(task_size, VA_EXCLUDE_START);
8412 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8413 info.align_offset = pgoff << PAGE_SHIFT;
8414 + info.threadstack_offset = offset;
8415 addr = vm_unmapped_area(&info);
8416
8417 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8418 VM_BUG_ON(addr != -ENOMEM);
8419 info.low_limit = VA_EXCLUDE_END;
8420 +
8421 +#ifdef CONFIG_PAX_RANDMMAP
8422 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8423 + info.low_limit += mm->delta_mmap;
8424 +#endif
8425 +
8426 info.high_limit = task_size;
8427 addr = vm_unmapped_area(&info);
8428 }
8429 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8430 unsigned long task_size = STACK_TOP32;
8431 unsigned long addr = addr0;
8432 int do_color_align;
8433 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8434 struct vm_unmapped_area_info info;
8435
8436 /* This should only ever run for 32-bit processes. */
8437 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8438 /* We do not accept a shared mapping if it would violate
8439 * cache aliasing constraints.
8440 */
8441 - if ((flags & MAP_SHARED) &&
8442 + if ((filp || (flags & MAP_SHARED)) &&
8443 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8444 return -EINVAL;
8445 return addr;
8446 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8447 if (filp || (flags & MAP_SHARED))
8448 do_color_align = 1;
8449
8450 +#ifdef CONFIG_PAX_RANDMMAP
8451 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8452 +#endif
8453 +
8454 /* requesting a specific address */
8455 if (addr) {
8456 if (do_color_align)
8457 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8458 addr = PAGE_ALIGN(addr);
8459
8460 vma = find_vma(mm, addr);
8461 - if (task_size - len >= addr &&
8462 - (!vma || addr + len <= vma->vm_start))
8463 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8464 return addr;
8465 }
8466
8467 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8468 info.high_limit = mm->mmap_base;
8469 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8470 info.align_offset = pgoff << PAGE_SHIFT;
8471 + info.threadstack_offset = offset;
8472 addr = vm_unmapped_area(&info);
8473
8474 /*
8475 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8476 VM_BUG_ON(addr != -ENOMEM);
8477 info.flags = 0;
8478 info.low_limit = TASK_UNMAPPED_BASE;
8479 +
8480 +#ifdef CONFIG_PAX_RANDMMAP
8481 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8482 + info.low_limit += mm->delta_mmap;
8483 +#endif
8484 +
8485 info.high_limit = STACK_TOP32;
8486 addr = vm_unmapped_area(&info);
8487 }
8488 @@ -264,6 +286,10 @@ static unsigned long mmap_rnd(void)
8489 {
8490 unsigned long rnd = 0UL;
8491
8492 +#ifdef CONFIG_PAX_RANDMMAP
8493 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8494 +#endif
8495 +
8496 if (current->flags & PF_RANDOMIZE) {
8497 unsigned long val = get_random_int();
8498 if (test_thread_flag(TIF_32BIT))
8499 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8500 gap == RLIM_INFINITY ||
8501 sysctl_legacy_va_layout) {
8502 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8503 +
8504 +#ifdef CONFIG_PAX_RANDMMAP
8505 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8506 + mm->mmap_base += mm->delta_mmap;
8507 +#endif
8508 +
8509 mm->get_unmapped_area = arch_get_unmapped_area;
8510 mm->unmap_area = arch_unmap_area;
8511 } else {
8512 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8513 gap = (task_size / 6 * 5);
8514
8515 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8516 +
8517 +#ifdef CONFIG_PAX_RANDMMAP
8518 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8519 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8520 +#endif
8521 +
8522 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8523 mm->unmap_area = arch_unmap_area_topdown;
8524 }
8525 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8526 index 22a1098..6255eb9 100644
8527 --- a/arch/sparc/kernel/syscalls.S
8528 +++ b/arch/sparc/kernel/syscalls.S
8529 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8530 #endif
8531 .align 32
8532 1: ldx [%g6 + TI_FLAGS], %l5
8533 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8534 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8535 be,pt %icc, rtrap
8536 nop
8537 call syscall_trace_leave
8538 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8539
8540 srl %i5, 0, %o5 ! IEU1
8541 srl %i2, 0, %o2 ! IEU0 Group
8542 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8543 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8544 bne,pn %icc, linux_syscall_trace32 ! CTI
8545 mov %i0, %l5 ! IEU1
8546 call %l7 ! CTI Group brk forced
8547 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8548
8549 mov %i3, %o3 ! IEU1
8550 mov %i4, %o4 ! IEU0 Group
8551 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8552 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8553 bne,pn %icc, linux_syscall_trace ! CTI Group
8554 mov %i0, %l5 ! IEU0
8555 2: call %l7 ! CTI Group brk forced
8556 @@ -223,7 +223,7 @@ ret_sys_call:
8557
8558 cmp %o0, -ERESTART_RESTARTBLOCK
8559 bgeu,pn %xcc, 1f
8560 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8561 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8562 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8563
8564 2:
8565 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8566 index 654e8aa..45f431b 100644
8567 --- a/arch/sparc/kernel/sysfs.c
8568 +++ b/arch/sparc/kernel/sysfs.c
8569 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8570 return NOTIFY_OK;
8571 }
8572
8573 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8574 +static struct notifier_block sysfs_cpu_nb = {
8575 .notifier_call = sysfs_cpu_notify,
8576 };
8577
8578 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8579 index 6629829..036032d 100644
8580 --- a/arch/sparc/kernel/traps_32.c
8581 +++ b/arch/sparc/kernel/traps_32.c
8582 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8583 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8584 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8585
8586 +extern void gr_handle_kernel_exploit(void);
8587 +
8588 void die_if_kernel(char *str, struct pt_regs *regs)
8589 {
8590 static int die_counter;
8591 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8592 count++ < 30 &&
8593 (((unsigned long) rw) >= PAGE_OFFSET) &&
8594 !(((unsigned long) rw) & 0x7)) {
8595 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8596 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8597 (void *) rw->ins[7]);
8598 rw = (struct reg_window32 *)rw->ins[6];
8599 }
8600 }
8601 printk("Instruction DUMP:");
8602 instruction_dump ((unsigned long *) regs->pc);
8603 - if(regs->psr & PSR_PS)
8604 + if(regs->psr & PSR_PS) {
8605 + gr_handle_kernel_exploit();
8606 do_exit(SIGKILL);
8607 + }
8608 do_exit(SIGSEGV);
8609 }
8610
8611 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8612 index 8d38ca9..845b1d6 100644
8613 --- a/arch/sparc/kernel/traps_64.c
8614 +++ b/arch/sparc/kernel/traps_64.c
8615 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8616 i + 1,
8617 p->trapstack[i].tstate, p->trapstack[i].tpc,
8618 p->trapstack[i].tnpc, p->trapstack[i].tt);
8619 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8620 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8621 }
8622 }
8623
8624 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8625
8626 lvl -= 0x100;
8627 if (regs->tstate & TSTATE_PRIV) {
8628 +
8629 +#ifdef CONFIG_PAX_REFCOUNT
8630 + if (lvl == 6)
8631 + pax_report_refcount_overflow(regs);
8632 +#endif
8633 +
8634 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8635 die_if_kernel(buffer, regs);
8636 }
8637 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8638 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8639 {
8640 char buffer[32];
8641 -
8642 +
8643 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8644 0, lvl, SIGTRAP) == NOTIFY_STOP)
8645 return;
8646
8647 +#ifdef CONFIG_PAX_REFCOUNT
8648 + if (lvl == 6)
8649 + pax_report_refcount_overflow(regs);
8650 +#endif
8651 +
8652 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8653
8654 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8655 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8656 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8657 printk("%s" "ERROR(%d): ",
8658 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8659 - printk("TPC<%pS>\n", (void *) regs->tpc);
8660 + printk("TPC<%pA>\n", (void *) regs->tpc);
8661 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8662 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8663 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8664 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8665 smp_processor_id(),
8666 (type & 0x1) ? 'I' : 'D',
8667 regs->tpc);
8668 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8669 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8670 panic("Irrecoverable Cheetah+ parity error.");
8671 }
8672
8673 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8674 smp_processor_id(),
8675 (type & 0x1) ? 'I' : 'D',
8676 regs->tpc);
8677 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8678 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8679 }
8680
8681 struct sun4v_error_entry {
8682 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8683
8684 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8685 regs->tpc, tl);
8686 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8687 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8688 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8689 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8690 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8691 (void *) regs->u_regs[UREG_I7]);
8692 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8693 "pte[%lx] error[%lx]\n",
8694 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8695
8696 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8697 regs->tpc, tl);
8698 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8699 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8700 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8701 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8702 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8703 (void *) regs->u_regs[UREG_I7]);
8704 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8705 "pte[%lx] error[%lx]\n",
8706 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8707 fp = (unsigned long)sf->fp + STACK_BIAS;
8708 }
8709
8710 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8711 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8712 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8713 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8714 int index = tsk->curr_ret_stack;
8715 if (tsk->ret_stack && index >= graph) {
8716 pc = tsk->ret_stack[index - graph].ret;
8717 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8718 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8719 graph++;
8720 }
8721 }
8722 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8723 return (struct reg_window *) (fp + STACK_BIAS);
8724 }
8725
8726 +extern void gr_handle_kernel_exploit(void);
8727 +
8728 void die_if_kernel(char *str, struct pt_regs *regs)
8729 {
8730 static int die_counter;
8731 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8732 while (rw &&
8733 count++ < 30 &&
8734 kstack_valid(tp, (unsigned long) rw)) {
8735 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8736 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8737 (void *) rw->ins[7]);
8738
8739 rw = kernel_stack_up(rw);
8740 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8741 }
8742 user_instruction_dump ((unsigned int __user *) regs->tpc);
8743 }
8744 - if (regs->tstate & TSTATE_PRIV)
8745 + if (regs->tstate & TSTATE_PRIV) {
8746 + gr_handle_kernel_exploit();
8747 do_exit(SIGKILL);
8748 + }
8749 do_exit(SIGSEGV);
8750 }
8751 EXPORT_SYMBOL(die_if_kernel);
8752 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8753 index 8201c25e..072a2a7 100644
8754 --- a/arch/sparc/kernel/unaligned_64.c
8755 +++ b/arch/sparc/kernel/unaligned_64.c
8756 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8757 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8758
8759 if (__ratelimit(&ratelimit)) {
8760 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8761 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8762 regs->tpc, (void *) regs->tpc);
8763 }
8764 }
8765 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
8766 index eb1624b..55100de 100644
8767 --- a/arch/sparc/kernel/us3_cpufreq.c
8768 +++ b/arch/sparc/kernel/us3_cpufreq.c
8769 @@ -18,14 +18,12 @@
8770 #include <asm/head.h>
8771 #include <asm/timer.h>
8772
8773 -static struct cpufreq_driver *cpufreq_us3_driver;
8774 -
8775 struct us3_freq_percpu_info {
8776 struct cpufreq_frequency_table table[4];
8777 };
8778
8779 /* Indexed by cpu number. */
8780 -static struct us3_freq_percpu_info *us3_freq_table;
8781 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
8782
8783 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
8784 * in the Safari config register.
8785 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
8786
8787 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
8788 {
8789 - if (cpufreq_us3_driver)
8790 - us3_set_cpu_divider_index(policy->cpu, 0);
8791 + us3_set_cpu_divider_index(policy->cpu, 0);
8792
8793 return 0;
8794 }
8795
8796 +static int __init us3_freq_init(void);
8797 +static void __exit us3_freq_exit(void);
8798 +
8799 +static struct cpufreq_driver cpufreq_us3_driver = {
8800 + .init = us3_freq_cpu_init,
8801 + .verify = us3_freq_verify,
8802 + .target = us3_freq_target,
8803 + .get = us3_freq_get,
8804 + .exit = us3_freq_cpu_exit,
8805 + .owner = THIS_MODULE,
8806 + .name = "UltraSPARC-III",
8807 +
8808 +};
8809 +
8810 static int __init us3_freq_init(void)
8811 {
8812 unsigned long manuf, impl, ver;
8813 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
8814 (impl == CHEETAH_IMPL ||
8815 impl == CHEETAH_PLUS_IMPL ||
8816 impl == JAGUAR_IMPL ||
8817 - impl == PANTHER_IMPL)) {
8818 - struct cpufreq_driver *driver;
8819 -
8820 - ret = -ENOMEM;
8821 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
8822 - if (!driver)
8823 - goto err_out;
8824 -
8825 - us3_freq_table = kzalloc(
8826 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
8827 - GFP_KERNEL);
8828 - if (!us3_freq_table)
8829 - goto err_out;
8830 -
8831 - driver->init = us3_freq_cpu_init;
8832 - driver->verify = us3_freq_verify;
8833 - driver->target = us3_freq_target;
8834 - driver->get = us3_freq_get;
8835 - driver->exit = us3_freq_cpu_exit;
8836 - driver->owner = THIS_MODULE,
8837 - strcpy(driver->name, "UltraSPARC-III");
8838 -
8839 - cpufreq_us3_driver = driver;
8840 - ret = cpufreq_register_driver(driver);
8841 - if (ret)
8842 - goto err_out;
8843 -
8844 - return 0;
8845 -
8846 -err_out:
8847 - if (driver) {
8848 - kfree(driver);
8849 - cpufreq_us3_driver = NULL;
8850 - }
8851 - kfree(us3_freq_table);
8852 - us3_freq_table = NULL;
8853 - return ret;
8854 - }
8855 + impl == PANTHER_IMPL))
8856 + return cpufreq_register_driver(&cpufreq_us3_driver);
8857
8858 return -ENODEV;
8859 }
8860
8861 static void __exit us3_freq_exit(void)
8862 {
8863 - if (cpufreq_us3_driver) {
8864 - cpufreq_unregister_driver(cpufreq_us3_driver);
8865 - kfree(cpufreq_us3_driver);
8866 - cpufreq_us3_driver = NULL;
8867 - kfree(us3_freq_table);
8868 - us3_freq_table = NULL;
8869 - }
8870 + cpufreq_unregister_driver(&cpufreq_us3_driver);
8871 }
8872
8873 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
8874 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8875 index 8410065f2..4fd4ca22 100644
8876 --- a/arch/sparc/lib/Makefile
8877 +++ b/arch/sparc/lib/Makefile
8878 @@ -2,7 +2,7 @@
8879 #
8880
8881 asflags-y := -ansi -DST_DIV0=0x02
8882 -ccflags-y := -Werror
8883 +#ccflags-y := -Werror
8884
8885 lib-$(CONFIG_SPARC32) += ashrdi3.o
8886 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8887 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8888 index 85c233d..68500e0 100644
8889 --- a/arch/sparc/lib/atomic_64.S
8890 +++ b/arch/sparc/lib/atomic_64.S
8891 @@ -17,7 +17,12 @@
8892 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8893 BACKOFF_SETUP(%o2)
8894 1: lduw [%o1], %g1
8895 - add %g1, %o0, %g7
8896 + addcc %g1, %o0, %g7
8897 +
8898 +#ifdef CONFIG_PAX_REFCOUNT
8899 + tvs %icc, 6
8900 +#endif
8901 +
8902 cas [%o1], %g1, %g7
8903 cmp %g1, %g7
8904 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8905 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8906 2: BACKOFF_SPIN(%o2, %o3, 1b)
8907 ENDPROC(atomic_add)
8908
8909 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8910 + BACKOFF_SETUP(%o2)
8911 +1: lduw [%o1], %g1
8912 + add %g1, %o0, %g7
8913 + cas [%o1], %g1, %g7
8914 + cmp %g1, %g7
8915 + bne,pn %icc, 2f
8916 + nop
8917 + retl
8918 + nop
8919 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8920 +ENDPROC(atomic_add_unchecked)
8921 +
8922 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8923 BACKOFF_SETUP(%o2)
8924 1: lduw [%o1], %g1
8925 - sub %g1, %o0, %g7
8926 + subcc %g1, %o0, %g7
8927 +
8928 +#ifdef CONFIG_PAX_REFCOUNT
8929 + tvs %icc, 6
8930 +#endif
8931 +
8932 cas [%o1], %g1, %g7
8933 cmp %g1, %g7
8934 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8935 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8936 2: BACKOFF_SPIN(%o2, %o3, 1b)
8937 ENDPROC(atomic_sub)
8938
8939 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8940 + BACKOFF_SETUP(%o2)
8941 +1: lduw [%o1], %g1
8942 + sub %g1, %o0, %g7
8943 + cas [%o1], %g1, %g7
8944 + cmp %g1, %g7
8945 + bne,pn %icc, 2f
8946 + nop
8947 + retl
8948 + nop
8949 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8950 +ENDPROC(atomic_sub_unchecked)
8951 +
8952 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8953 BACKOFF_SETUP(%o2)
8954 1: lduw [%o1], %g1
8955 - add %g1, %o0, %g7
8956 + addcc %g1, %o0, %g7
8957 +
8958 +#ifdef CONFIG_PAX_REFCOUNT
8959 + tvs %icc, 6
8960 +#endif
8961 +
8962 cas [%o1], %g1, %g7
8963 cmp %g1, %g7
8964 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8965 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8966 2: BACKOFF_SPIN(%o2, %o3, 1b)
8967 ENDPROC(atomic_add_ret)
8968
8969 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8970 + BACKOFF_SETUP(%o2)
8971 +1: lduw [%o1], %g1
8972 + addcc %g1, %o0, %g7
8973 + cas [%o1], %g1, %g7
8974 + cmp %g1, %g7
8975 + bne,pn %icc, 2f
8976 + add %g7, %o0, %g7
8977 + sra %g7, 0, %o0
8978 + retl
8979 + nop
8980 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8981 +ENDPROC(atomic_add_ret_unchecked)
8982 +
8983 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
8984 BACKOFF_SETUP(%o2)
8985 1: lduw [%o1], %g1
8986 - sub %g1, %o0, %g7
8987 + subcc %g1, %o0, %g7
8988 +
8989 +#ifdef CONFIG_PAX_REFCOUNT
8990 + tvs %icc, 6
8991 +#endif
8992 +
8993 cas [%o1], %g1, %g7
8994 cmp %g1, %g7
8995 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8996 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
8997 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8998 BACKOFF_SETUP(%o2)
8999 1: ldx [%o1], %g1
9000 - add %g1, %o0, %g7
9001 + addcc %g1, %o0, %g7
9002 +
9003 +#ifdef CONFIG_PAX_REFCOUNT
9004 + tvs %xcc, 6
9005 +#endif
9006 +
9007 casx [%o1], %g1, %g7
9008 cmp %g1, %g7
9009 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9010 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9011 2: BACKOFF_SPIN(%o2, %o3, 1b)
9012 ENDPROC(atomic64_add)
9013
9014 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9015 + BACKOFF_SETUP(%o2)
9016 +1: ldx [%o1], %g1
9017 + addcc %g1, %o0, %g7
9018 + casx [%o1], %g1, %g7
9019 + cmp %g1, %g7
9020 + bne,pn %xcc, 2f
9021 + nop
9022 + retl
9023 + nop
9024 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9025 +ENDPROC(atomic64_add_unchecked)
9026 +
9027 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9028 BACKOFF_SETUP(%o2)
9029 1: ldx [%o1], %g1
9030 - sub %g1, %o0, %g7
9031 + subcc %g1, %o0, %g7
9032 +
9033 +#ifdef CONFIG_PAX_REFCOUNT
9034 + tvs %xcc, 6
9035 +#endif
9036 +
9037 casx [%o1], %g1, %g7
9038 cmp %g1, %g7
9039 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9040 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9041 2: BACKOFF_SPIN(%o2, %o3, 1b)
9042 ENDPROC(atomic64_sub)
9043
9044 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9045 + BACKOFF_SETUP(%o2)
9046 +1: ldx [%o1], %g1
9047 + subcc %g1, %o0, %g7
9048 + casx [%o1], %g1, %g7
9049 + cmp %g1, %g7
9050 + bne,pn %xcc, 2f
9051 + nop
9052 + retl
9053 + nop
9054 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9055 +ENDPROC(atomic64_sub_unchecked)
9056 +
9057 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9058 BACKOFF_SETUP(%o2)
9059 1: ldx [%o1], %g1
9060 - add %g1, %o0, %g7
9061 + addcc %g1, %o0, %g7
9062 +
9063 +#ifdef CONFIG_PAX_REFCOUNT
9064 + tvs %xcc, 6
9065 +#endif
9066 +
9067 casx [%o1], %g1, %g7
9068 cmp %g1, %g7
9069 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9070 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9071 2: BACKOFF_SPIN(%o2, %o3, 1b)
9072 ENDPROC(atomic64_add_ret)
9073
9074 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9075 + BACKOFF_SETUP(%o2)
9076 +1: ldx [%o1], %g1
9077 + addcc %g1, %o0, %g7
9078 + casx [%o1], %g1, %g7
9079 + cmp %g1, %g7
9080 + bne,pn %xcc, 2f
9081 + add %g7, %o0, %g7
9082 + mov %g7, %o0
9083 + retl
9084 + nop
9085 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9086 +ENDPROC(atomic64_add_ret_unchecked)
9087 +
9088 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9089 BACKOFF_SETUP(%o2)
9090 1: ldx [%o1], %g1
9091 - sub %g1, %o0, %g7
9092 + subcc %g1, %o0, %g7
9093 +
9094 +#ifdef CONFIG_PAX_REFCOUNT
9095 + tvs %xcc, 6
9096 +#endif
9097 +
9098 casx [%o1], %g1, %g7
9099 cmp %g1, %g7
9100 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9101 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9102 index 0c4e35e..745d3e4 100644
9103 --- a/arch/sparc/lib/ksyms.c
9104 +++ b/arch/sparc/lib/ksyms.c
9105 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9106
9107 /* Atomic counter implementation. */
9108 EXPORT_SYMBOL(atomic_add);
9109 +EXPORT_SYMBOL(atomic_add_unchecked);
9110 EXPORT_SYMBOL(atomic_add_ret);
9111 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9112 EXPORT_SYMBOL(atomic_sub);
9113 +EXPORT_SYMBOL(atomic_sub_unchecked);
9114 EXPORT_SYMBOL(atomic_sub_ret);
9115 EXPORT_SYMBOL(atomic64_add);
9116 +EXPORT_SYMBOL(atomic64_add_unchecked);
9117 EXPORT_SYMBOL(atomic64_add_ret);
9118 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9119 EXPORT_SYMBOL(atomic64_sub);
9120 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9121 EXPORT_SYMBOL(atomic64_sub_ret);
9122 EXPORT_SYMBOL(atomic64_dec_if_positive);
9123
9124 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9125 index 30c3ecc..736f015 100644
9126 --- a/arch/sparc/mm/Makefile
9127 +++ b/arch/sparc/mm/Makefile
9128 @@ -2,7 +2,7 @@
9129 #
9130
9131 asflags-y := -ansi
9132 -ccflags-y := -Werror
9133 +#ccflags-y := -Werror
9134
9135 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9136 obj-y += fault_$(BITS).o
9137 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9138 index e98bfda..ea8d221 100644
9139 --- a/arch/sparc/mm/fault_32.c
9140 +++ b/arch/sparc/mm/fault_32.c
9141 @@ -21,6 +21,9 @@
9142 #include <linux/perf_event.h>
9143 #include <linux/interrupt.h>
9144 #include <linux/kdebug.h>
9145 +#include <linux/slab.h>
9146 +#include <linux/pagemap.h>
9147 +#include <linux/compiler.h>
9148
9149 #include <asm/page.h>
9150 #include <asm/pgtable.h>
9151 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9152 return safe_compute_effective_address(regs, insn);
9153 }
9154
9155 +#ifdef CONFIG_PAX_PAGEEXEC
9156 +#ifdef CONFIG_PAX_DLRESOLVE
9157 +static void pax_emuplt_close(struct vm_area_struct *vma)
9158 +{
9159 + vma->vm_mm->call_dl_resolve = 0UL;
9160 +}
9161 +
9162 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9163 +{
9164 + unsigned int *kaddr;
9165 +
9166 + vmf->page = alloc_page(GFP_HIGHUSER);
9167 + if (!vmf->page)
9168 + return VM_FAULT_OOM;
9169 +
9170 + kaddr = kmap(vmf->page);
9171 + memset(kaddr, 0, PAGE_SIZE);
9172 + kaddr[0] = 0x9DE3BFA8U; /* save */
9173 + flush_dcache_page(vmf->page);
9174 + kunmap(vmf->page);
9175 + return VM_FAULT_MAJOR;
9176 +}
9177 +
9178 +static const struct vm_operations_struct pax_vm_ops = {
9179 + .close = pax_emuplt_close,
9180 + .fault = pax_emuplt_fault
9181 +};
9182 +
9183 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9184 +{
9185 + int ret;
9186 +
9187 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9188 + vma->vm_mm = current->mm;
9189 + vma->vm_start = addr;
9190 + vma->vm_end = addr + PAGE_SIZE;
9191 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9192 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9193 + vma->vm_ops = &pax_vm_ops;
9194 +
9195 + ret = insert_vm_struct(current->mm, vma);
9196 + if (ret)
9197 + return ret;
9198 +
9199 + ++current->mm->total_vm;
9200 + return 0;
9201 +}
9202 +#endif
9203 +
9204 +/*
9205 + * PaX: decide what to do with offenders (regs->pc = fault address)
9206 + *
9207 + * returns 1 when task should be killed
9208 + * 2 when patched PLT trampoline was detected
9209 + * 3 when unpatched PLT trampoline was detected
9210 + */
9211 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9212 +{
9213 +
9214 +#ifdef CONFIG_PAX_EMUPLT
9215 + int err;
9216 +
9217 + do { /* PaX: patched PLT emulation #1 */
9218 + unsigned int sethi1, sethi2, jmpl;
9219 +
9220 + err = get_user(sethi1, (unsigned int *)regs->pc);
9221 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9222 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9223 +
9224 + if (err)
9225 + break;
9226 +
9227 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9228 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9229 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9230 + {
9231 + unsigned int addr;
9232 +
9233 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9234 + addr = regs->u_regs[UREG_G1];
9235 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9236 + regs->pc = addr;
9237 + regs->npc = addr+4;
9238 + return 2;
9239 + }
9240 + } while (0);
9241 +
9242 + do { /* PaX: patched PLT emulation #2 */
9243 + unsigned int ba;
9244 +
9245 + err = get_user(ba, (unsigned int *)regs->pc);
9246 +
9247 + if (err)
9248 + break;
9249 +
9250 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9251 + unsigned int addr;
9252 +
9253 + if ((ba & 0xFFC00000U) == 0x30800000U)
9254 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9255 + else
9256 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9257 + regs->pc = addr;
9258 + regs->npc = addr+4;
9259 + return 2;
9260 + }
9261 + } while (0);
9262 +
9263 + do { /* PaX: patched PLT emulation #3 */
9264 + unsigned int sethi, bajmpl, nop;
9265 +
9266 + err = get_user(sethi, (unsigned int *)regs->pc);
9267 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9268 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9269 +
9270 + if (err)
9271 + break;
9272 +
9273 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9274 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9275 + nop == 0x01000000U)
9276 + {
9277 + unsigned int addr;
9278 +
9279 + addr = (sethi & 0x003FFFFFU) << 10;
9280 + regs->u_regs[UREG_G1] = addr;
9281 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9282 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9283 + else
9284 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9285 + regs->pc = addr;
9286 + regs->npc = addr+4;
9287 + return 2;
9288 + }
9289 + } while (0);
9290 +
9291 + do { /* PaX: unpatched PLT emulation step 1 */
9292 + unsigned int sethi, ba, nop;
9293 +
9294 + err = get_user(sethi, (unsigned int *)regs->pc);
9295 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9296 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9297 +
9298 + if (err)
9299 + break;
9300 +
9301 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9302 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9303 + nop == 0x01000000U)
9304 + {
9305 + unsigned int addr, save, call;
9306 +
9307 + if ((ba & 0xFFC00000U) == 0x30800000U)
9308 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9309 + else
9310 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9311 +
9312 + err = get_user(save, (unsigned int *)addr);
9313 + err |= get_user(call, (unsigned int *)(addr+4));
9314 + err |= get_user(nop, (unsigned int *)(addr+8));
9315 + if (err)
9316 + break;
9317 +
9318 +#ifdef CONFIG_PAX_DLRESOLVE
9319 + if (save == 0x9DE3BFA8U &&
9320 + (call & 0xC0000000U) == 0x40000000U &&
9321 + nop == 0x01000000U)
9322 + {
9323 + struct vm_area_struct *vma;
9324 + unsigned long call_dl_resolve;
9325 +
9326 + down_read(&current->mm->mmap_sem);
9327 + call_dl_resolve = current->mm->call_dl_resolve;
9328 + up_read(&current->mm->mmap_sem);
9329 + if (likely(call_dl_resolve))
9330 + goto emulate;
9331 +
9332 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9333 +
9334 + down_write(&current->mm->mmap_sem);
9335 + if (current->mm->call_dl_resolve) {
9336 + call_dl_resolve = current->mm->call_dl_resolve;
9337 + up_write(&current->mm->mmap_sem);
9338 + if (vma)
9339 + kmem_cache_free(vm_area_cachep, vma);
9340 + goto emulate;
9341 + }
9342 +
9343 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9344 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9345 + up_write(&current->mm->mmap_sem);
9346 + if (vma)
9347 + kmem_cache_free(vm_area_cachep, vma);
9348 + return 1;
9349 + }
9350 +
9351 + if (pax_insert_vma(vma, call_dl_resolve)) {
9352 + up_write(&current->mm->mmap_sem);
9353 + kmem_cache_free(vm_area_cachep, vma);
9354 + return 1;
9355 + }
9356 +
9357 + current->mm->call_dl_resolve = call_dl_resolve;
9358 + up_write(&current->mm->mmap_sem);
9359 +
9360 +emulate:
9361 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9362 + regs->pc = call_dl_resolve;
9363 + regs->npc = addr+4;
9364 + return 3;
9365 + }
9366 +#endif
9367 +
9368 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9369 + if ((save & 0xFFC00000U) == 0x05000000U &&
9370 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9371 + nop == 0x01000000U)
9372 + {
9373 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9374 + regs->u_regs[UREG_G2] = addr + 4;
9375 + addr = (save & 0x003FFFFFU) << 10;
9376 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9377 + regs->pc = addr;
9378 + regs->npc = addr+4;
9379 + return 3;
9380 + }
9381 + }
9382 + } while (0);
9383 +
9384 + do { /* PaX: unpatched PLT emulation step 2 */
9385 + unsigned int save, call, nop;
9386 +
9387 + err = get_user(save, (unsigned int *)(regs->pc-4));
9388 + err |= get_user(call, (unsigned int *)regs->pc);
9389 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9390 + if (err)
9391 + break;
9392 +
9393 + if (save == 0x9DE3BFA8U &&
9394 + (call & 0xC0000000U) == 0x40000000U &&
9395 + nop == 0x01000000U)
9396 + {
9397 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9398 +
9399 + regs->u_regs[UREG_RETPC] = regs->pc;
9400 + regs->pc = dl_resolve;
9401 + regs->npc = dl_resolve+4;
9402 + return 3;
9403 + }
9404 + } while (0);
9405 +#endif
9406 +
9407 + return 1;
9408 +}
9409 +
9410 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9411 +{
9412 + unsigned long i;
9413 +
9414 + printk(KERN_ERR "PAX: bytes at PC: ");
9415 + for (i = 0; i < 8; i++) {
9416 + unsigned int c;
9417 + if (get_user(c, (unsigned int *)pc+i))
9418 + printk(KERN_CONT "???????? ");
9419 + else
9420 + printk(KERN_CONT "%08x ", c);
9421 + }
9422 + printk("\n");
9423 +}
9424 +#endif
9425 +
9426 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9427 int text_fault)
9428 {
9429 @@ -230,6 +504,24 @@ good_area:
9430 if (!(vma->vm_flags & VM_WRITE))
9431 goto bad_area;
9432 } else {
9433 +
9434 +#ifdef CONFIG_PAX_PAGEEXEC
9435 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9436 + up_read(&mm->mmap_sem);
9437 + switch (pax_handle_fetch_fault(regs)) {
9438 +
9439 +#ifdef CONFIG_PAX_EMUPLT
9440 + case 2:
9441 + case 3:
9442 + return;
9443 +#endif
9444 +
9445 + }
9446 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9447 + do_group_exit(SIGKILL);
9448 + }
9449 +#endif
9450 +
9451 /* Allow reads even for write-only mappings */
9452 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9453 goto bad_area;
9454 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9455 index 5062ff3..e0b75f3 100644
9456 --- a/arch/sparc/mm/fault_64.c
9457 +++ b/arch/sparc/mm/fault_64.c
9458 @@ -21,6 +21,9 @@
9459 #include <linux/kprobes.h>
9460 #include <linux/kdebug.h>
9461 #include <linux/percpu.h>
9462 +#include <linux/slab.h>
9463 +#include <linux/pagemap.h>
9464 +#include <linux/compiler.h>
9465
9466 #include <asm/page.h>
9467 #include <asm/pgtable.h>
9468 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9469 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9470 regs->tpc);
9471 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9472 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9473 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9474 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9475 dump_stack();
9476 unhandled_fault(regs->tpc, current, regs);
9477 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9478 show_regs(regs);
9479 }
9480
9481 +#ifdef CONFIG_PAX_PAGEEXEC
9482 +#ifdef CONFIG_PAX_DLRESOLVE
9483 +static void pax_emuplt_close(struct vm_area_struct *vma)
9484 +{
9485 + vma->vm_mm->call_dl_resolve = 0UL;
9486 +}
9487 +
9488 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9489 +{
9490 + unsigned int *kaddr;
9491 +
9492 + vmf->page = alloc_page(GFP_HIGHUSER);
9493 + if (!vmf->page)
9494 + return VM_FAULT_OOM;
9495 +
9496 + kaddr = kmap(vmf->page);
9497 + memset(kaddr, 0, PAGE_SIZE);
9498 + kaddr[0] = 0x9DE3BFA8U; /* save */
9499 + flush_dcache_page(vmf->page);
9500 + kunmap(vmf->page);
9501 + return VM_FAULT_MAJOR;
9502 +}
9503 +
9504 +static const struct vm_operations_struct pax_vm_ops = {
9505 + .close = pax_emuplt_close,
9506 + .fault = pax_emuplt_fault
9507 +};
9508 +
9509 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9510 +{
9511 + int ret;
9512 +
9513 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9514 + vma->vm_mm = current->mm;
9515 + vma->vm_start = addr;
9516 + vma->vm_end = addr + PAGE_SIZE;
9517 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9518 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9519 + vma->vm_ops = &pax_vm_ops;
9520 +
9521 + ret = insert_vm_struct(current->mm, vma);
9522 + if (ret)
9523 + return ret;
9524 +
9525 + ++current->mm->total_vm;
9526 + return 0;
9527 +}
9528 +#endif
9529 +
9530 +/*
9531 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9532 + *
9533 + * returns 1 when task should be killed
9534 + * 2 when patched PLT trampoline was detected
9535 + * 3 when unpatched PLT trampoline was detected
9536 + */
9537 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9538 +{
9539 +
9540 +#ifdef CONFIG_PAX_EMUPLT
9541 + int err;
9542 +
9543 + do { /* PaX: patched PLT emulation #1 */
9544 + unsigned int sethi1, sethi2, jmpl;
9545 +
9546 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9547 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9548 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9549 +
9550 + if (err)
9551 + break;
9552 +
9553 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9554 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9555 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9556 + {
9557 + unsigned long addr;
9558 +
9559 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9560 + addr = regs->u_regs[UREG_G1];
9561 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9562 +
9563 + if (test_thread_flag(TIF_32BIT))
9564 + addr &= 0xFFFFFFFFUL;
9565 +
9566 + regs->tpc = addr;
9567 + regs->tnpc = addr+4;
9568 + return 2;
9569 + }
9570 + } while (0);
9571 +
9572 + do { /* PaX: patched PLT emulation #2 */
9573 + unsigned int ba;
9574 +
9575 + err = get_user(ba, (unsigned int *)regs->tpc);
9576 +
9577 + if (err)
9578 + break;
9579 +
9580 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9581 + unsigned long addr;
9582 +
9583 + if ((ba & 0xFFC00000U) == 0x30800000U)
9584 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9585 + else
9586 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9587 +
9588 + if (test_thread_flag(TIF_32BIT))
9589 + addr &= 0xFFFFFFFFUL;
9590 +
9591 + regs->tpc = addr;
9592 + regs->tnpc = addr+4;
9593 + return 2;
9594 + }
9595 + } while (0);
9596 +
9597 + do { /* PaX: patched PLT emulation #3 */
9598 + unsigned int sethi, bajmpl, nop;
9599 +
9600 + err = get_user(sethi, (unsigned int *)regs->tpc);
9601 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9602 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9603 +
9604 + if (err)
9605 + break;
9606 +
9607 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9608 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9609 + nop == 0x01000000U)
9610 + {
9611 + unsigned long addr;
9612 +
9613 + addr = (sethi & 0x003FFFFFU) << 10;
9614 + regs->u_regs[UREG_G1] = addr;
9615 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9616 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9617 + else
9618 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9619 +
9620 + if (test_thread_flag(TIF_32BIT))
9621 + addr &= 0xFFFFFFFFUL;
9622 +
9623 + regs->tpc = addr;
9624 + regs->tnpc = addr+4;
9625 + return 2;
9626 + }
9627 + } while (0);
9628 +
9629 + do { /* PaX: patched PLT emulation #4 */
9630 + unsigned int sethi, mov1, call, mov2;
9631 +
9632 + err = get_user(sethi, (unsigned int *)regs->tpc);
9633 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9634 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9635 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9636 +
9637 + if (err)
9638 + break;
9639 +
9640 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9641 + mov1 == 0x8210000FU &&
9642 + (call & 0xC0000000U) == 0x40000000U &&
9643 + mov2 == 0x9E100001U)
9644 + {
9645 + unsigned long addr;
9646 +
9647 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9648 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9649 +
9650 + if (test_thread_flag(TIF_32BIT))
9651 + addr &= 0xFFFFFFFFUL;
9652 +
9653 + regs->tpc = addr;
9654 + regs->tnpc = addr+4;
9655 + return 2;
9656 + }
9657 + } while (0);
9658 +
9659 + do { /* PaX: patched PLT emulation #5 */
9660 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9661 +
9662 + err = get_user(sethi, (unsigned int *)regs->tpc);
9663 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9664 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9665 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9666 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9667 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9668 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9669 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9670 +
9671 + if (err)
9672 + break;
9673 +
9674 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9675 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9676 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9677 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9678 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9679 + sllx == 0x83287020U &&
9680 + jmpl == 0x81C04005U &&
9681 + nop == 0x01000000U)
9682 + {
9683 + unsigned long addr;
9684 +
9685 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9686 + regs->u_regs[UREG_G1] <<= 32;
9687 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9688 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9689 + regs->tpc = addr;
9690 + regs->tnpc = addr+4;
9691 + return 2;
9692 + }
9693 + } while (0);
9694 +
9695 + do { /* PaX: patched PLT emulation #6 */
9696 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9697 +
9698 + err = get_user(sethi, (unsigned int *)regs->tpc);
9699 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9700 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9701 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9702 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9703 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9704 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9705 +
9706 + if (err)
9707 + break;
9708 +
9709 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9710 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9711 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9712 + sllx == 0x83287020U &&
9713 + (or & 0xFFFFE000U) == 0x8A116000U &&
9714 + jmpl == 0x81C04005U &&
9715 + nop == 0x01000000U)
9716 + {
9717 + unsigned long addr;
9718 +
9719 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9720 + regs->u_regs[UREG_G1] <<= 32;
9721 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9722 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9723 + regs->tpc = addr;
9724 + regs->tnpc = addr+4;
9725 + return 2;
9726 + }
9727 + } while (0);
9728 +
9729 + do { /* PaX: unpatched PLT emulation step 1 */
9730 + unsigned int sethi, ba, nop;
9731 +
9732 + err = get_user(sethi, (unsigned int *)regs->tpc);
9733 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9734 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9735 +
9736 + if (err)
9737 + break;
9738 +
9739 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9740 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9741 + nop == 0x01000000U)
9742 + {
9743 + unsigned long addr;
9744 + unsigned int save, call;
9745 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9746 +
9747 + if ((ba & 0xFFC00000U) == 0x30800000U)
9748 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9749 + else
9750 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9751 +
9752 + if (test_thread_flag(TIF_32BIT))
9753 + addr &= 0xFFFFFFFFUL;
9754 +
9755 + err = get_user(save, (unsigned int *)addr);
9756 + err |= get_user(call, (unsigned int *)(addr+4));
9757 + err |= get_user(nop, (unsigned int *)(addr+8));
9758 + if (err)
9759 + break;
9760 +
9761 +#ifdef CONFIG_PAX_DLRESOLVE
9762 + if (save == 0x9DE3BFA8U &&
9763 + (call & 0xC0000000U) == 0x40000000U &&
9764 + nop == 0x01000000U)
9765 + {
9766 + struct vm_area_struct *vma;
9767 + unsigned long call_dl_resolve;
9768 +
9769 + down_read(&current->mm->mmap_sem);
9770 + call_dl_resolve = current->mm->call_dl_resolve;
9771 + up_read(&current->mm->mmap_sem);
9772 + if (likely(call_dl_resolve))
9773 + goto emulate;
9774 +
9775 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9776 +
9777 + down_write(&current->mm->mmap_sem);
9778 + if (current->mm->call_dl_resolve) {
9779 + call_dl_resolve = current->mm->call_dl_resolve;
9780 + up_write(&current->mm->mmap_sem);
9781 + if (vma)
9782 + kmem_cache_free(vm_area_cachep, vma);
9783 + goto emulate;
9784 + }
9785 +
9786 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9787 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9788 + up_write(&current->mm->mmap_sem);
9789 + if (vma)
9790 + kmem_cache_free(vm_area_cachep, vma);
9791 + return 1;
9792 + }
9793 +
9794 + if (pax_insert_vma(vma, call_dl_resolve)) {
9795 + up_write(&current->mm->mmap_sem);
9796 + kmem_cache_free(vm_area_cachep, vma);
9797 + return 1;
9798 + }
9799 +
9800 + current->mm->call_dl_resolve = call_dl_resolve;
9801 + up_write(&current->mm->mmap_sem);
9802 +
9803 +emulate:
9804 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9805 + regs->tpc = call_dl_resolve;
9806 + regs->tnpc = addr+4;
9807 + return 3;
9808 + }
9809 +#endif
9810 +
9811 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9812 + if ((save & 0xFFC00000U) == 0x05000000U &&
9813 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9814 + nop == 0x01000000U)
9815 + {
9816 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9817 + regs->u_regs[UREG_G2] = addr + 4;
9818 + addr = (save & 0x003FFFFFU) << 10;
9819 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9820 +
9821 + if (test_thread_flag(TIF_32BIT))
9822 + addr &= 0xFFFFFFFFUL;
9823 +
9824 + regs->tpc = addr;
9825 + regs->tnpc = addr+4;
9826 + return 3;
9827 + }
9828 +
9829 + /* PaX: 64-bit PLT stub */
9830 + err = get_user(sethi1, (unsigned int *)addr);
9831 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9832 + err |= get_user(or1, (unsigned int *)(addr+8));
9833 + err |= get_user(or2, (unsigned int *)(addr+12));
9834 + err |= get_user(sllx, (unsigned int *)(addr+16));
9835 + err |= get_user(add, (unsigned int *)(addr+20));
9836 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9837 + err |= get_user(nop, (unsigned int *)(addr+28));
9838 + if (err)
9839 + break;
9840 +
9841 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9842 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9843 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9844 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9845 + sllx == 0x89293020U &&
9846 + add == 0x8A010005U &&
9847 + jmpl == 0x89C14000U &&
9848 + nop == 0x01000000U)
9849 + {
9850 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9851 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9852 + regs->u_regs[UREG_G4] <<= 32;
9853 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9854 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9855 + regs->u_regs[UREG_G4] = addr + 24;
9856 + addr = regs->u_regs[UREG_G5];
9857 + regs->tpc = addr;
9858 + regs->tnpc = addr+4;
9859 + return 3;
9860 + }
9861 + }
9862 + } while (0);
9863 +
9864 +#ifdef CONFIG_PAX_DLRESOLVE
9865 + do { /* PaX: unpatched PLT emulation step 2 */
9866 + unsigned int save, call, nop;
9867 +
9868 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9869 + err |= get_user(call, (unsigned int *)regs->tpc);
9870 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9871 + if (err)
9872 + break;
9873 +
9874 + if (save == 0x9DE3BFA8U &&
9875 + (call & 0xC0000000U) == 0x40000000U &&
9876 + nop == 0x01000000U)
9877 + {
9878 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9879 +
9880 + if (test_thread_flag(TIF_32BIT))
9881 + dl_resolve &= 0xFFFFFFFFUL;
9882 +
9883 + regs->u_regs[UREG_RETPC] = regs->tpc;
9884 + regs->tpc = dl_resolve;
9885 + regs->tnpc = dl_resolve+4;
9886 + return 3;
9887 + }
9888 + } while (0);
9889 +#endif
9890 +
9891 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9892 + unsigned int sethi, ba, nop;
9893 +
9894 + err = get_user(sethi, (unsigned int *)regs->tpc);
9895 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9896 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9897 +
9898 + if (err)
9899 + break;
9900 +
9901 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9902 + (ba & 0xFFF00000U) == 0x30600000U &&
9903 + nop == 0x01000000U)
9904 + {
9905 + unsigned long addr;
9906 +
9907 + addr = (sethi & 0x003FFFFFU) << 10;
9908 + regs->u_regs[UREG_G1] = addr;
9909 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9910 +
9911 + if (test_thread_flag(TIF_32BIT))
9912 + addr &= 0xFFFFFFFFUL;
9913 +
9914 + regs->tpc = addr;
9915 + regs->tnpc = addr+4;
9916 + return 2;
9917 + }
9918 + } while (0);
9919 +
9920 +#endif
9921 +
9922 + return 1;
9923 +}
9924 +
9925 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9926 +{
9927 + unsigned long i;
9928 +
9929 + printk(KERN_ERR "PAX: bytes at PC: ");
9930 + for (i = 0; i < 8; i++) {
9931 + unsigned int c;
9932 + if (get_user(c, (unsigned int *)pc+i))
9933 + printk(KERN_CONT "???????? ");
9934 + else
9935 + printk(KERN_CONT "%08x ", c);
9936 + }
9937 + printk("\n");
9938 +}
9939 +#endif
9940 +
9941 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9942 {
9943 struct mm_struct *mm = current->mm;
9944 @@ -341,6 +804,29 @@ retry:
9945 if (!vma)
9946 goto bad_area;
9947
9948 +#ifdef CONFIG_PAX_PAGEEXEC
9949 + /* PaX: detect ITLB misses on non-exec pages */
9950 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9951 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9952 + {
9953 + if (address != regs->tpc)
9954 + goto good_area;
9955 +
9956 + up_read(&mm->mmap_sem);
9957 + switch (pax_handle_fetch_fault(regs)) {
9958 +
9959 +#ifdef CONFIG_PAX_EMUPLT
9960 + case 2:
9961 + case 3:
9962 + return;
9963 +#endif
9964 +
9965 + }
9966 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9967 + do_group_exit(SIGKILL);
9968 + }
9969 +#endif
9970 +
9971 /* Pure DTLB misses do not tell us whether the fault causing
9972 * load/store/atomic was a write or not, it only says that there
9973 * was no match. So in such a case we (carefully) read the
9974 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9975 index d2b5944..bd813f2 100644
9976 --- a/arch/sparc/mm/hugetlbpage.c
9977 +++ b/arch/sparc/mm/hugetlbpage.c
9978 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9979
9980 info.flags = 0;
9981 info.length = len;
9982 - info.low_limit = TASK_UNMAPPED_BASE;
9983 + info.low_limit = mm->mmap_base;
9984 info.high_limit = min(task_size, VA_EXCLUDE_START);
9985 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
9986 info.align_offset = 0;
9987 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9988 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9989 VM_BUG_ON(addr != -ENOMEM);
9990 info.low_limit = VA_EXCLUDE_END;
9991 +
9992 +#ifdef CONFIG_PAX_RANDMMAP
9993 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9994 + info.low_limit += mm->delta_mmap;
9995 +#endif
9996 +
9997 info.high_limit = task_size;
9998 addr = vm_unmapped_area(&info);
9999 }
10000 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10001 VM_BUG_ON(addr != -ENOMEM);
10002 info.flags = 0;
10003 info.low_limit = TASK_UNMAPPED_BASE;
10004 +
10005 +#ifdef CONFIG_PAX_RANDMMAP
10006 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10007 + info.low_limit += mm->delta_mmap;
10008 +#endif
10009 +
10010 info.high_limit = STACK_TOP32;
10011 addr = vm_unmapped_area(&info);
10012 }
10013 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10014 struct mm_struct *mm = current->mm;
10015 struct vm_area_struct *vma;
10016 unsigned long task_size = TASK_SIZE;
10017 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10018
10019 if (test_thread_flag(TIF_32BIT))
10020 task_size = STACK_TOP32;
10021 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10022 return addr;
10023 }
10024
10025 +#ifdef CONFIG_PAX_RANDMMAP
10026 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10027 +#endif
10028 +
10029 if (addr) {
10030 addr = ALIGN(addr, HPAGE_SIZE);
10031 vma = find_vma(mm, addr);
10032 - if (task_size - len >= addr &&
10033 - (!vma || addr + len <= vma->vm_start))
10034 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10035 return addr;
10036 }
10037 if (mm->get_unmapped_area == arch_get_unmapped_area)
10038 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10039 index f4500c6..889656c 100644
10040 --- a/arch/tile/include/asm/atomic_64.h
10041 +++ b/arch/tile/include/asm/atomic_64.h
10042 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10043
10044 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10045
10046 +#define atomic64_read_unchecked(v) atomic64_read(v)
10047 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10048 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10049 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10050 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10051 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10052 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10053 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10054 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10055 +
10056 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10057 #define smp_mb__before_atomic_dec() smp_mb()
10058 #define smp_mb__after_atomic_dec() smp_mb()
10059 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10060 index a9a5299..0fce79e 100644
10061 --- a/arch/tile/include/asm/cache.h
10062 +++ b/arch/tile/include/asm/cache.h
10063 @@ -15,11 +15,12 @@
10064 #ifndef _ASM_TILE_CACHE_H
10065 #define _ASM_TILE_CACHE_H
10066
10067 +#include <linux/const.h>
10068 #include <arch/chip.h>
10069
10070 /* bytes per L1 data cache line */
10071 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10072 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10073 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10074
10075 /* bytes per L2 cache line */
10076 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10077 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10078 index 9ab078a..d6635c2 100644
10079 --- a/arch/tile/include/asm/uaccess.h
10080 +++ b/arch/tile/include/asm/uaccess.h
10081 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10082 const void __user *from,
10083 unsigned long n)
10084 {
10085 - int sz = __compiletime_object_size(to);
10086 + size_t sz = __compiletime_object_size(to);
10087
10088 - if (likely(sz == -1 || sz >= n))
10089 + if (likely(sz == (size_t)-1 || sz >= n))
10090 n = _copy_from_user(to, from, n);
10091 else
10092 copy_from_user_overflow();
10093 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10094 index 650ccff..45fe2d6 100644
10095 --- a/arch/tile/mm/hugetlbpage.c
10096 +++ b/arch/tile/mm/hugetlbpage.c
10097 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10098 info.high_limit = TASK_SIZE;
10099 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10100 info.align_offset = 0;
10101 + info.threadstack_offset = 0;
10102 return vm_unmapped_area(&info);
10103 }
10104
10105 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10106 info.high_limit = current->mm->mmap_base;
10107 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10108 info.align_offset = 0;
10109 + info.threadstack_offset = 0;
10110 addr = vm_unmapped_area(&info);
10111
10112 /*
10113 diff --git a/arch/um/Makefile b/arch/um/Makefile
10114 index 133f7de..1d6f2f1 100644
10115 --- a/arch/um/Makefile
10116 +++ b/arch/um/Makefile
10117 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10118 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10119 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10120
10121 +ifdef CONSTIFY_PLUGIN
10122 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10123 +endif
10124 +
10125 #This will adjust *FLAGS accordingly to the platform.
10126 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10127
10128 diff --git a/arch/um/defconfig b/arch/um/defconfig
10129 index 08107a7..ab22afe 100644
10130 --- a/arch/um/defconfig
10131 +++ b/arch/um/defconfig
10132 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10133 CONFIG_X86_L1_CACHE_SHIFT=5
10134 CONFIG_X86_XADD=y
10135 CONFIG_X86_PPRO_FENCE=y
10136 -CONFIG_X86_WP_WORKS_OK=y
10137 CONFIG_X86_INVLPG=y
10138 CONFIG_X86_BSWAP=y
10139 CONFIG_X86_POPAD_OK=y
10140 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10141 index 19e1bdd..3665b77 100644
10142 --- a/arch/um/include/asm/cache.h
10143 +++ b/arch/um/include/asm/cache.h
10144 @@ -1,6 +1,7 @@
10145 #ifndef __UM_CACHE_H
10146 #define __UM_CACHE_H
10147
10148 +#include <linux/const.h>
10149
10150 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10151 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10152 @@ -12,6 +13,6 @@
10153 # define L1_CACHE_SHIFT 5
10154 #endif
10155
10156 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10157 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10158
10159 #endif
10160 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10161 index 2e0a6b1..a64d0f5 100644
10162 --- a/arch/um/include/asm/kmap_types.h
10163 +++ b/arch/um/include/asm/kmap_types.h
10164 @@ -8,6 +8,6 @@
10165
10166 /* No more #include "asm/arch/kmap_types.h" ! */
10167
10168 -#define KM_TYPE_NR 14
10169 +#define KM_TYPE_NR 15
10170
10171 #endif
10172 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10173 index 5ff53d9..5850cdf 100644
10174 --- a/arch/um/include/asm/page.h
10175 +++ b/arch/um/include/asm/page.h
10176 @@ -14,6 +14,9 @@
10177 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10178 #define PAGE_MASK (~(PAGE_SIZE-1))
10179
10180 +#define ktla_ktva(addr) (addr)
10181 +#define ktva_ktla(addr) (addr)
10182 +
10183 #ifndef __ASSEMBLY__
10184
10185 struct page;
10186 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10187 index 0032f92..cd151e0 100644
10188 --- a/arch/um/include/asm/pgtable-3level.h
10189 +++ b/arch/um/include/asm/pgtable-3level.h
10190 @@ -58,6 +58,7 @@
10191 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10192 #define pud_populate(mm, pud, pmd) \
10193 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10194 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10195
10196 #ifdef CONFIG_64BIT
10197 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10198 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10199 index b462b13..e7a19aa 100644
10200 --- a/arch/um/kernel/process.c
10201 +++ b/arch/um/kernel/process.c
10202 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10203 return 2;
10204 }
10205
10206 -/*
10207 - * Only x86 and x86_64 have an arch_align_stack().
10208 - * All other arches have "#define arch_align_stack(x) (x)"
10209 - * in their asm/system.h
10210 - * As this is included in UML from asm-um/system-generic.h,
10211 - * we can use it to behave as the subarch does.
10212 - */
10213 -#ifndef arch_align_stack
10214 -unsigned long arch_align_stack(unsigned long sp)
10215 -{
10216 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10217 - sp -= get_random_int() % 8192;
10218 - return sp & ~0xf;
10219 -}
10220 -#endif
10221 -
10222 unsigned long get_wchan(struct task_struct *p)
10223 {
10224 unsigned long stack_page, sp, ip;
10225 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10226 index ad8f795..2c7eec6 100644
10227 --- a/arch/unicore32/include/asm/cache.h
10228 +++ b/arch/unicore32/include/asm/cache.h
10229 @@ -12,8 +12,10 @@
10230 #ifndef __UNICORE_CACHE_H__
10231 #define __UNICORE_CACHE_H__
10232
10233 -#define L1_CACHE_SHIFT (5)
10234 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10235 +#include <linux/const.h>
10236 +
10237 +#define L1_CACHE_SHIFT 5
10238 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10239
10240 /*
10241 * Memory returned by kmalloc() may be used for DMA, so we must make
10242 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10243 index 6ef2a37..74ad6ad 100644
10244 --- a/arch/x86/Kconfig
10245 +++ b/arch/x86/Kconfig
10246 @@ -243,7 +243,7 @@ config X86_HT
10247
10248 config X86_32_LAZY_GS
10249 def_bool y
10250 - depends on X86_32 && !CC_STACKPROTECTOR
10251 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10252
10253 config ARCH_HWEIGHT_CFLAGS
10254 string
10255 @@ -1076,6 +1076,7 @@ config MICROCODE_EARLY
10256
10257 config X86_MSR
10258 tristate "/dev/cpu/*/msr - Model-specific register support"
10259 + depends on !GRKERNSEC_KMEM
10260 ---help---
10261 This device gives privileged processes access to the x86
10262 Model-Specific Registers (MSRs). It is a character device with
10263 @@ -1099,7 +1100,7 @@ choice
10264
10265 config NOHIGHMEM
10266 bool "off"
10267 - depends on !X86_NUMAQ
10268 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10269 ---help---
10270 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10271 However, the address space of 32-bit x86 processors is only 4
10272 @@ -1136,7 +1137,7 @@ config NOHIGHMEM
10273
10274 config HIGHMEM4G
10275 bool "4GB"
10276 - depends on !X86_NUMAQ
10277 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10278 ---help---
10279 Select this if you have a 32-bit processor and between 1 and 4
10280 gigabytes of physical RAM.
10281 @@ -1189,7 +1190,7 @@ config PAGE_OFFSET
10282 hex
10283 default 0xB0000000 if VMSPLIT_3G_OPT
10284 default 0x80000000 if VMSPLIT_2G
10285 - default 0x78000000 if VMSPLIT_2G_OPT
10286 + default 0x70000000 if VMSPLIT_2G_OPT
10287 default 0x40000000 if VMSPLIT_1G
10288 default 0xC0000000
10289 depends on X86_32
10290 @@ -1587,6 +1588,7 @@ config SECCOMP
10291
10292 config CC_STACKPROTECTOR
10293 bool "Enable -fstack-protector buffer overflow detection"
10294 + depends on X86_64 || !PAX_MEMORY_UDEREF
10295 ---help---
10296 This option turns on the -fstack-protector GCC feature. This
10297 feature puts, at the beginning of functions, a canary value on
10298 @@ -1706,6 +1708,8 @@ config X86_NEED_RELOCS
10299 config PHYSICAL_ALIGN
10300 hex "Alignment value to which kernel should be aligned" if X86_32
10301 default "0x1000000"
10302 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10303 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10304 range 0x2000 0x1000000
10305 ---help---
10306 This value puts the alignment restrictions on physical address
10307 @@ -1781,9 +1785,10 @@ config DEBUG_HOTPLUG_CPU0
10308 If unsure, say N.
10309
10310 config COMPAT_VDSO
10311 - def_bool y
10312 + def_bool n
10313 prompt "Compat VDSO support"
10314 depends on X86_32 || IA32_EMULATION
10315 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10316 ---help---
10317 Map the 32-bit VDSO to the predictable old-style address too.
10318
10319 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10320 index c026cca..14657ae 100644
10321 --- a/arch/x86/Kconfig.cpu
10322 +++ b/arch/x86/Kconfig.cpu
10323 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10324
10325 config X86_F00F_BUG
10326 def_bool y
10327 - depends on M586MMX || M586TSC || M586 || M486
10328 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10329
10330 config X86_INVD_BUG
10331 def_bool y
10332 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10333
10334 config X86_ALIGNMENT_16
10335 def_bool y
10336 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10337 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10338
10339 config X86_INTEL_USERCOPY
10340 def_bool y
10341 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10342 # generates cmov.
10343 config X86_CMOV
10344 def_bool y
10345 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10346 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10347
10348 config X86_MINIMUM_CPU_FAMILY
10349 int
10350 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10351 index b322f12..652d0d9 100644
10352 --- a/arch/x86/Kconfig.debug
10353 +++ b/arch/x86/Kconfig.debug
10354 @@ -84,7 +84,7 @@ config X86_PTDUMP
10355 config DEBUG_RODATA
10356 bool "Write protect kernel read-only data structures"
10357 default y
10358 - depends on DEBUG_KERNEL
10359 + depends on DEBUG_KERNEL && BROKEN
10360 ---help---
10361 Mark the kernel read-only data as write-protected in the pagetables,
10362 in order to catch accidental (and incorrect) writes to such const
10363 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10364
10365 config DEBUG_SET_MODULE_RONX
10366 bool "Set loadable kernel module data as NX and text as RO"
10367 - depends on MODULES
10368 + depends on MODULES && BROKEN
10369 ---help---
10370 This option helps catch unintended modifications to loadable
10371 kernel module's text and read-only data. It also prevents execution
10372 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10373
10374 config DEBUG_STRICT_USER_COPY_CHECKS
10375 bool "Strict copy size checks"
10376 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10377 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10378 ---help---
10379 Enabling this option turns a certain set of sanity checks for user
10380 copy operations into compile time failures.
10381 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10382 index 5c47726..8c4fa67 100644
10383 --- a/arch/x86/Makefile
10384 +++ b/arch/x86/Makefile
10385 @@ -54,6 +54,7 @@ else
10386 UTS_MACHINE := x86_64
10387 CHECKFLAGS += -D__x86_64__ -m64
10388
10389 + biarch := $(call cc-option,-m64)
10390 KBUILD_AFLAGS += -m64
10391 KBUILD_CFLAGS += -m64
10392
10393 @@ -234,3 +235,12 @@ define archhelp
10394 echo ' FDARGS="..." arguments for the booted kernel'
10395 echo ' FDINITRD=file initrd for the booted kernel'
10396 endef
10397 +
10398 +define OLD_LD
10399 +
10400 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10401 +*** Please upgrade your binutils to 2.18 or newer
10402 +endef
10403 +
10404 +archprepare:
10405 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10406 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10407 index 379814b..add62ce 100644
10408 --- a/arch/x86/boot/Makefile
10409 +++ b/arch/x86/boot/Makefile
10410 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10411 $(call cc-option, -fno-stack-protector) \
10412 $(call cc-option, -mpreferred-stack-boundary=2)
10413 KBUILD_CFLAGS += $(call cc-option, -m32)
10414 +ifdef CONSTIFY_PLUGIN
10415 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10416 +endif
10417 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10418 GCOV_PROFILE := n
10419
10420 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10421 index 878e4b9..20537ab 100644
10422 --- a/arch/x86/boot/bitops.h
10423 +++ b/arch/x86/boot/bitops.h
10424 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10425 u8 v;
10426 const u32 *p = (const u32 *)addr;
10427
10428 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10429 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10430 return v;
10431 }
10432
10433 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10434
10435 static inline void set_bit(int nr, void *addr)
10436 {
10437 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10438 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10439 }
10440
10441 #endif /* BOOT_BITOPS_H */
10442 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10443 index 5b75319..331a4ca 100644
10444 --- a/arch/x86/boot/boot.h
10445 +++ b/arch/x86/boot/boot.h
10446 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10447 static inline u16 ds(void)
10448 {
10449 u16 seg;
10450 - asm("movw %%ds,%0" : "=rm" (seg));
10451 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10452 return seg;
10453 }
10454
10455 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10456 static inline int memcmp(const void *s1, const void *s2, size_t len)
10457 {
10458 u8 diff;
10459 - asm("repe; cmpsb; setnz %0"
10460 + asm volatile("repe; cmpsb; setnz %0"
10461 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10462 return diff;
10463 }
10464 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10465 index 5ef205c..342191d 100644
10466 --- a/arch/x86/boot/compressed/Makefile
10467 +++ b/arch/x86/boot/compressed/Makefile
10468 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10469 KBUILD_CFLAGS += $(cflags-y)
10470 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10471 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10472 +ifdef CONSTIFY_PLUGIN
10473 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10474 +endif
10475
10476 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10477 GCOV_PROFILE := n
10478 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10479 index 35ee62f..b6609b6 100644
10480 --- a/arch/x86/boot/compressed/eboot.c
10481 +++ b/arch/x86/boot/compressed/eboot.c
10482 @@ -150,7 +150,6 @@ again:
10483 *addr = max_addr;
10484 }
10485
10486 -free_pool:
10487 efi_call_phys1(sys_table->boottime->free_pool, map);
10488
10489 fail:
10490 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10491 if (i == map_size / desc_size)
10492 status = EFI_NOT_FOUND;
10493
10494 -free_pool:
10495 efi_call_phys1(sys_table->boottime->free_pool, map);
10496 fail:
10497 return status;
10498 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10499 index 1e3184f..0d11e2e 100644
10500 --- a/arch/x86/boot/compressed/head_32.S
10501 +++ b/arch/x86/boot/compressed/head_32.S
10502 @@ -118,7 +118,7 @@ preferred_addr:
10503 notl %eax
10504 andl %eax, %ebx
10505 #else
10506 - movl $LOAD_PHYSICAL_ADDR, %ebx
10507 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10508 #endif
10509
10510 /* Target address to relocate to for decompression */
10511 @@ -204,7 +204,7 @@ relocated:
10512 * and where it was actually loaded.
10513 */
10514 movl %ebp, %ebx
10515 - subl $LOAD_PHYSICAL_ADDR, %ebx
10516 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10517 jz 2f /* Nothing to be done if loaded at compiled addr. */
10518 /*
10519 * Process relocations.
10520 @@ -212,8 +212,7 @@ relocated:
10521
10522 1: subl $4, %edi
10523 movl (%edi), %ecx
10524 - testl %ecx, %ecx
10525 - jz 2f
10526 + jecxz 2f
10527 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10528 jmp 1b
10529 2:
10530 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10531 index c1d383d..57ab51c 100644
10532 --- a/arch/x86/boot/compressed/head_64.S
10533 +++ b/arch/x86/boot/compressed/head_64.S
10534 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10535 notl %eax
10536 andl %eax, %ebx
10537 #else
10538 - movl $LOAD_PHYSICAL_ADDR, %ebx
10539 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10540 #endif
10541
10542 /* Target address to relocate to for decompression */
10543 @@ -272,7 +272,7 @@ preferred_addr:
10544 notq %rax
10545 andq %rax, %rbp
10546 #else
10547 - movq $LOAD_PHYSICAL_ADDR, %rbp
10548 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10549 #endif
10550
10551 /* Target address to relocate to for decompression */
10552 @@ -363,8 +363,8 @@ gdt:
10553 .long gdt
10554 .word 0
10555 .quad 0x0000000000000000 /* NULL descriptor */
10556 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10557 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10558 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10559 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10560 .quad 0x0080890000000000 /* TS descriptor */
10561 .quad 0x0000000000000000 /* TS continued */
10562 gdt_end:
10563 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10564 index 7cb56c6..d382d84 100644
10565 --- a/arch/x86/boot/compressed/misc.c
10566 +++ b/arch/x86/boot/compressed/misc.c
10567 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10568 case PT_LOAD:
10569 #ifdef CONFIG_RELOCATABLE
10570 dest = output;
10571 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10572 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10573 #else
10574 dest = (void *)(phdr->p_paddr);
10575 #endif
10576 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10577 error("Destination address too large");
10578 #endif
10579 #ifndef CONFIG_RELOCATABLE
10580 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10581 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10582 error("Wrong destination address");
10583 #endif
10584
10585 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10586 index 4d3ff03..e4972ff 100644
10587 --- a/arch/x86/boot/cpucheck.c
10588 +++ b/arch/x86/boot/cpucheck.c
10589 @@ -74,7 +74,7 @@ static int has_fpu(void)
10590 u16 fcw = -1, fsw = -1;
10591 u32 cr0;
10592
10593 - asm("movl %%cr0,%0" : "=r" (cr0));
10594 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10595 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10596 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10597 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10598 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10599 {
10600 u32 f0, f1;
10601
10602 - asm("pushfl ; "
10603 + asm volatile("pushfl ; "
10604 "pushfl ; "
10605 "popl %0 ; "
10606 "movl %0,%1 ; "
10607 @@ -115,7 +115,7 @@ static void get_flags(void)
10608 set_bit(X86_FEATURE_FPU, cpu.flags);
10609
10610 if (has_eflag(X86_EFLAGS_ID)) {
10611 - asm("cpuid"
10612 + asm volatile("cpuid"
10613 : "=a" (max_intel_level),
10614 "=b" (cpu_vendor[0]),
10615 "=d" (cpu_vendor[1]),
10616 @@ -124,7 +124,7 @@ static void get_flags(void)
10617
10618 if (max_intel_level >= 0x00000001 &&
10619 max_intel_level <= 0x0000ffff) {
10620 - asm("cpuid"
10621 + asm volatile("cpuid"
10622 : "=a" (tfms),
10623 "=c" (cpu.flags[4]),
10624 "=d" (cpu.flags[0])
10625 @@ -136,7 +136,7 @@ static void get_flags(void)
10626 cpu.model += ((tfms >> 16) & 0xf) << 4;
10627 }
10628
10629 - asm("cpuid"
10630 + asm volatile("cpuid"
10631 : "=a" (max_amd_level)
10632 : "a" (0x80000000)
10633 : "ebx", "ecx", "edx");
10634 @@ -144,7 +144,7 @@ static void get_flags(void)
10635 if (max_amd_level >= 0x80000001 &&
10636 max_amd_level <= 0x8000ffff) {
10637 u32 eax = 0x80000001;
10638 - asm("cpuid"
10639 + asm volatile("cpuid"
10640 : "+a" (eax),
10641 "=c" (cpu.flags[6]),
10642 "=d" (cpu.flags[1])
10643 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10644 u32 ecx = MSR_K7_HWCR;
10645 u32 eax, edx;
10646
10647 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10648 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10649 eax &= ~(1 << 15);
10650 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10651 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10652
10653 get_flags(); /* Make sure it really did something */
10654 err = check_flags();
10655 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10656 u32 ecx = MSR_VIA_FCR;
10657 u32 eax, edx;
10658
10659 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10660 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10661 eax |= (1<<1)|(1<<7);
10662 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10663 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10664
10665 set_bit(X86_FEATURE_CX8, cpu.flags);
10666 err = check_flags();
10667 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10668 u32 eax, edx;
10669 u32 level = 1;
10670
10671 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10672 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10673 - asm("cpuid"
10674 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10675 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10676 + asm volatile("cpuid"
10677 : "+a" (level), "=d" (cpu.flags[0])
10678 : : "ecx", "ebx");
10679 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10680 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10681
10682 err = check_flags();
10683 }
10684 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10685 index 9ec06a1..2c25e79 100644
10686 --- a/arch/x86/boot/header.S
10687 +++ b/arch/x86/boot/header.S
10688 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10689 # single linked list of
10690 # struct setup_data
10691
10692 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10693 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10694
10695 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10696 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10697 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10698 +#else
10699 #define VO_INIT_SIZE (VO__end - VO__text)
10700 +#endif
10701 #if ZO_INIT_SIZE > VO_INIT_SIZE
10702 #define INIT_SIZE ZO_INIT_SIZE
10703 #else
10704 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10705 index db75d07..8e6d0af 100644
10706 --- a/arch/x86/boot/memory.c
10707 +++ b/arch/x86/boot/memory.c
10708 @@ -19,7 +19,7 @@
10709
10710 static int detect_memory_e820(void)
10711 {
10712 - int count = 0;
10713 + unsigned int count = 0;
10714 struct biosregs ireg, oreg;
10715 struct e820entry *desc = boot_params.e820_map;
10716 static struct e820entry buf; /* static so it is zeroed */
10717 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10718 index 11e8c6e..fdbb1ed 100644
10719 --- a/arch/x86/boot/video-vesa.c
10720 +++ b/arch/x86/boot/video-vesa.c
10721 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10722
10723 boot_params.screen_info.vesapm_seg = oreg.es;
10724 boot_params.screen_info.vesapm_off = oreg.di;
10725 + boot_params.screen_info.vesapm_size = oreg.cx;
10726 }
10727
10728 /*
10729 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10730 index 43eda28..5ab5fdb 100644
10731 --- a/arch/x86/boot/video.c
10732 +++ b/arch/x86/boot/video.c
10733 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10734 static unsigned int get_entry(void)
10735 {
10736 char entry_buf[4];
10737 - int i, len = 0;
10738 + unsigned int i, len = 0;
10739 int key;
10740 unsigned int v;
10741
10742 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10743 index 9105655..5e37f27 100644
10744 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10745 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10746 @@ -8,6 +8,8 @@
10747 * including this sentence is retained in full.
10748 */
10749
10750 +#include <asm/alternative-asm.h>
10751 +
10752 .extern crypto_ft_tab
10753 .extern crypto_it_tab
10754 .extern crypto_fl_tab
10755 @@ -70,6 +72,8 @@
10756 je B192; \
10757 leaq 32(r9),r9;
10758
10759 +#define ret pax_force_retaddr 0, 1; ret
10760 +
10761 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10762 movq r1,r2; \
10763 movq r3,r4; \
10764 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10765 index 04b7977..402f223 100644
10766 --- a/arch/x86/crypto/aesni-intel_asm.S
10767 +++ b/arch/x86/crypto/aesni-intel_asm.S
10768 @@ -31,6 +31,7 @@
10769
10770 #include <linux/linkage.h>
10771 #include <asm/inst.h>
10772 +#include <asm/alternative-asm.h>
10773
10774 #ifdef __x86_64__
10775 .data
10776 @@ -1435,6 +1436,7 @@ _return_T_done_decrypt:
10777 pop %r14
10778 pop %r13
10779 pop %r12
10780 + pax_force_retaddr 0, 1
10781 ret
10782 ENDPROC(aesni_gcm_dec)
10783
10784 @@ -1699,6 +1701,7 @@ _return_T_done_encrypt:
10785 pop %r14
10786 pop %r13
10787 pop %r12
10788 + pax_force_retaddr 0, 1
10789 ret
10790 ENDPROC(aesni_gcm_enc)
10791
10792 @@ -1716,6 +1719,7 @@ _key_expansion_256a:
10793 pxor %xmm1, %xmm0
10794 movaps %xmm0, (TKEYP)
10795 add $0x10, TKEYP
10796 + pax_force_retaddr_bts
10797 ret
10798 ENDPROC(_key_expansion_128)
10799 ENDPROC(_key_expansion_256a)
10800 @@ -1742,6 +1746,7 @@ _key_expansion_192a:
10801 shufps $0b01001110, %xmm2, %xmm1
10802 movaps %xmm1, 0x10(TKEYP)
10803 add $0x20, TKEYP
10804 + pax_force_retaddr_bts
10805 ret
10806 ENDPROC(_key_expansion_192a)
10807
10808 @@ -1762,6 +1767,7 @@ _key_expansion_192b:
10809
10810 movaps %xmm0, (TKEYP)
10811 add $0x10, TKEYP
10812 + pax_force_retaddr_bts
10813 ret
10814 ENDPROC(_key_expansion_192b)
10815
10816 @@ -1775,6 +1781,7 @@ _key_expansion_256b:
10817 pxor %xmm1, %xmm2
10818 movaps %xmm2, (TKEYP)
10819 add $0x10, TKEYP
10820 + pax_force_retaddr_bts
10821 ret
10822 ENDPROC(_key_expansion_256b)
10823
10824 @@ -1888,6 +1895,7 @@ ENTRY(aesni_set_key)
10825 #ifndef __x86_64__
10826 popl KEYP
10827 #endif
10828 + pax_force_retaddr 0, 1
10829 ret
10830 ENDPROC(aesni_set_key)
10831
10832 @@ -1910,6 +1918,7 @@ ENTRY(aesni_enc)
10833 popl KLEN
10834 popl KEYP
10835 #endif
10836 + pax_force_retaddr 0, 1
10837 ret
10838 ENDPROC(aesni_enc)
10839
10840 @@ -1968,6 +1977,7 @@ _aesni_enc1:
10841 AESENC KEY STATE
10842 movaps 0x70(TKEYP), KEY
10843 AESENCLAST KEY STATE
10844 + pax_force_retaddr_bts
10845 ret
10846 ENDPROC(_aesni_enc1)
10847
10848 @@ -2077,6 +2087,7 @@ _aesni_enc4:
10849 AESENCLAST KEY STATE2
10850 AESENCLAST KEY STATE3
10851 AESENCLAST KEY STATE4
10852 + pax_force_retaddr_bts
10853 ret
10854 ENDPROC(_aesni_enc4)
10855
10856 @@ -2100,6 +2111,7 @@ ENTRY(aesni_dec)
10857 popl KLEN
10858 popl KEYP
10859 #endif
10860 + pax_force_retaddr 0, 1
10861 ret
10862 ENDPROC(aesni_dec)
10863
10864 @@ -2158,6 +2170,7 @@ _aesni_dec1:
10865 AESDEC KEY STATE
10866 movaps 0x70(TKEYP), KEY
10867 AESDECLAST KEY STATE
10868 + pax_force_retaddr_bts
10869 ret
10870 ENDPROC(_aesni_dec1)
10871
10872 @@ -2267,6 +2280,7 @@ _aesni_dec4:
10873 AESDECLAST KEY STATE2
10874 AESDECLAST KEY STATE3
10875 AESDECLAST KEY STATE4
10876 + pax_force_retaddr_bts
10877 ret
10878 ENDPROC(_aesni_dec4)
10879
10880 @@ -2325,6 +2339,7 @@ ENTRY(aesni_ecb_enc)
10881 popl KEYP
10882 popl LEN
10883 #endif
10884 + pax_force_retaddr 0, 1
10885 ret
10886 ENDPROC(aesni_ecb_enc)
10887
10888 @@ -2384,6 +2399,7 @@ ENTRY(aesni_ecb_dec)
10889 popl KEYP
10890 popl LEN
10891 #endif
10892 + pax_force_retaddr 0, 1
10893 ret
10894 ENDPROC(aesni_ecb_dec)
10895
10896 @@ -2426,6 +2442,7 @@ ENTRY(aesni_cbc_enc)
10897 popl LEN
10898 popl IVP
10899 #endif
10900 + pax_force_retaddr 0, 1
10901 ret
10902 ENDPROC(aesni_cbc_enc)
10903
10904 @@ -2517,6 +2534,7 @@ ENTRY(aesni_cbc_dec)
10905 popl LEN
10906 popl IVP
10907 #endif
10908 + pax_force_retaddr 0, 1
10909 ret
10910 ENDPROC(aesni_cbc_dec)
10911
10912 @@ -2544,6 +2562,7 @@ _aesni_inc_init:
10913 mov $1, TCTR_LOW
10914 MOVQ_R64_XMM TCTR_LOW INC
10915 MOVQ_R64_XMM CTR TCTR_LOW
10916 + pax_force_retaddr_bts
10917 ret
10918 ENDPROC(_aesni_inc_init)
10919
10920 @@ -2573,6 +2592,7 @@ _aesni_inc:
10921 .Linc_low:
10922 movaps CTR, IV
10923 PSHUFB_XMM BSWAP_MASK IV
10924 + pax_force_retaddr_bts
10925 ret
10926 ENDPROC(_aesni_inc)
10927
10928 @@ -2634,6 +2654,7 @@ ENTRY(aesni_ctr_enc)
10929 .Lctr_enc_ret:
10930 movups IV, (IVP)
10931 .Lctr_enc_just_ret:
10932 + pax_force_retaddr 0, 1
10933 ret
10934 ENDPROC(aesni_ctr_enc)
10935 #endif
10936 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10937 index 246c670..4d1ed00 100644
10938 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10939 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10940 @@ -21,6 +21,7 @@
10941 */
10942
10943 #include <linux/linkage.h>
10944 +#include <asm/alternative-asm.h>
10945
10946 .file "blowfish-x86_64-asm.S"
10947 .text
10948 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
10949 jnz .L__enc_xor;
10950
10951 write_block();
10952 + pax_force_retaddr 0, 1
10953 ret;
10954 .L__enc_xor:
10955 xor_block();
10956 + pax_force_retaddr 0, 1
10957 ret;
10958 ENDPROC(__blowfish_enc_blk)
10959
10960 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
10961
10962 movq %r11, %rbp;
10963
10964 + pax_force_retaddr 0, 1
10965 ret;
10966 ENDPROC(blowfish_dec_blk)
10967
10968 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
10969
10970 popq %rbx;
10971 popq %rbp;
10972 + pax_force_retaddr 0, 1
10973 ret;
10974
10975 .L__enc_xor4:
10976 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
10977
10978 popq %rbx;
10979 popq %rbp;
10980 + pax_force_retaddr 0, 1
10981 ret;
10982 ENDPROC(__blowfish_enc_blk_4way)
10983
10984 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
10985 popq %rbx;
10986 popq %rbp;
10987
10988 + pax_force_retaddr 0, 1
10989 ret;
10990 ENDPROC(blowfish_dec_blk_4way)
10991 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
10992 index 310319c..ce174a4 100644
10993 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
10994 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
10995 @@ -21,6 +21,7 @@
10996 */
10997
10998 #include <linux/linkage.h>
10999 +#include <asm/alternative-asm.h>
11000
11001 .file "camellia-x86_64-asm_64.S"
11002 .text
11003 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
11004 enc_outunpack(mov, RT1);
11005
11006 movq RRBP, %rbp;
11007 + pax_force_retaddr 0, 1
11008 ret;
11009
11010 .L__enc_xor:
11011 enc_outunpack(xor, RT1);
11012
11013 movq RRBP, %rbp;
11014 + pax_force_retaddr 0, 1
11015 ret;
11016 ENDPROC(__camellia_enc_blk)
11017
11018 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
11019 dec_outunpack();
11020
11021 movq RRBP, %rbp;
11022 + pax_force_retaddr 0, 1
11023 ret;
11024 ENDPROC(camellia_dec_blk)
11025
11026 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11027
11028 movq RRBP, %rbp;
11029 popq %rbx;
11030 + pax_force_retaddr 0, 1
11031 ret;
11032
11033 .L__enc2_xor:
11034 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11035
11036 movq RRBP, %rbp;
11037 popq %rbx;
11038 + pax_force_retaddr 0, 1
11039 ret;
11040 ENDPROC(__camellia_enc_blk_2way)
11041
11042 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11043
11044 movq RRBP, %rbp;
11045 movq RXOR, %rbx;
11046 + pax_force_retaddr 0, 1
11047 ret;
11048 ENDPROC(camellia_dec_blk_2way)
11049 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11050 index c35fd5d..c1ee236 100644
11051 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11052 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11053 @@ -24,6 +24,7 @@
11054 */
11055
11056 #include <linux/linkage.h>
11057 +#include <asm/alternative-asm.h>
11058
11059 .file "cast5-avx-x86_64-asm_64.S"
11060
11061 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11062 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11063 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11064
11065 + pax_force_retaddr 0, 1
11066 ret;
11067 ENDPROC(__cast5_enc_blk16)
11068
11069 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11070 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11071 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11072
11073 + pax_force_retaddr 0, 1
11074 ret;
11075
11076 .L__skip_dec:
11077 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11078 vmovdqu RR4, (6*4*4)(%r11);
11079 vmovdqu RL4, (7*4*4)(%r11);
11080
11081 + pax_force_retaddr
11082 ret;
11083 ENDPROC(cast5_ecb_enc_16way)
11084
11085 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11086 vmovdqu RR4, (6*4*4)(%r11);
11087 vmovdqu RL4, (7*4*4)(%r11);
11088
11089 + pax_force_retaddr
11090 ret;
11091 ENDPROC(cast5_ecb_dec_16way)
11092
11093 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11094
11095 popq %r12;
11096
11097 + pax_force_retaddr
11098 ret;
11099 ENDPROC(cast5_cbc_dec_16way)
11100
11101 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11102
11103 popq %r12;
11104
11105 + pax_force_retaddr
11106 ret;
11107 ENDPROC(cast5_ctr_16way)
11108 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11109 index f93b610..c09bf40 100644
11110 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11111 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11112 @@ -24,6 +24,7 @@
11113 */
11114
11115 #include <linux/linkage.h>
11116 +#include <asm/alternative-asm.h>
11117 #include "glue_helper-asm-avx.S"
11118
11119 .file "cast6-avx-x86_64-asm_64.S"
11120 @@ -293,6 +294,7 @@ __cast6_enc_blk8:
11121 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11122 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11123
11124 + pax_force_retaddr 0, 1
11125 ret;
11126 ENDPROC(__cast6_enc_blk8)
11127
11128 @@ -338,6 +340,7 @@ __cast6_dec_blk8:
11129 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11130 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11131
11132 + pax_force_retaddr 0, 1
11133 ret;
11134 ENDPROC(__cast6_dec_blk8)
11135
11136 @@ -356,6 +359,7 @@ ENTRY(cast6_ecb_enc_8way)
11137
11138 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11139
11140 + pax_force_retaddr
11141 ret;
11142 ENDPROC(cast6_ecb_enc_8way)
11143
11144 @@ -374,6 +378,7 @@ ENTRY(cast6_ecb_dec_8way)
11145
11146 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11147
11148 + pax_force_retaddr
11149 ret;
11150 ENDPROC(cast6_ecb_dec_8way)
11151
11152 @@ -397,6 +402,7 @@ ENTRY(cast6_cbc_dec_8way)
11153
11154 popq %r12;
11155
11156 + pax_force_retaddr
11157 ret;
11158 ENDPROC(cast6_cbc_dec_8way)
11159
11160 @@ -422,5 +428,6 @@ ENTRY(cast6_ctr_8way)
11161
11162 popq %r12;
11163
11164 + pax_force_retaddr
11165 ret;
11166 ENDPROC(cast6_ctr_8way)
11167 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11168 index 9279e0b..9270820 100644
11169 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11170 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11171 @@ -1,4 +1,5 @@
11172 #include <linux/linkage.h>
11173 +#include <asm/alternative-asm.h>
11174
11175 # enter salsa20_encrypt_bytes
11176 ENTRY(salsa20_encrypt_bytes)
11177 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11178 add %r11,%rsp
11179 mov %rdi,%rax
11180 mov %rsi,%rdx
11181 + pax_force_retaddr 0, 1
11182 ret
11183 # bytesatleast65:
11184 ._bytesatleast65:
11185 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11186 add %r11,%rsp
11187 mov %rdi,%rax
11188 mov %rsi,%rdx
11189 + pax_force_retaddr
11190 ret
11191 ENDPROC(salsa20_keysetup)
11192
11193 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11194 add %r11,%rsp
11195 mov %rdi,%rax
11196 mov %rsi,%rdx
11197 + pax_force_retaddr
11198 ret
11199 ENDPROC(salsa20_ivsetup)
11200 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11201 index 43c9386..a0e2d60 100644
11202 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11203 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11204 @@ -25,6 +25,7 @@
11205 */
11206
11207 #include <linux/linkage.h>
11208 +#include <asm/alternative-asm.h>
11209 #include "glue_helper-asm-avx.S"
11210
11211 .file "serpent-avx-x86_64-asm_64.S"
11212 @@ -617,6 +618,7 @@ __serpent_enc_blk8_avx:
11213 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11214 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11215
11216 + pax_force_retaddr
11217 ret;
11218 ENDPROC(__serpent_enc_blk8_avx)
11219
11220 @@ -671,6 +673,7 @@ __serpent_dec_blk8_avx:
11221 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11222 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11223
11224 + pax_force_retaddr
11225 ret;
11226 ENDPROC(__serpent_dec_blk8_avx)
11227
11228 @@ -687,6 +690,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11229
11230 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11231
11232 + pax_force_retaddr
11233 ret;
11234 ENDPROC(serpent_ecb_enc_8way_avx)
11235
11236 @@ -703,6 +707,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11237
11238 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11239
11240 + pax_force_retaddr
11241 ret;
11242 ENDPROC(serpent_ecb_dec_8way_avx)
11243
11244 @@ -719,6 +724,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11245
11246 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11247
11248 + pax_force_retaddr
11249 ret;
11250 ENDPROC(serpent_cbc_dec_8way_avx)
11251
11252 @@ -737,5 +743,6 @@ ENTRY(serpent_ctr_8way_avx)
11253
11254 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11255
11256 + pax_force_retaddr
11257 ret;
11258 ENDPROC(serpent_ctr_8way_avx)
11259 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11260 index acc066c..1559cc4 100644
11261 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11262 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11263 @@ -25,6 +25,7 @@
11264 */
11265
11266 #include <linux/linkage.h>
11267 +#include <asm/alternative-asm.h>
11268
11269 .file "serpent-sse2-x86_64-asm_64.S"
11270 .text
11271 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11272 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11273 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11274
11275 + pax_force_retaddr
11276 ret;
11277
11278 .L__enc_xor8:
11279 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11280 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11281
11282 + pax_force_retaddr
11283 ret;
11284 ENDPROC(__serpent_enc_blk_8way)
11285
11286 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11287 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11288 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11289
11290 + pax_force_retaddr
11291 ret;
11292 ENDPROC(serpent_dec_blk_8way)
11293 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11294 index a410950..3356d42 100644
11295 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11296 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11297 @@ -29,6 +29,7 @@
11298 */
11299
11300 #include <linux/linkage.h>
11301 +#include <asm/alternative-asm.h>
11302
11303 #define CTX %rdi // arg1
11304 #define BUF %rsi // arg2
11305 @@ -104,6 +105,7 @@
11306 pop %r12
11307 pop %rbp
11308 pop %rbx
11309 + pax_force_retaddr 0, 1
11310 ret
11311
11312 ENDPROC(\name)
11313 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11314 index 8d3e113..898b161 100644
11315 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11316 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11317 @@ -24,6 +24,7 @@
11318 */
11319
11320 #include <linux/linkage.h>
11321 +#include <asm/alternative-asm.h>
11322 #include "glue_helper-asm-avx.S"
11323
11324 .file "twofish-avx-x86_64-asm_64.S"
11325 @@ -282,6 +283,7 @@ __twofish_enc_blk8:
11326 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11327 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11328
11329 + pax_force_retaddr 0, 1
11330 ret;
11331 ENDPROC(__twofish_enc_blk8)
11332
11333 @@ -322,6 +324,7 @@ __twofish_dec_blk8:
11334 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11335 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11336
11337 + pax_force_retaddr 0, 1
11338 ret;
11339 ENDPROC(__twofish_dec_blk8)
11340
11341 @@ -340,6 +343,7 @@ ENTRY(twofish_ecb_enc_8way)
11342
11343 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11344
11345 + pax_force_retaddr 0, 1
11346 ret;
11347 ENDPROC(twofish_ecb_enc_8way)
11348
11349 @@ -358,6 +362,7 @@ ENTRY(twofish_ecb_dec_8way)
11350
11351 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11352
11353 + pax_force_retaddr 0, 1
11354 ret;
11355 ENDPROC(twofish_ecb_dec_8way)
11356
11357 @@ -381,6 +386,7 @@ ENTRY(twofish_cbc_dec_8way)
11358
11359 popq %r12;
11360
11361 + pax_force_retaddr 0, 1
11362 ret;
11363 ENDPROC(twofish_cbc_dec_8way)
11364
11365 @@ -406,5 +412,6 @@ ENTRY(twofish_ctr_8way)
11366
11367 popq %r12;
11368
11369 + pax_force_retaddr 0, 1
11370 ret;
11371 ENDPROC(twofish_ctr_8way)
11372 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11373 index 1c3b7ce..b365c5e 100644
11374 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11375 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11376 @@ -21,6 +21,7 @@
11377 */
11378
11379 #include <linux/linkage.h>
11380 +#include <asm/alternative-asm.h>
11381
11382 .file "twofish-x86_64-asm-3way.S"
11383 .text
11384 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
11385 popq %r13;
11386 popq %r14;
11387 popq %r15;
11388 + pax_force_retaddr 0, 1
11389 ret;
11390
11391 .L__enc_xor3:
11392 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
11393 popq %r13;
11394 popq %r14;
11395 popq %r15;
11396 + pax_force_retaddr 0, 1
11397 ret;
11398 ENDPROC(__twofish_enc_blk_3way)
11399
11400 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
11401 popq %r13;
11402 popq %r14;
11403 popq %r15;
11404 + pax_force_retaddr 0, 1
11405 ret;
11406 ENDPROC(twofish_dec_blk_3way)
11407 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11408 index a039d21..29e7615 100644
11409 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11410 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11411 @@ -22,6 +22,7 @@
11412
11413 #include <linux/linkage.h>
11414 #include <asm/asm-offsets.h>
11415 +#include <asm/alternative-asm.h>
11416
11417 #define a_offset 0
11418 #define b_offset 4
11419 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
11420
11421 popq R1
11422 movq $1,%rax
11423 + pax_force_retaddr 0, 1
11424 ret
11425 ENDPROC(twofish_enc_blk)
11426
11427 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
11428
11429 popq R1
11430 movq $1,%rax
11431 + pax_force_retaddr 0, 1
11432 ret
11433 ENDPROC(twofish_dec_blk)
11434 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11435 index 03abf9b..a42ba29 100644
11436 --- a/arch/x86/ia32/ia32_aout.c
11437 +++ b/arch/x86/ia32/ia32_aout.c
11438 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11439 unsigned long dump_start, dump_size;
11440 struct user32 dump;
11441
11442 + memset(&dump, 0, sizeof(dump));
11443 +
11444 fs = get_fs();
11445 set_fs(KERNEL_DS);
11446 has_dumped = 1;
11447 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11448 index cf1a471..3bc4cf8 100644
11449 --- a/arch/x86/ia32/ia32_signal.c
11450 +++ b/arch/x86/ia32/ia32_signal.c
11451 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
11452 sp -= frame_size;
11453 /* Align the stack pointer according to the i386 ABI,
11454 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11455 - sp = ((sp + 4) & -16ul) - 4;
11456 + sp = ((sp - 12) & -16ul) - 4;
11457 return (void __user *) sp;
11458 }
11459
11460 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
11461 * These are actually not used anymore, but left because some
11462 * gdb versions depend on them as a marker.
11463 */
11464 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11465 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11466 } put_user_catch(err);
11467
11468 if (err)
11469 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11470 0xb8,
11471 __NR_ia32_rt_sigreturn,
11472 0x80cd,
11473 - 0,
11474 + 0
11475 };
11476
11477 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
11478 @@ -463,16 +463,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11479
11480 if (ksig->ka.sa.sa_flags & SA_RESTORER)
11481 restorer = ksig->ka.sa.sa_restorer;
11482 + else if (current->mm->context.vdso)
11483 + /* Return stub is in 32bit vsyscall page */
11484 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11485 else
11486 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11487 - rt_sigreturn);
11488 + restorer = &frame->retcode;
11489 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11490
11491 /*
11492 * Not actually used anymore, but left because some gdb
11493 * versions need it.
11494 */
11495 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11496 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11497 } put_user_catch(err);
11498
11499 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
11500 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11501 index 474dc1b..be7bff5 100644
11502 --- a/arch/x86/ia32/ia32entry.S
11503 +++ b/arch/x86/ia32/ia32entry.S
11504 @@ -15,8 +15,10 @@
11505 #include <asm/irqflags.h>
11506 #include <asm/asm.h>
11507 #include <asm/smap.h>
11508 +#include <asm/pgtable.h>
11509 #include <linux/linkage.h>
11510 #include <linux/err.h>
11511 +#include <asm/alternative-asm.h>
11512
11513 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11514 #include <linux/elf-em.h>
11515 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11516 ENDPROC(native_irq_enable_sysexit)
11517 #endif
11518
11519 + .macro pax_enter_kernel_user
11520 + pax_set_fptr_mask
11521 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11522 + call pax_enter_kernel_user
11523 +#endif
11524 + .endm
11525 +
11526 + .macro pax_exit_kernel_user
11527 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11528 + call pax_exit_kernel_user
11529 +#endif
11530 +#ifdef CONFIG_PAX_RANDKSTACK
11531 + pushq %rax
11532 + pushq %r11
11533 + call pax_randomize_kstack
11534 + popq %r11
11535 + popq %rax
11536 +#endif
11537 + .endm
11538 +
11539 +.macro pax_erase_kstack
11540 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11541 + call pax_erase_kstack
11542 +#endif
11543 +.endm
11544 +
11545 /*
11546 * 32bit SYSENTER instruction entry.
11547 *
11548 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11549 CFI_REGISTER rsp,rbp
11550 SWAPGS_UNSAFE_STACK
11551 movq PER_CPU_VAR(kernel_stack), %rsp
11552 - addq $(KERNEL_STACK_OFFSET),%rsp
11553 - /*
11554 - * No need to follow this irqs on/off section: the syscall
11555 - * disabled irqs, here we enable it straight after entry:
11556 - */
11557 - ENABLE_INTERRUPTS(CLBR_NONE)
11558 movl %ebp,%ebp /* zero extension */
11559 pushq_cfi $__USER32_DS
11560 /*CFI_REL_OFFSET ss,0*/
11561 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11562 CFI_REL_OFFSET rsp,0
11563 pushfq_cfi
11564 /*CFI_REL_OFFSET rflags,0*/
11565 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11566 - CFI_REGISTER rip,r10
11567 + orl $X86_EFLAGS_IF,(%rsp)
11568 + GET_THREAD_INFO(%r11)
11569 + movl TI_sysenter_return(%r11), %r11d
11570 + CFI_REGISTER rip,r11
11571 pushq_cfi $__USER32_CS
11572 /*CFI_REL_OFFSET cs,0*/
11573 movl %eax, %eax
11574 - pushq_cfi %r10
11575 + pushq_cfi %r11
11576 CFI_REL_OFFSET rip,0
11577 pushq_cfi %rax
11578 cld
11579 SAVE_ARGS 0,1,0
11580 + pax_enter_kernel_user
11581 +
11582 +#ifdef CONFIG_PAX_RANDKSTACK
11583 + pax_erase_kstack
11584 +#endif
11585 +
11586 + /*
11587 + * No need to follow this irqs on/off section: the syscall
11588 + * disabled irqs, here we enable it straight after entry:
11589 + */
11590 + ENABLE_INTERRUPTS(CLBR_NONE)
11591 /* no need to do an access_ok check here because rbp has been
11592 32bit zero extended */
11593 +
11594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11595 + mov pax_user_shadow_base,%r11
11596 + add %r11,%rbp
11597 +#endif
11598 +
11599 ASM_STAC
11600 1: movl (%rbp),%ebp
11601 _ASM_EXTABLE(1b,ia32_badarg)
11602 ASM_CLAC
11603 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11604 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11605 + GET_THREAD_INFO(%r11)
11606 + orl $TS_COMPAT,TI_status(%r11)
11607 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11608 CFI_REMEMBER_STATE
11609 jnz sysenter_tracesys
11610 cmpq $(IA32_NR_syscalls-1),%rax
11611 @@ -162,12 +204,15 @@ sysenter_do_call:
11612 sysenter_dispatch:
11613 call *ia32_sys_call_table(,%rax,8)
11614 movq %rax,RAX-ARGOFFSET(%rsp)
11615 + GET_THREAD_INFO(%r11)
11616 DISABLE_INTERRUPTS(CLBR_NONE)
11617 TRACE_IRQS_OFF
11618 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11619 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11620 jnz sysexit_audit
11621 sysexit_from_sys_call:
11622 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11623 + pax_exit_kernel_user
11624 + pax_erase_kstack
11625 + andl $~TS_COMPAT,TI_status(%r11)
11626 /* clear IF, that popfq doesn't enable interrupts early */
11627 andl $~0x200,EFLAGS-R11(%rsp)
11628 movl RIP-R11(%rsp),%edx /* User %eip */
11629 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11630 movl %eax,%esi /* 2nd arg: syscall number */
11631 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11632 call __audit_syscall_entry
11633 +
11634 + pax_erase_kstack
11635 +
11636 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11637 cmpq $(IA32_NR_syscalls-1),%rax
11638 ja ia32_badsys
11639 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11640 .endm
11641
11642 .macro auditsys_exit exit
11643 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11644 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11645 jnz ia32_ret_from_sys_call
11646 TRACE_IRQS_ON
11647 ENABLE_INTERRUPTS(CLBR_NONE)
11648 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11649 1: setbe %al /* 1 if error, 0 if not */
11650 movzbl %al,%edi /* zero-extend that into %edi */
11651 call __audit_syscall_exit
11652 + GET_THREAD_INFO(%r11)
11653 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11654 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11655 DISABLE_INTERRUPTS(CLBR_NONE)
11656 TRACE_IRQS_OFF
11657 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11658 + testl %edi,TI_flags(%r11)
11659 jz \exit
11660 CLEAR_RREGS -ARGOFFSET
11661 jmp int_with_check
11662 @@ -237,7 +286,7 @@ sysexit_audit:
11663
11664 sysenter_tracesys:
11665 #ifdef CONFIG_AUDITSYSCALL
11666 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11667 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11668 jz sysenter_auditsys
11669 #endif
11670 SAVE_REST
11671 @@ -249,6 +298,9 @@ sysenter_tracesys:
11672 RESTORE_REST
11673 cmpq $(IA32_NR_syscalls-1),%rax
11674 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11675 +
11676 + pax_erase_kstack
11677 +
11678 jmp sysenter_do_call
11679 CFI_ENDPROC
11680 ENDPROC(ia32_sysenter_target)
11681 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11682 ENTRY(ia32_cstar_target)
11683 CFI_STARTPROC32 simple
11684 CFI_SIGNAL_FRAME
11685 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11686 + CFI_DEF_CFA rsp,0
11687 CFI_REGISTER rip,rcx
11688 /*CFI_REGISTER rflags,r11*/
11689 SWAPGS_UNSAFE_STACK
11690 movl %esp,%r8d
11691 CFI_REGISTER rsp,r8
11692 movq PER_CPU_VAR(kernel_stack),%rsp
11693 + SAVE_ARGS 8*6,0,0
11694 + pax_enter_kernel_user
11695 +
11696 +#ifdef CONFIG_PAX_RANDKSTACK
11697 + pax_erase_kstack
11698 +#endif
11699 +
11700 /*
11701 * No need to follow this irqs on/off section: the syscall
11702 * disabled irqs and here we enable it straight after entry:
11703 */
11704 ENABLE_INTERRUPTS(CLBR_NONE)
11705 - SAVE_ARGS 8,0,0
11706 movl %eax,%eax /* zero extension */
11707 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11708 movq %rcx,RIP-ARGOFFSET(%rsp)
11709 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11710 /* no need to do an access_ok check here because r8 has been
11711 32bit zero extended */
11712 /* hardware stack frame is complete now */
11713 +
11714 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11715 + mov pax_user_shadow_base,%r11
11716 + add %r11,%r8
11717 +#endif
11718 +
11719 ASM_STAC
11720 1: movl (%r8),%r9d
11721 _ASM_EXTABLE(1b,ia32_badarg)
11722 ASM_CLAC
11723 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11724 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11725 + GET_THREAD_INFO(%r11)
11726 + orl $TS_COMPAT,TI_status(%r11)
11727 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11728 CFI_REMEMBER_STATE
11729 jnz cstar_tracesys
11730 cmpq $IA32_NR_syscalls-1,%rax
11731 @@ -319,12 +384,15 @@ cstar_do_call:
11732 cstar_dispatch:
11733 call *ia32_sys_call_table(,%rax,8)
11734 movq %rax,RAX-ARGOFFSET(%rsp)
11735 + GET_THREAD_INFO(%r11)
11736 DISABLE_INTERRUPTS(CLBR_NONE)
11737 TRACE_IRQS_OFF
11738 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11739 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11740 jnz sysretl_audit
11741 sysretl_from_sys_call:
11742 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11743 + pax_exit_kernel_user
11744 + pax_erase_kstack
11745 + andl $~TS_COMPAT,TI_status(%r11)
11746 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11747 movl RIP-ARGOFFSET(%rsp),%ecx
11748 CFI_REGISTER rip,rcx
11749 @@ -352,7 +420,7 @@ sysretl_audit:
11750
11751 cstar_tracesys:
11752 #ifdef CONFIG_AUDITSYSCALL
11753 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11754 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11755 jz cstar_auditsys
11756 #endif
11757 xchgl %r9d,%ebp
11758 @@ -366,6 +434,9 @@ cstar_tracesys:
11759 xchgl %ebp,%r9d
11760 cmpq $(IA32_NR_syscalls-1),%rax
11761 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11762 +
11763 + pax_erase_kstack
11764 +
11765 jmp cstar_do_call
11766 END(ia32_cstar_target)
11767
11768 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11769 CFI_REL_OFFSET rip,RIP-RIP
11770 PARAVIRT_ADJUST_EXCEPTION_FRAME
11771 SWAPGS
11772 - /*
11773 - * No need to follow this irqs on/off section: the syscall
11774 - * disabled irqs and here we enable it straight after entry:
11775 - */
11776 - ENABLE_INTERRUPTS(CLBR_NONE)
11777 movl %eax,%eax
11778 pushq_cfi %rax
11779 cld
11780 /* note the registers are not zero extended to the sf.
11781 this could be a problem. */
11782 SAVE_ARGS 0,1,0
11783 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11784 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11785 + pax_enter_kernel_user
11786 +
11787 +#ifdef CONFIG_PAX_RANDKSTACK
11788 + pax_erase_kstack
11789 +#endif
11790 +
11791 + /*
11792 + * No need to follow this irqs on/off section: the syscall
11793 + * disabled irqs and here we enable it straight after entry:
11794 + */
11795 + ENABLE_INTERRUPTS(CLBR_NONE)
11796 + GET_THREAD_INFO(%r11)
11797 + orl $TS_COMPAT,TI_status(%r11)
11798 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11799 jnz ia32_tracesys
11800 cmpq $(IA32_NR_syscalls-1),%rax
11801 ja ia32_badsys
11802 @@ -442,6 +520,9 @@ ia32_tracesys:
11803 RESTORE_REST
11804 cmpq $(IA32_NR_syscalls-1),%rax
11805 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11806 +
11807 + pax_erase_kstack
11808 +
11809 jmp ia32_do_call
11810 END(ia32_syscall)
11811
11812 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11813 index ad7a20c..1ffa3c1 100644
11814 --- a/arch/x86/ia32/sys_ia32.c
11815 +++ b/arch/x86/ia32/sys_ia32.c
11816 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11817 */
11818 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11819 {
11820 - typeof(ubuf->st_uid) uid = 0;
11821 - typeof(ubuf->st_gid) gid = 0;
11822 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11823 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11824 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11825 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11826 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11827 @@ -205,7 +205,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
11828 return -EFAULT;
11829
11830 set_fs(KERNEL_DS);
11831 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
11832 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
11833 count);
11834 set_fs(old_fs);
11835
11836 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11837 index 372231c..a5aa1a1 100644
11838 --- a/arch/x86/include/asm/alternative-asm.h
11839 +++ b/arch/x86/include/asm/alternative-asm.h
11840 @@ -18,6 +18,45 @@
11841 .endm
11842 #endif
11843
11844 +#ifdef KERNEXEC_PLUGIN
11845 + .macro pax_force_retaddr_bts rip=0
11846 + btsq $63,\rip(%rsp)
11847 + .endm
11848 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11849 + .macro pax_force_retaddr rip=0, reload=0
11850 + btsq $63,\rip(%rsp)
11851 + .endm
11852 + .macro pax_force_fptr ptr
11853 + btsq $63,\ptr
11854 + .endm
11855 + .macro pax_set_fptr_mask
11856 + .endm
11857 +#endif
11858 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11859 + .macro pax_force_retaddr rip=0, reload=0
11860 + .if \reload
11861 + pax_set_fptr_mask
11862 + .endif
11863 + orq %r10,\rip(%rsp)
11864 + .endm
11865 + .macro pax_force_fptr ptr
11866 + orq %r10,\ptr
11867 + .endm
11868 + .macro pax_set_fptr_mask
11869 + movabs $0x8000000000000000,%r10
11870 + .endm
11871 +#endif
11872 +#else
11873 + .macro pax_force_retaddr rip=0, reload=0
11874 + .endm
11875 + .macro pax_force_fptr ptr
11876 + .endm
11877 + .macro pax_force_retaddr_bts rip=0
11878 + .endm
11879 + .macro pax_set_fptr_mask
11880 + .endm
11881 +#endif
11882 +
11883 .macro altinstruction_entry orig alt feature orig_len alt_len
11884 .long \orig - .
11885 .long \alt - .
11886 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11887 index 58ed6d9..f1cbe58 100644
11888 --- a/arch/x86/include/asm/alternative.h
11889 +++ b/arch/x86/include/asm/alternative.h
11890 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11891 ".pushsection .discard,\"aw\",@progbits\n" \
11892 DISCARD_ENTRY(1) \
11893 ".popsection\n" \
11894 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11895 + ".pushsection .altinstr_replacement, \"a\"\n" \
11896 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11897 ".popsection"
11898
11899 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11900 DISCARD_ENTRY(1) \
11901 DISCARD_ENTRY(2) \
11902 ".popsection\n" \
11903 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11904 + ".pushsection .altinstr_replacement, \"a\"\n" \
11905 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11906 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11907 ".popsection"
11908 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11909 index 3388034..050f0b9 100644
11910 --- a/arch/x86/include/asm/apic.h
11911 +++ b/arch/x86/include/asm/apic.h
11912 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11913
11914 #ifdef CONFIG_X86_LOCAL_APIC
11915
11916 -extern unsigned int apic_verbosity;
11917 +extern int apic_verbosity;
11918 extern int local_apic_timer_c2_ok;
11919
11920 extern int disable_apic;
11921 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11922 index 20370c6..a2eb9b0 100644
11923 --- a/arch/x86/include/asm/apm.h
11924 +++ b/arch/x86/include/asm/apm.h
11925 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11926 __asm__ __volatile__(APM_DO_ZERO_SEGS
11927 "pushl %%edi\n\t"
11928 "pushl %%ebp\n\t"
11929 - "lcall *%%cs:apm_bios_entry\n\t"
11930 + "lcall *%%ss:apm_bios_entry\n\t"
11931 "setc %%al\n\t"
11932 "popl %%ebp\n\t"
11933 "popl %%edi\n\t"
11934 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11935 __asm__ __volatile__(APM_DO_ZERO_SEGS
11936 "pushl %%edi\n\t"
11937 "pushl %%ebp\n\t"
11938 - "lcall *%%cs:apm_bios_entry\n\t"
11939 + "lcall *%%ss:apm_bios_entry\n\t"
11940 "setc %%bl\n\t"
11941 "popl %%ebp\n\t"
11942 "popl %%edi\n\t"
11943 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
11944 index 722aa3b..3a0bb27 100644
11945 --- a/arch/x86/include/asm/atomic.h
11946 +++ b/arch/x86/include/asm/atomic.h
11947 @@ -22,7 +22,18 @@
11948 */
11949 static inline int atomic_read(const atomic_t *v)
11950 {
11951 - return (*(volatile int *)&(v)->counter);
11952 + return (*(volatile const int *)&(v)->counter);
11953 +}
11954 +
11955 +/**
11956 + * atomic_read_unchecked - read atomic variable
11957 + * @v: pointer of type atomic_unchecked_t
11958 + *
11959 + * Atomically reads the value of @v.
11960 + */
11961 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
11962 +{
11963 + return (*(volatile const int *)&(v)->counter);
11964 }
11965
11966 /**
11967 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
11968 }
11969
11970 /**
11971 + * atomic_set_unchecked - set atomic variable
11972 + * @v: pointer of type atomic_unchecked_t
11973 + * @i: required value
11974 + *
11975 + * Atomically sets the value of @v to @i.
11976 + */
11977 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
11978 +{
11979 + v->counter = i;
11980 +}
11981 +
11982 +/**
11983 * atomic_add - add integer to atomic variable
11984 * @i: integer value to add
11985 * @v: pointer of type atomic_t
11986 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
11987 */
11988 static inline void atomic_add(int i, atomic_t *v)
11989 {
11990 - asm volatile(LOCK_PREFIX "addl %1,%0"
11991 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
11992 +
11993 +#ifdef CONFIG_PAX_REFCOUNT
11994 + "jno 0f\n"
11995 + LOCK_PREFIX "subl %1,%0\n"
11996 + "int $4\n0:\n"
11997 + _ASM_EXTABLE(0b, 0b)
11998 +#endif
11999 +
12000 + : "+m" (v->counter)
12001 + : "ir" (i));
12002 +}
12003 +
12004 +/**
12005 + * atomic_add_unchecked - add integer to atomic variable
12006 + * @i: integer value to add
12007 + * @v: pointer of type atomic_unchecked_t
12008 + *
12009 + * Atomically adds @i to @v.
12010 + */
12011 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12012 +{
12013 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12014 : "+m" (v->counter)
12015 : "ir" (i));
12016 }
12017 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12018 */
12019 static inline void atomic_sub(int i, atomic_t *v)
12020 {
12021 - asm volatile(LOCK_PREFIX "subl %1,%0"
12022 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12023 +
12024 +#ifdef CONFIG_PAX_REFCOUNT
12025 + "jno 0f\n"
12026 + LOCK_PREFIX "addl %1,%0\n"
12027 + "int $4\n0:\n"
12028 + _ASM_EXTABLE(0b, 0b)
12029 +#endif
12030 +
12031 + : "+m" (v->counter)
12032 + : "ir" (i));
12033 +}
12034 +
12035 +/**
12036 + * atomic_sub_unchecked - subtract integer from atomic variable
12037 + * @i: integer value to subtract
12038 + * @v: pointer of type atomic_unchecked_t
12039 + *
12040 + * Atomically subtracts @i from @v.
12041 + */
12042 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12043 +{
12044 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12045 : "+m" (v->counter)
12046 : "ir" (i));
12047 }
12048 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12049 {
12050 unsigned char c;
12051
12052 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12053 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12054 +
12055 +#ifdef CONFIG_PAX_REFCOUNT
12056 + "jno 0f\n"
12057 + LOCK_PREFIX "addl %2,%0\n"
12058 + "int $4\n0:\n"
12059 + _ASM_EXTABLE(0b, 0b)
12060 +#endif
12061 +
12062 + "sete %1\n"
12063 : "+m" (v->counter), "=qm" (c)
12064 : "ir" (i) : "memory");
12065 return c;
12066 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12067 */
12068 static inline void atomic_inc(atomic_t *v)
12069 {
12070 - asm volatile(LOCK_PREFIX "incl %0"
12071 + asm volatile(LOCK_PREFIX "incl %0\n"
12072 +
12073 +#ifdef CONFIG_PAX_REFCOUNT
12074 + "jno 0f\n"
12075 + LOCK_PREFIX "decl %0\n"
12076 + "int $4\n0:\n"
12077 + _ASM_EXTABLE(0b, 0b)
12078 +#endif
12079 +
12080 + : "+m" (v->counter));
12081 +}
12082 +
12083 +/**
12084 + * atomic_inc_unchecked - increment atomic variable
12085 + * @v: pointer of type atomic_unchecked_t
12086 + *
12087 + * Atomically increments @v by 1.
12088 + */
12089 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12090 +{
12091 + asm volatile(LOCK_PREFIX "incl %0\n"
12092 : "+m" (v->counter));
12093 }
12094
12095 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12096 */
12097 static inline void atomic_dec(atomic_t *v)
12098 {
12099 - asm volatile(LOCK_PREFIX "decl %0"
12100 + asm volatile(LOCK_PREFIX "decl %0\n"
12101 +
12102 +#ifdef CONFIG_PAX_REFCOUNT
12103 + "jno 0f\n"
12104 + LOCK_PREFIX "incl %0\n"
12105 + "int $4\n0:\n"
12106 + _ASM_EXTABLE(0b, 0b)
12107 +#endif
12108 +
12109 + : "+m" (v->counter));
12110 +}
12111 +
12112 +/**
12113 + * atomic_dec_unchecked - decrement atomic variable
12114 + * @v: pointer of type atomic_unchecked_t
12115 + *
12116 + * Atomically decrements @v by 1.
12117 + */
12118 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12119 +{
12120 + asm volatile(LOCK_PREFIX "decl %0\n"
12121 : "+m" (v->counter));
12122 }
12123
12124 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12125 {
12126 unsigned char c;
12127
12128 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12129 + asm volatile(LOCK_PREFIX "decl %0\n"
12130 +
12131 +#ifdef CONFIG_PAX_REFCOUNT
12132 + "jno 0f\n"
12133 + LOCK_PREFIX "incl %0\n"
12134 + "int $4\n0:\n"
12135 + _ASM_EXTABLE(0b, 0b)
12136 +#endif
12137 +
12138 + "sete %1\n"
12139 : "+m" (v->counter), "=qm" (c)
12140 : : "memory");
12141 return c != 0;
12142 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12143 {
12144 unsigned char c;
12145
12146 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12147 + asm volatile(LOCK_PREFIX "incl %0\n"
12148 +
12149 +#ifdef CONFIG_PAX_REFCOUNT
12150 + "jno 0f\n"
12151 + LOCK_PREFIX "decl %0\n"
12152 + "int $4\n0:\n"
12153 + _ASM_EXTABLE(0b, 0b)
12154 +#endif
12155 +
12156 + "sete %1\n"
12157 + : "+m" (v->counter), "=qm" (c)
12158 + : : "memory");
12159 + return c != 0;
12160 +}
12161 +
12162 +/**
12163 + * atomic_inc_and_test_unchecked - increment and test
12164 + * @v: pointer of type atomic_unchecked_t
12165 + *
12166 + * Atomically increments @v by 1
12167 + * and returns true if the result is zero, or false for all
12168 + * other cases.
12169 + */
12170 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12171 +{
12172 + unsigned char c;
12173 +
12174 + asm volatile(LOCK_PREFIX "incl %0\n"
12175 + "sete %1\n"
12176 : "+m" (v->counter), "=qm" (c)
12177 : : "memory");
12178 return c != 0;
12179 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12180 {
12181 unsigned char c;
12182
12183 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12184 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12185 +
12186 +#ifdef CONFIG_PAX_REFCOUNT
12187 + "jno 0f\n"
12188 + LOCK_PREFIX "subl %2,%0\n"
12189 + "int $4\n0:\n"
12190 + _ASM_EXTABLE(0b, 0b)
12191 +#endif
12192 +
12193 + "sets %1\n"
12194 : "+m" (v->counter), "=qm" (c)
12195 : "ir" (i) : "memory");
12196 return c;
12197 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12198 */
12199 static inline int atomic_add_return(int i, atomic_t *v)
12200 {
12201 + return i + xadd_check_overflow(&v->counter, i);
12202 +}
12203 +
12204 +/**
12205 + * atomic_add_return_unchecked - add integer and return
12206 + * @i: integer value to add
12207 + * @v: pointer of type atomic_unchecked_t
12208 + *
12209 + * Atomically adds @i to @v and returns @i + @v
12210 + */
12211 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12212 +{
12213 return i + xadd(&v->counter, i);
12214 }
12215
12216 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12217 }
12218
12219 #define atomic_inc_return(v) (atomic_add_return(1, v))
12220 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12221 +{
12222 + return atomic_add_return_unchecked(1, v);
12223 +}
12224 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12225
12226 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12227 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12228 return cmpxchg(&v->counter, old, new);
12229 }
12230
12231 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12232 +{
12233 + return cmpxchg(&v->counter, old, new);
12234 +}
12235 +
12236 static inline int atomic_xchg(atomic_t *v, int new)
12237 {
12238 return xchg(&v->counter, new);
12239 }
12240
12241 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12242 +{
12243 + return xchg(&v->counter, new);
12244 +}
12245 +
12246 /**
12247 * __atomic_add_unless - add unless the number is already a given value
12248 * @v: pointer of type atomic_t
12249 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12250 */
12251 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12252 {
12253 - int c, old;
12254 + int c, old, new;
12255 c = atomic_read(v);
12256 for (;;) {
12257 - if (unlikely(c == (u)))
12258 + if (unlikely(c == u))
12259 break;
12260 - old = atomic_cmpxchg((v), c, c + (a));
12261 +
12262 + asm volatile("addl %2,%0\n"
12263 +
12264 +#ifdef CONFIG_PAX_REFCOUNT
12265 + "jno 0f\n"
12266 + "subl %2,%0\n"
12267 + "int $4\n0:\n"
12268 + _ASM_EXTABLE(0b, 0b)
12269 +#endif
12270 +
12271 + : "=r" (new)
12272 + : "0" (c), "ir" (a));
12273 +
12274 + old = atomic_cmpxchg(v, c, new);
12275 if (likely(old == c))
12276 break;
12277 c = old;
12278 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12279 }
12280
12281 /**
12282 + * atomic_inc_not_zero_hint - increment if not null
12283 + * @v: pointer of type atomic_t
12284 + * @hint: probable value of the atomic before the increment
12285 + *
12286 + * This version of atomic_inc_not_zero() gives a hint of probable
12287 + * value of the atomic. This helps processor to not read the memory
12288 + * before doing the atomic read/modify/write cycle, lowering
12289 + * number of bus transactions on some arches.
12290 + *
12291 + * Returns: 0 if increment was not done, 1 otherwise.
12292 + */
12293 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12294 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12295 +{
12296 + int val, c = hint, new;
12297 +
12298 + /* sanity test, should be removed by compiler if hint is a constant */
12299 + if (!hint)
12300 + return __atomic_add_unless(v, 1, 0);
12301 +
12302 + do {
12303 + asm volatile("incl %0\n"
12304 +
12305 +#ifdef CONFIG_PAX_REFCOUNT
12306 + "jno 0f\n"
12307 + "decl %0\n"
12308 + "int $4\n0:\n"
12309 + _ASM_EXTABLE(0b, 0b)
12310 +#endif
12311 +
12312 + : "=r" (new)
12313 + : "0" (c));
12314 +
12315 + val = atomic_cmpxchg(v, c, new);
12316 + if (val == c)
12317 + return 1;
12318 + c = val;
12319 + } while (c);
12320 +
12321 + return 0;
12322 +}
12323 +
12324 +/**
12325 * atomic_inc_short - increment of a short integer
12326 * @v: pointer to type int
12327 *
12328 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12329 #endif
12330
12331 /* These are x86-specific, used by some header files */
12332 -#define atomic_clear_mask(mask, addr) \
12333 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12334 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12335 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12336 +{
12337 + asm volatile(LOCK_PREFIX "andl %1,%0"
12338 + : "+m" (v->counter)
12339 + : "r" (~(mask))
12340 + : "memory");
12341 +}
12342
12343 -#define atomic_set_mask(mask, addr) \
12344 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12345 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12346 - : "memory")
12347 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12348 +{
12349 + asm volatile(LOCK_PREFIX "andl %1,%0"
12350 + : "+m" (v->counter)
12351 + : "r" (~(mask))
12352 + : "memory");
12353 +}
12354 +
12355 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12356 +{
12357 + asm volatile(LOCK_PREFIX "orl %1,%0"
12358 + : "+m" (v->counter)
12359 + : "r" (mask)
12360 + : "memory");
12361 +}
12362 +
12363 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12364 +{
12365 + asm volatile(LOCK_PREFIX "orl %1,%0"
12366 + : "+m" (v->counter)
12367 + : "r" (mask)
12368 + : "memory");
12369 +}
12370
12371 /* Atomic operations are already serializing on x86 */
12372 #define smp_mb__before_atomic_dec() barrier()
12373 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12374 index b154de7..aadebd8 100644
12375 --- a/arch/x86/include/asm/atomic64_32.h
12376 +++ b/arch/x86/include/asm/atomic64_32.h
12377 @@ -12,6 +12,14 @@ typedef struct {
12378 u64 __aligned(8) counter;
12379 } atomic64_t;
12380
12381 +#ifdef CONFIG_PAX_REFCOUNT
12382 +typedef struct {
12383 + u64 __aligned(8) counter;
12384 +} atomic64_unchecked_t;
12385 +#else
12386 +typedef atomic64_t atomic64_unchecked_t;
12387 +#endif
12388 +
12389 #define ATOMIC64_INIT(val) { (val) }
12390
12391 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12392 @@ -37,21 +45,31 @@ typedef struct {
12393 ATOMIC64_DECL_ONE(sym##_386)
12394
12395 ATOMIC64_DECL_ONE(add_386);
12396 +ATOMIC64_DECL_ONE(add_unchecked_386);
12397 ATOMIC64_DECL_ONE(sub_386);
12398 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12399 ATOMIC64_DECL_ONE(inc_386);
12400 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12401 ATOMIC64_DECL_ONE(dec_386);
12402 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12403 #endif
12404
12405 #define alternative_atomic64(f, out, in...) \
12406 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12407
12408 ATOMIC64_DECL(read);
12409 +ATOMIC64_DECL(read_unchecked);
12410 ATOMIC64_DECL(set);
12411 +ATOMIC64_DECL(set_unchecked);
12412 ATOMIC64_DECL(xchg);
12413 ATOMIC64_DECL(add_return);
12414 +ATOMIC64_DECL(add_return_unchecked);
12415 ATOMIC64_DECL(sub_return);
12416 +ATOMIC64_DECL(sub_return_unchecked);
12417 ATOMIC64_DECL(inc_return);
12418 +ATOMIC64_DECL(inc_return_unchecked);
12419 ATOMIC64_DECL(dec_return);
12420 +ATOMIC64_DECL(dec_return_unchecked);
12421 ATOMIC64_DECL(dec_if_positive);
12422 ATOMIC64_DECL(inc_not_zero);
12423 ATOMIC64_DECL(add_unless);
12424 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12425 }
12426
12427 /**
12428 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12429 + * @p: pointer to type atomic64_unchecked_t
12430 + * @o: expected value
12431 + * @n: new value
12432 + *
12433 + * Atomically sets @v to @n if it was equal to @o and returns
12434 + * the old value.
12435 + */
12436 +
12437 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12438 +{
12439 + return cmpxchg64(&v->counter, o, n);
12440 +}
12441 +
12442 +/**
12443 * atomic64_xchg - xchg atomic64 variable
12444 * @v: pointer to type atomic64_t
12445 * @n: value to assign
12446 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12447 }
12448
12449 /**
12450 + * atomic64_set_unchecked - set atomic64 variable
12451 + * @v: pointer to type atomic64_unchecked_t
12452 + * @n: value to assign
12453 + *
12454 + * Atomically sets the value of @v to @n.
12455 + */
12456 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12457 +{
12458 + unsigned high = (unsigned)(i >> 32);
12459 + unsigned low = (unsigned)i;
12460 + alternative_atomic64(set, /* no output */,
12461 + "S" (v), "b" (low), "c" (high)
12462 + : "eax", "edx", "memory");
12463 +}
12464 +
12465 +/**
12466 * atomic64_read - read atomic64 variable
12467 * @v: pointer to type atomic64_t
12468 *
12469 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12470 }
12471
12472 /**
12473 + * atomic64_read_unchecked - read atomic64 variable
12474 + * @v: pointer to type atomic64_unchecked_t
12475 + *
12476 + * Atomically reads the value of @v and returns it.
12477 + */
12478 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12479 +{
12480 + long long r;
12481 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12482 + return r;
12483 + }
12484 +
12485 +/**
12486 * atomic64_add_return - add and return
12487 * @i: integer value to add
12488 * @v: pointer to type atomic64_t
12489 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12490 return i;
12491 }
12492
12493 +/**
12494 + * atomic64_add_return_unchecked - add and return
12495 + * @i: integer value to add
12496 + * @v: pointer to type atomic64_unchecked_t
12497 + *
12498 + * Atomically adds @i to @v and returns @i + *@v
12499 + */
12500 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12501 +{
12502 + alternative_atomic64(add_return_unchecked,
12503 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12504 + ASM_NO_INPUT_CLOBBER("memory"));
12505 + return i;
12506 +}
12507 +
12508 /*
12509 * Other variants with different arithmetic operators:
12510 */
12511 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12512 return a;
12513 }
12514
12515 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12516 +{
12517 + long long a;
12518 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12519 + "S" (v) : "memory", "ecx");
12520 + return a;
12521 +}
12522 +
12523 static inline long long atomic64_dec_return(atomic64_t *v)
12524 {
12525 long long a;
12526 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12527 }
12528
12529 /**
12530 + * atomic64_add_unchecked - add integer to atomic64 variable
12531 + * @i: integer value to add
12532 + * @v: pointer to type atomic64_unchecked_t
12533 + *
12534 + * Atomically adds @i to @v.
12535 + */
12536 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12537 +{
12538 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12539 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12540 + ASM_NO_INPUT_CLOBBER("memory"));
12541 + return i;
12542 +}
12543 +
12544 +/**
12545 * atomic64_sub - subtract the atomic64 variable
12546 * @i: integer value to subtract
12547 * @v: pointer to type atomic64_t
12548 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12549 index 0e1cbfc..5623683 100644
12550 --- a/arch/x86/include/asm/atomic64_64.h
12551 +++ b/arch/x86/include/asm/atomic64_64.h
12552 @@ -18,7 +18,19 @@
12553 */
12554 static inline long atomic64_read(const atomic64_t *v)
12555 {
12556 - return (*(volatile long *)&(v)->counter);
12557 + return (*(volatile const long *)&(v)->counter);
12558 +}
12559 +
12560 +/**
12561 + * atomic64_read_unchecked - read atomic64 variable
12562 + * @v: pointer of type atomic64_unchecked_t
12563 + *
12564 + * Atomically reads the value of @v.
12565 + * Doesn't imply a read memory barrier.
12566 + */
12567 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12568 +{
12569 + return (*(volatile const long *)&(v)->counter);
12570 }
12571
12572 /**
12573 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12574 }
12575
12576 /**
12577 + * atomic64_set_unchecked - set atomic64 variable
12578 + * @v: pointer to type atomic64_unchecked_t
12579 + * @i: required value
12580 + *
12581 + * Atomically sets the value of @v to @i.
12582 + */
12583 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12584 +{
12585 + v->counter = i;
12586 +}
12587 +
12588 +/**
12589 * atomic64_add - add integer to atomic64 variable
12590 * @i: integer value to add
12591 * @v: pointer to type atomic64_t
12592 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12593 */
12594 static inline void atomic64_add(long i, atomic64_t *v)
12595 {
12596 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12597 +
12598 +#ifdef CONFIG_PAX_REFCOUNT
12599 + "jno 0f\n"
12600 + LOCK_PREFIX "subq %1,%0\n"
12601 + "int $4\n0:\n"
12602 + _ASM_EXTABLE(0b, 0b)
12603 +#endif
12604 +
12605 + : "=m" (v->counter)
12606 + : "er" (i), "m" (v->counter));
12607 +}
12608 +
12609 +/**
12610 + * atomic64_add_unchecked - add integer to atomic64 variable
12611 + * @i: integer value to add
12612 + * @v: pointer to type atomic64_unchecked_t
12613 + *
12614 + * Atomically adds @i to @v.
12615 + */
12616 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12617 +{
12618 asm volatile(LOCK_PREFIX "addq %1,%0"
12619 : "=m" (v->counter)
12620 : "er" (i), "m" (v->counter));
12621 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12622 */
12623 static inline void atomic64_sub(long i, atomic64_t *v)
12624 {
12625 - asm volatile(LOCK_PREFIX "subq %1,%0"
12626 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12627 +
12628 +#ifdef CONFIG_PAX_REFCOUNT
12629 + "jno 0f\n"
12630 + LOCK_PREFIX "addq %1,%0\n"
12631 + "int $4\n0:\n"
12632 + _ASM_EXTABLE(0b, 0b)
12633 +#endif
12634 +
12635 + : "=m" (v->counter)
12636 + : "er" (i), "m" (v->counter));
12637 +}
12638 +
12639 +/**
12640 + * atomic64_sub_unchecked - subtract the atomic64 variable
12641 + * @i: integer value to subtract
12642 + * @v: pointer to type atomic64_unchecked_t
12643 + *
12644 + * Atomically subtracts @i from @v.
12645 + */
12646 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12647 +{
12648 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12649 : "=m" (v->counter)
12650 : "er" (i), "m" (v->counter));
12651 }
12652 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12653 {
12654 unsigned char c;
12655
12656 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12657 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12658 +
12659 +#ifdef CONFIG_PAX_REFCOUNT
12660 + "jno 0f\n"
12661 + LOCK_PREFIX "addq %2,%0\n"
12662 + "int $4\n0:\n"
12663 + _ASM_EXTABLE(0b, 0b)
12664 +#endif
12665 +
12666 + "sete %1\n"
12667 : "=m" (v->counter), "=qm" (c)
12668 : "er" (i), "m" (v->counter) : "memory");
12669 return c;
12670 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12671 */
12672 static inline void atomic64_inc(atomic64_t *v)
12673 {
12674 + asm volatile(LOCK_PREFIX "incq %0\n"
12675 +
12676 +#ifdef CONFIG_PAX_REFCOUNT
12677 + "jno 0f\n"
12678 + LOCK_PREFIX "decq %0\n"
12679 + "int $4\n0:\n"
12680 + _ASM_EXTABLE(0b, 0b)
12681 +#endif
12682 +
12683 + : "=m" (v->counter)
12684 + : "m" (v->counter));
12685 +}
12686 +
12687 +/**
12688 + * atomic64_inc_unchecked - increment atomic64 variable
12689 + * @v: pointer to type atomic64_unchecked_t
12690 + *
12691 + * Atomically increments @v by 1.
12692 + */
12693 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12694 +{
12695 asm volatile(LOCK_PREFIX "incq %0"
12696 : "=m" (v->counter)
12697 : "m" (v->counter));
12698 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12699 */
12700 static inline void atomic64_dec(atomic64_t *v)
12701 {
12702 - asm volatile(LOCK_PREFIX "decq %0"
12703 + asm volatile(LOCK_PREFIX "decq %0\n"
12704 +
12705 +#ifdef CONFIG_PAX_REFCOUNT
12706 + "jno 0f\n"
12707 + LOCK_PREFIX "incq %0\n"
12708 + "int $4\n0:\n"
12709 + _ASM_EXTABLE(0b, 0b)
12710 +#endif
12711 +
12712 + : "=m" (v->counter)
12713 + : "m" (v->counter));
12714 +}
12715 +
12716 +/**
12717 + * atomic64_dec_unchecked - decrement atomic64 variable
12718 + * @v: pointer to type atomic64_t
12719 + *
12720 + * Atomically decrements @v by 1.
12721 + */
12722 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12723 +{
12724 + asm volatile(LOCK_PREFIX "decq %0\n"
12725 : "=m" (v->counter)
12726 : "m" (v->counter));
12727 }
12728 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12729 {
12730 unsigned char c;
12731
12732 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12733 + asm volatile(LOCK_PREFIX "decq %0\n"
12734 +
12735 +#ifdef CONFIG_PAX_REFCOUNT
12736 + "jno 0f\n"
12737 + LOCK_PREFIX "incq %0\n"
12738 + "int $4\n0:\n"
12739 + _ASM_EXTABLE(0b, 0b)
12740 +#endif
12741 +
12742 + "sete %1\n"
12743 : "=m" (v->counter), "=qm" (c)
12744 : "m" (v->counter) : "memory");
12745 return c != 0;
12746 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12747 {
12748 unsigned char c;
12749
12750 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12751 + asm volatile(LOCK_PREFIX "incq %0\n"
12752 +
12753 +#ifdef CONFIG_PAX_REFCOUNT
12754 + "jno 0f\n"
12755 + LOCK_PREFIX "decq %0\n"
12756 + "int $4\n0:\n"
12757 + _ASM_EXTABLE(0b, 0b)
12758 +#endif
12759 +
12760 + "sete %1\n"
12761 : "=m" (v->counter), "=qm" (c)
12762 : "m" (v->counter) : "memory");
12763 return c != 0;
12764 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12765 {
12766 unsigned char c;
12767
12768 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12769 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12770 +
12771 +#ifdef CONFIG_PAX_REFCOUNT
12772 + "jno 0f\n"
12773 + LOCK_PREFIX "subq %2,%0\n"
12774 + "int $4\n0:\n"
12775 + _ASM_EXTABLE(0b, 0b)
12776 +#endif
12777 +
12778 + "sets %1\n"
12779 : "=m" (v->counter), "=qm" (c)
12780 : "er" (i), "m" (v->counter) : "memory");
12781 return c;
12782 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12783 */
12784 static inline long atomic64_add_return(long i, atomic64_t *v)
12785 {
12786 + return i + xadd_check_overflow(&v->counter, i);
12787 +}
12788 +
12789 +/**
12790 + * atomic64_add_return_unchecked - add and return
12791 + * @i: integer value to add
12792 + * @v: pointer to type atomic64_unchecked_t
12793 + *
12794 + * Atomically adds @i to @v and returns @i + @v
12795 + */
12796 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12797 +{
12798 return i + xadd(&v->counter, i);
12799 }
12800
12801 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12802 }
12803
12804 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12805 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12806 +{
12807 + return atomic64_add_return_unchecked(1, v);
12808 +}
12809 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12810
12811 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12812 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12813 return cmpxchg(&v->counter, old, new);
12814 }
12815
12816 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12817 +{
12818 + return cmpxchg(&v->counter, old, new);
12819 +}
12820 +
12821 static inline long atomic64_xchg(atomic64_t *v, long new)
12822 {
12823 return xchg(&v->counter, new);
12824 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12825 */
12826 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12827 {
12828 - long c, old;
12829 + long c, old, new;
12830 c = atomic64_read(v);
12831 for (;;) {
12832 - if (unlikely(c == (u)))
12833 + if (unlikely(c == u))
12834 break;
12835 - old = atomic64_cmpxchg((v), c, c + (a));
12836 +
12837 + asm volatile("add %2,%0\n"
12838 +
12839 +#ifdef CONFIG_PAX_REFCOUNT
12840 + "jno 0f\n"
12841 + "sub %2,%0\n"
12842 + "int $4\n0:\n"
12843 + _ASM_EXTABLE(0b, 0b)
12844 +#endif
12845 +
12846 + : "=r" (new)
12847 + : "0" (c), "ir" (a));
12848 +
12849 + old = atomic64_cmpxchg(v, c, new);
12850 if (likely(old == c))
12851 break;
12852 c = old;
12853 }
12854 - return c != (u);
12855 + return c != u;
12856 }
12857
12858 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12859 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12860 index 6dfd019..28e188d 100644
12861 --- a/arch/x86/include/asm/bitops.h
12862 +++ b/arch/x86/include/asm/bitops.h
12863 @@ -40,7 +40,7 @@
12864 * a mask operation on a byte.
12865 */
12866 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12867 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12868 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12869 #define CONST_MASK(nr) (1 << ((nr) & 7))
12870
12871 /**
12872 @@ -486,7 +486,7 @@ static inline int fls(int x)
12873 * at position 64.
12874 */
12875 #ifdef CONFIG_X86_64
12876 -static __always_inline int fls64(__u64 x)
12877 +static __always_inline long fls64(__u64 x)
12878 {
12879 int bitpos = -1;
12880 /*
12881 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12882 index 4fa687a..60f2d39 100644
12883 --- a/arch/x86/include/asm/boot.h
12884 +++ b/arch/x86/include/asm/boot.h
12885 @@ -6,10 +6,15 @@
12886 #include <uapi/asm/boot.h>
12887
12888 /* Physical address where kernel should be loaded. */
12889 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12890 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12891 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12892 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12893
12894 +#ifndef __ASSEMBLY__
12895 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12896 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12897 +#endif
12898 +
12899 /* Minimum kernel alignment, as a power of two */
12900 #ifdef CONFIG_X86_64
12901 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12902 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12903 index 48f99f1..d78ebf9 100644
12904 --- a/arch/x86/include/asm/cache.h
12905 +++ b/arch/x86/include/asm/cache.h
12906 @@ -5,12 +5,13 @@
12907
12908 /* L1 cache line size */
12909 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12910 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12911 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12912
12913 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12914 +#define __read_only __attribute__((__section__(".data..read_only")))
12915
12916 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12917 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12918 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12919
12920 #ifdef CONFIG_X86_VSMP
12921 #ifdef CONFIG_SMP
12922 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12923 index 9863ee3..4a1f8e1 100644
12924 --- a/arch/x86/include/asm/cacheflush.h
12925 +++ b/arch/x86/include/asm/cacheflush.h
12926 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12927 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12928
12929 if (pg_flags == _PGMT_DEFAULT)
12930 - return -1;
12931 + return ~0UL;
12932 else if (pg_flags == _PGMT_WC)
12933 return _PAGE_CACHE_WC;
12934 else if (pg_flags == _PGMT_UC_MINUS)
12935 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
12936 index 46fc474..b02b0f9 100644
12937 --- a/arch/x86/include/asm/checksum_32.h
12938 +++ b/arch/x86/include/asm/checksum_32.h
12939 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
12940 int len, __wsum sum,
12941 int *src_err_ptr, int *dst_err_ptr);
12942
12943 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
12944 + int len, __wsum sum,
12945 + int *src_err_ptr, int *dst_err_ptr);
12946 +
12947 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
12948 + int len, __wsum sum,
12949 + int *src_err_ptr, int *dst_err_ptr);
12950 +
12951 /*
12952 * Note: when you get a NULL pointer exception here this means someone
12953 * passed in an incorrect kernel address to one of these functions.
12954 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
12955 int *err_ptr)
12956 {
12957 might_sleep();
12958 - return csum_partial_copy_generic((__force void *)src, dst,
12959 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
12960 len, sum, err_ptr, NULL);
12961 }
12962
12963 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
12964 {
12965 might_sleep();
12966 if (access_ok(VERIFY_WRITE, dst, len))
12967 - return csum_partial_copy_generic(src, (__force void *)dst,
12968 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
12969 len, sum, NULL, err_ptr);
12970
12971 if (len)
12972 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
12973 index 8d871ea..c1a0dc9 100644
12974 --- a/arch/x86/include/asm/cmpxchg.h
12975 +++ b/arch/x86/include/asm/cmpxchg.h
12976 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
12977 __compiletime_error("Bad argument size for cmpxchg");
12978 extern void __xadd_wrong_size(void)
12979 __compiletime_error("Bad argument size for xadd");
12980 +extern void __xadd_check_overflow_wrong_size(void)
12981 + __compiletime_error("Bad argument size for xadd_check_overflow");
12982 extern void __add_wrong_size(void)
12983 __compiletime_error("Bad argument size for add");
12984 +extern void __add_check_overflow_wrong_size(void)
12985 + __compiletime_error("Bad argument size for add_check_overflow");
12986
12987 /*
12988 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
12989 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
12990 __ret; \
12991 })
12992
12993 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
12994 + ({ \
12995 + __typeof__ (*(ptr)) __ret = (arg); \
12996 + switch (sizeof(*(ptr))) { \
12997 + case __X86_CASE_L: \
12998 + asm volatile (lock #op "l %0, %1\n" \
12999 + "jno 0f\n" \
13000 + "mov %0,%1\n" \
13001 + "int $4\n0:\n" \
13002 + _ASM_EXTABLE(0b, 0b) \
13003 + : "+r" (__ret), "+m" (*(ptr)) \
13004 + : : "memory", "cc"); \
13005 + break; \
13006 + case __X86_CASE_Q: \
13007 + asm volatile (lock #op "q %q0, %1\n" \
13008 + "jno 0f\n" \
13009 + "mov %0,%1\n" \
13010 + "int $4\n0:\n" \
13011 + _ASM_EXTABLE(0b, 0b) \
13012 + : "+r" (__ret), "+m" (*(ptr)) \
13013 + : : "memory", "cc"); \
13014 + break; \
13015 + default: \
13016 + __ ## op ## _check_overflow_wrong_size(); \
13017 + } \
13018 + __ret; \
13019 + })
13020 +
13021 /*
13022 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13023 * Since this is generally used to protect other memory information, we
13024 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13025 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13026 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13027
13028 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13029 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13030 +
13031 #define __add(ptr, inc, lock) \
13032 ({ \
13033 __typeof__ (*(ptr)) __ret = (inc); \
13034 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13035 index 59c6c40..5e0b22c 100644
13036 --- a/arch/x86/include/asm/compat.h
13037 +++ b/arch/x86/include/asm/compat.h
13038 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13039 typedef u32 compat_uint_t;
13040 typedef u32 compat_ulong_t;
13041 typedef u64 __attribute__((aligned(4))) compat_u64;
13042 -typedef u32 compat_uptr_t;
13043 +typedef u32 __user compat_uptr_t;
13044
13045 struct compat_timespec {
13046 compat_time_t tv_sec;
13047 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13048 index 93fe929..90858b7 100644
13049 --- a/arch/x86/include/asm/cpufeature.h
13050 +++ b/arch/x86/include/asm/cpufeature.h
13051 @@ -207,7 +207,7 @@
13052 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13053 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13054 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13055 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13056 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13057 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13058 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13059 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13060 @@ -377,7 +377,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13061 ".section .discard,\"aw\",@progbits\n"
13062 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13063 ".previous\n"
13064 - ".section .altinstr_replacement,\"ax\"\n"
13065 + ".section .altinstr_replacement,\"a\"\n"
13066 "3: movb $1,%0\n"
13067 "4:\n"
13068 ".previous\n"
13069 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13070 index 8bf1c06..b6ae785 100644
13071 --- a/arch/x86/include/asm/desc.h
13072 +++ b/arch/x86/include/asm/desc.h
13073 @@ -4,6 +4,7 @@
13074 #include <asm/desc_defs.h>
13075 #include <asm/ldt.h>
13076 #include <asm/mmu.h>
13077 +#include <asm/pgtable.h>
13078
13079 #include <linux/smp.h>
13080 #include <linux/percpu.h>
13081 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13082
13083 desc->type = (info->read_exec_only ^ 1) << 1;
13084 desc->type |= info->contents << 2;
13085 + desc->type |= info->seg_not_present ^ 1;
13086
13087 desc->s = 1;
13088 desc->dpl = 0x3;
13089 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13090 }
13091
13092 extern struct desc_ptr idt_descr;
13093 -extern gate_desc idt_table[];
13094 extern struct desc_ptr nmi_idt_descr;
13095 -extern gate_desc nmi_idt_table[];
13096 -
13097 -struct gdt_page {
13098 - struct desc_struct gdt[GDT_ENTRIES];
13099 -} __attribute__((aligned(PAGE_SIZE)));
13100 -
13101 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13102 +extern gate_desc idt_table[256];
13103 +extern gate_desc nmi_idt_table[256];
13104
13105 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13106 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13107 {
13108 - return per_cpu(gdt_page, cpu).gdt;
13109 + return cpu_gdt_table[cpu];
13110 }
13111
13112 #ifdef CONFIG_X86_64
13113 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13114 unsigned long base, unsigned dpl, unsigned flags,
13115 unsigned short seg)
13116 {
13117 - gate->a = (seg << 16) | (base & 0xffff);
13118 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13119 + gate->gate.offset_low = base;
13120 + gate->gate.seg = seg;
13121 + gate->gate.reserved = 0;
13122 + gate->gate.type = type;
13123 + gate->gate.s = 0;
13124 + gate->gate.dpl = dpl;
13125 + gate->gate.p = 1;
13126 + gate->gate.offset_high = base >> 16;
13127 }
13128
13129 #endif
13130 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13131
13132 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13133 {
13134 + pax_open_kernel();
13135 memcpy(&idt[entry], gate, sizeof(*gate));
13136 + pax_close_kernel();
13137 }
13138
13139 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13140 {
13141 + pax_open_kernel();
13142 memcpy(&ldt[entry], desc, 8);
13143 + pax_close_kernel();
13144 }
13145
13146 static inline void
13147 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13148 default: size = sizeof(*gdt); break;
13149 }
13150
13151 + pax_open_kernel();
13152 memcpy(&gdt[entry], desc, size);
13153 + pax_close_kernel();
13154 }
13155
13156 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13157 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13158
13159 static inline void native_load_tr_desc(void)
13160 {
13161 + pax_open_kernel();
13162 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13163 + pax_close_kernel();
13164 }
13165
13166 static inline void native_load_gdt(const struct desc_ptr *dtr)
13167 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13168 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13169 unsigned int i;
13170
13171 + pax_open_kernel();
13172 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13173 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13174 + pax_close_kernel();
13175 }
13176
13177 #define _LDT_empty(info) \
13178 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13179 preempt_enable();
13180 }
13181
13182 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13183 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13184 {
13185 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13186 }
13187 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13188 }
13189
13190 #ifdef CONFIG_X86_64
13191 -static inline void set_nmi_gate(int gate, void *addr)
13192 +static inline void set_nmi_gate(int gate, const void *addr)
13193 {
13194 gate_desc s;
13195
13196 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13197 }
13198 #endif
13199
13200 -static inline void _set_gate(int gate, unsigned type, void *addr,
13201 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13202 unsigned dpl, unsigned ist, unsigned seg)
13203 {
13204 gate_desc s;
13205 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13206 * Pentium F0 0F bugfix can have resulted in the mapped
13207 * IDT being write-protected.
13208 */
13209 -static inline void set_intr_gate(unsigned int n, void *addr)
13210 +static inline void set_intr_gate(unsigned int n, const void *addr)
13211 {
13212 BUG_ON((unsigned)n > 0xFF);
13213 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13214 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13215 /*
13216 * This routine sets up an interrupt gate at directory privilege level 3.
13217 */
13218 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13219 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13220 {
13221 BUG_ON((unsigned)n > 0xFF);
13222 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13223 }
13224
13225 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13226 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13227 {
13228 BUG_ON((unsigned)n > 0xFF);
13229 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13230 }
13231
13232 -static inline void set_trap_gate(unsigned int n, void *addr)
13233 +static inline void set_trap_gate(unsigned int n, const void *addr)
13234 {
13235 BUG_ON((unsigned)n > 0xFF);
13236 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13237 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13238 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13239 {
13240 BUG_ON((unsigned)n > 0xFF);
13241 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13242 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13243 }
13244
13245 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13246 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13247 {
13248 BUG_ON((unsigned)n > 0xFF);
13249 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13250 }
13251
13252 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13253 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13254 {
13255 BUG_ON((unsigned)n > 0xFF);
13256 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13257 }
13258
13259 +#ifdef CONFIG_X86_32
13260 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13261 +{
13262 + struct desc_struct d;
13263 +
13264 + if (likely(limit))
13265 + limit = (limit - 1UL) >> PAGE_SHIFT;
13266 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13267 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13268 +}
13269 +#endif
13270 +
13271 #endif /* _ASM_X86_DESC_H */
13272 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13273 index 278441f..b95a174 100644
13274 --- a/arch/x86/include/asm/desc_defs.h
13275 +++ b/arch/x86/include/asm/desc_defs.h
13276 @@ -31,6 +31,12 @@ struct desc_struct {
13277 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13278 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13279 };
13280 + struct {
13281 + u16 offset_low;
13282 + u16 seg;
13283 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13284 + unsigned offset_high: 16;
13285 + } gate;
13286 };
13287 } __attribute__((packed));
13288
13289 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13290 index ced283a..ffe04cc 100644
13291 --- a/arch/x86/include/asm/div64.h
13292 +++ b/arch/x86/include/asm/div64.h
13293 @@ -39,7 +39,7 @@
13294 __mod; \
13295 })
13296
13297 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13298 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13299 {
13300 union {
13301 u64 v64;
13302 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13303 index 9c999c1..3860cb8 100644
13304 --- a/arch/x86/include/asm/elf.h
13305 +++ b/arch/x86/include/asm/elf.h
13306 @@ -243,7 +243,25 @@ extern int force_personality32;
13307 the loader. We need to make sure that it is out of the way of the program
13308 that it will "exec", and that there is sufficient room for the brk. */
13309
13310 +#ifdef CONFIG_PAX_SEGMEXEC
13311 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13312 +#else
13313 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13314 +#endif
13315 +
13316 +#ifdef CONFIG_PAX_ASLR
13317 +#ifdef CONFIG_X86_32
13318 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13319 +
13320 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13321 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13322 +#else
13323 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13324 +
13325 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13326 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13327 +#endif
13328 +#endif
13329
13330 /* This yields a mask that user programs can use to figure out what
13331 instruction set this CPU supports. This could be done in user space,
13332 @@ -296,16 +314,12 @@ do { \
13333
13334 #define ARCH_DLINFO \
13335 do { \
13336 - if (vdso_enabled) \
13337 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13338 - (unsigned long)current->mm->context.vdso); \
13339 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13340 } while (0)
13341
13342 #define ARCH_DLINFO_X32 \
13343 do { \
13344 - if (vdso_enabled) \
13345 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13346 - (unsigned long)current->mm->context.vdso); \
13347 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13348 } while (0)
13349
13350 #define AT_SYSINFO 32
13351 @@ -320,7 +334,7 @@ else \
13352
13353 #endif /* !CONFIG_X86_32 */
13354
13355 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13356 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13357
13358 #define VDSO_ENTRY \
13359 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13360 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13361 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13362 #define compat_arch_setup_additional_pages syscall32_setup_pages
13363
13364 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13365 -#define arch_randomize_brk arch_randomize_brk
13366 -
13367 /*
13368 * True on X86_32 or when emulating IA32 on X86_64
13369 */
13370 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13371 index 75ce3f4..882e801 100644
13372 --- a/arch/x86/include/asm/emergency-restart.h
13373 +++ b/arch/x86/include/asm/emergency-restart.h
13374 @@ -13,6 +13,6 @@ enum reboot_type {
13375
13376 extern enum reboot_type reboot_type;
13377
13378 -extern void machine_emergency_restart(void);
13379 +extern void machine_emergency_restart(void) __noreturn;
13380
13381 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13382 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13383 index e25cc33..425d099 100644
13384 --- a/arch/x86/include/asm/fpu-internal.h
13385 +++ b/arch/x86/include/asm/fpu-internal.h
13386 @@ -127,7 +127,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13387 ({ \
13388 int err; \
13389 asm volatile(ASM_STAC "\n" \
13390 - "1:" #insn "\n\t" \
13391 + "1:" \
13392 + __copyuser_seg \
13393 + #insn "\n\t" \
13394 "2: " ASM_CLAC "\n" \
13395 ".section .fixup,\"ax\"\n" \
13396 "3: movl $-1,%[err]\n" \
13397 @@ -300,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13398 "emms\n\t" /* clear stack tags */
13399 "fildl %P[addr]", /* set F?P to defined value */
13400 X86_FEATURE_FXSAVE_LEAK,
13401 - [addr] "m" (tsk->thread.fpu.has_fpu));
13402 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13403
13404 return fpu_restore_checking(&tsk->thread.fpu);
13405 }
13406 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13407 index be27ba1..8f13ff9 100644
13408 --- a/arch/x86/include/asm/futex.h
13409 +++ b/arch/x86/include/asm/futex.h
13410 @@ -12,6 +12,7 @@
13411 #include <asm/smap.h>
13412
13413 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13414 + typecheck(u32 __user *, uaddr); \
13415 asm volatile("\t" ASM_STAC "\n" \
13416 "1:\t" insn "\n" \
13417 "2:\t" ASM_CLAC "\n" \
13418 @@ -20,15 +21,16 @@
13419 "\tjmp\t2b\n" \
13420 "\t.previous\n" \
13421 _ASM_EXTABLE(1b, 3b) \
13422 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13423 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13424 : "i" (-EFAULT), "0" (oparg), "1" (0))
13425
13426 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13427 + typecheck(u32 __user *, uaddr); \
13428 asm volatile("\t" ASM_STAC "\n" \
13429 "1:\tmovl %2, %0\n" \
13430 "\tmovl\t%0, %3\n" \
13431 "\t" insn "\n" \
13432 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13433 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13434 "\tjnz\t1b\n" \
13435 "3:\t" ASM_CLAC "\n" \
13436 "\t.section .fixup,\"ax\"\n" \
13437 @@ -38,7 +40,7 @@
13438 _ASM_EXTABLE(1b, 4b) \
13439 _ASM_EXTABLE(2b, 4b) \
13440 : "=&a" (oldval), "=&r" (ret), \
13441 - "+m" (*uaddr), "=&r" (tem) \
13442 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13443 : "r" (oparg), "i" (-EFAULT), "1" (0))
13444
13445 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13446 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13447
13448 switch (op) {
13449 case FUTEX_OP_SET:
13450 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13451 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13452 break;
13453 case FUTEX_OP_ADD:
13454 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13455 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13456 uaddr, oparg);
13457 break;
13458 case FUTEX_OP_OR:
13459 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13460 return -EFAULT;
13461
13462 asm volatile("\t" ASM_STAC "\n"
13463 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13464 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13465 "2:\t" ASM_CLAC "\n"
13466 "\t.section .fixup, \"ax\"\n"
13467 "3:\tmov %3, %0\n"
13468 "\tjmp 2b\n"
13469 "\t.previous\n"
13470 _ASM_EXTABLE(1b, 3b)
13471 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13472 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13473 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13474 : "memory"
13475 );
13476 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13477 index 10a78c3..cc77143 100644
13478 --- a/arch/x86/include/asm/hw_irq.h
13479 +++ b/arch/x86/include/asm/hw_irq.h
13480 @@ -147,8 +147,8 @@ extern void setup_ioapic_dest(void);
13481 extern void enable_IO_APIC(void);
13482
13483 /* Statistics */
13484 -extern atomic_t irq_err_count;
13485 -extern atomic_t irq_mis_count;
13486 +extern atomic_unchecked_t irq_err_count;
13487 +extern atomic_unchecked_t irq_mis_count;
13488
13489 /* EISA */
13490 extern void eisa_set_level_irq(unsigned int irq);
13491 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13492 index a203659..9889f1c 100644
13493 --- a/arch/x86/include/asm/i8259.h
13494 +++ b/arch/x86/include/asm/i8259.h
13495 @@ -62,7 +62,7 @@ struct legacy_pic {
13496 void (*init)(int auto_eoi);
13497 int (*irq_pending)(unsigned int irq);
13498 void (*make_irq)(unsigned int irq);
13499 -};
13500 +} __do_const;
13501
13502 extern struct legacy_pic *legacy_pic;
13503 extern struct legacy_pic null_legacy_pic;
13504 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13505 index d8e8eef..1765f78 100644
13506 --- a/arch/x86/include/asm/io.h
13507 +++ b/arch/x86/include/asm/io.h
13508 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13509 "m" (*(volatile type __force *)addr) barrier); }
13510
13511 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13512 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13513 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13514 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13515 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13516
13517 build_mmio_read(__readb, "b", unsigned char, "=q", )
13518 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13519 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13520 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13521 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13522
13523 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13524 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13525 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13526 return ioremap_nocache(offset, size);
13527 }
13528
13529 -extern void iounmap(volatile void __iomem *addr);
13530 +extern void iounmap(const volatile void __iomem *addr);
13531
13532 extern void set_iounmap_nonlazy(void);
13533
13534 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13535
13536 #include <linux/vmalloc.h>
13537
13538 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13539 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13540 +{
13541 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13542 +}
13543 +
13544 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13545 +{
13546 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13547 +}
13548 +
13549 /*
13550 * Convert a virtual cached pointer to an uncached pointer
13551 */
13552 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13553 index bba3cf8..06bc8da 100644
13554 --- a/arch/x86/include/asm/irqflags.h
13555 +++ b/arch/x86/include/asm/irqflags.h
13556 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13557 sti; \
13558 sysexit
13559
13560 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13561 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13562 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13563 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13564 +
13565 #else
13566 #define INTERRUPT_RETURN iret
13567 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13568 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13569 index 5a6d287..f815789 100644
13570 --- a/arch/x86/include/asm/kprobes.h
13571 +++ b/arch/x86/include/asm/kprobes.h
13572 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13573 #define RELATIVEJUMP_SIZE 5
13574 #define RELATIVECALL_OPCODE 0xe8
13575 #define RELATIVE_ADDR_SIZE 4
13576 -#define MAX_STACK_SIZE 64
13577 -#define MIN_STACK_SIZE(ADDR) \
13578 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13579 - THREAD_SIZE - (unsigned long)(ADDR))) \
13580 - ? (MAX_STACK_SIZE) \
13581 - : (((unsigned long)current_thread_info()) + \
13582 - THREAD_SIZE - (unsigned long)(ADDR)))
13583 +#define MAX_STACK_SIZE 64UL
13584 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13585
13586 #define flush_insn_slot(p) do { } while (0)
13587
13588 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13589 index 2d89e39..baee879 100644
13590 --- a/arch/x86/include/asm/local.h
13591 +++ b/arch/x86/include/asm/local.h
13592 @@ -10,33 +10,97 @@ typedef struct {
13593 atomic_long_t a;
13594 } local_t;
13595
13596 +typedef struct {
13597 + atomic_long_unchecked_t a;
13598 +} local_unchecked_t;
13599 +
13600 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13601
13602 #define local_read(l) atomic_long_read(&(l)->a)
13603 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13604 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13605 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13606
13607 static inline void local_inc(local_t *l)
13608 {
13609 - asm volatile(_ASM_INC "%0"
13610 + asm volatile(_ASM_INC "%0\n"
13611 +
13612 +#ifdef CONFIG_PAX_REFCOUNT
13613 + "jno 0f\n"
13614 + _ASM_DEC "%0\n"
13615 + "int $4\n0:\n"
13616 + _ASM_EXTABLE(0b, 0b)
13617 +#endif
13618 +
13619 + : "+m" (l->a.counter));
13620 +}
13621 +
13622 +static inline void local_inc_unchecked(local_unchecked_t *l)
13623 +{
13624 + asm volatile(_ASM_INC "%0\n"
13625 : "+m" (l->a.counter));
13626 }
13627
13628 static inline void local_dec(local_t *l)
13629 {
13630 - asm volatile(_ASM_DEC "%0"
13631 + asm volatile(_ASM_DEC "%0\n"
13632 +
13633 +#ifdef CONFIG_PAX_REFCOUNT
13634 + "jno 0f\n"
13635 + _ASM_INC "%0\n"
13636 + "int $4\n0:\n"
13637 + _ASM_EXTABLE(0b, 0b)
13638 +#endif
13639 +
13640 + : "+m" (l->a.counter));
13641 +}
13642 +
13643 +static inline void local_dec_unchecked(local_unchecked_t *l)
13644 +{
13645 + asm volatile(_ASM_DEC "%0\n"
13646 : "+m" (l->a.counter));
13647 }
13648
13649 static inline void local_add(long i, local_t *l)
13650 {
13651 - asm volatile(_ASM_ADD "%1,%0"
13652 + asm volatile(_ASM_ADD "%1,%0\n"
13653 +
13654 +#ifdef CONFIG_PAX_REFCOUNT
13655 + "jno 0f\n"
13656 + _ASM_SUB "%1,%0\n"
13657 + "int $4\n0:\n"
13658 + _ASM_EXTABLE(0b, 0b)
13659 +#endif
13660 +
13661 + : "+m" (l->a.counter)
13662 + : "ir" (i));
13663 +}
13664 +
13665 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13666 +{
13667 + asm volatile(_ASM_ADD "%1,%0\n"
13668 : "+m" (l->a.counter)
13669 : "ir" (i));
13670 }
13671
13672 static inline void local_sub(long i, local_t *l)
13673 {
13674 - asm volatile(_ASM_SUB "%1,%0"
13675 + asm volatile(_ASM_SUB "%1,%0\n"
13676 +
13677 +#ifdef CONFIG_PAX_REFCOUNT
13678 + "jno 0f\n"
13679 + _ASM_ADD "%1,%0\n"
13680 + "int $4\n0:\n"
13681 + _ASM_EXTABLE(0b, 0b)
13682 +#endif
13683 +
13684 + : "+m" (l->a.counter)
13685 + : "ir" (i));
13686 +}
13687 +
13688 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13689 +{
13690 + asm volatile(_ASM_SUB "%1,%0\n"
13691 : "+m" (l->a.counter)
13692 : "ir" (i));
13693 }
13694 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13695 {
13696 unsigned char c;
13697
13698 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13699 + asm volatile(_ASM_SUB "%2,%0\n"
13700 +
13701 +#ifdef CONFIG_PAX_REFCOUNT
13702 + "jno 0f\n"
13703 + _ASM_ADD "%2,%0\n"
13704 + "int $4\n0:\n"
13705 + _ASM_EXTABLE(0b, 0b)
13706 +#endif
13707 +
13708 + "sete %1\n"
13709 : "+m" (l->a.counter), "=qm" (c)
13710 : "ir" (i) : "memory");
13711 return c;
13712 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13713 {
13714 unsigned char c;
13715
13716 - asm volatile(_ASM_DEC "%0; sete %1"
13717 + asm volatile(_ASM_DEC "%0\n"
13718 +
13719 +#ifdef CONFIG_PAX_REFCOUNT
13720 + "jno 0f\n"
13721 + _ASM_INC "%0\n"
13722 + "int $4\n0:\n"
13723 + _ASM_EXTABLE(0b, 0b)
13724 +#endif
13725 +
13726 + "sete %1\n"
13727 : "+m" (l->a.counter), "=qm" (c)
13728 : : "memory");
13729 return c != 0;
13730 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13731 {
13732 unsigned char c;
13733
13734 - asm volatile(_ASM_INC "%0; sete %1"
13735 + asm volatile(_ASM_INC "%0\n"
13736 +
13737 +#ifdef CONFIG_PAX_REFCOUNT
13738 + "jno 0f\n"
13739 + _ASM_DEC "%0\n"
13740 + "int $4\n0:\n"
13741 + _ASM_EXTABLE(0b, 0b)
13742 +#endif
13743 +
13744 + "sete %1\n"
13745 : "+m" (l->a.counter), "=qm" (c)
13746 : : "memory");
13747 return c != 0;
13748 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13749 {
13750 unsigned char c;
13751
13752 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13753 + asm volatile(_ASM_ADD "%2,%0\n"
13754 +
13755 +#ifdef CONFIG_PAX_REFCOUNT
13756 + "jno 0f\n"
13757 + _ASM_SUB "%2,%0\n"
13758 + "int $4\n0:\n"
13759 + _ASM_EXTABLE(0b, 0b)
13760 +#endif
13761 +
13762 + "sets %1\n"
13763 : "+m" (l->a.counter), "=qm" (c)
13764 : "ir" (i) : "memory");
13765 return c;
13766 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13767 static inline long local_add_return(long i, local_t *l)
13768 {
13769 long __i = i;
13770 + asm volatile(_ASM_XADD "%0, %1\n"
13771 +
13772 +#ifdef CONFIG_PAX_REFCOUNT
13773 + "jno 0f\n"
13774 + _ASM_MOV "%0,%1\n"
13775 + "int $4\n0:\n"
13776 + _ASM_EXTABLE(0b, 0b)
13777 +#endif
13778 +
13779 + : "+r" (i), "+m" (l->a.counter)
13780 + : : "memory");
13781 + return i + __i;
13782 +}
13783 +
13784 +/**
13785 + * local_add_return_unchecked - add and return
13786 + * @i: integer value to add
13787 + * @l: pointer to type local_unchecked_t
13788 + *
13789 + * Atomically adds @i to @l and returns @i + @l
13790 + */
13791 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13792 +{
13793 + long __i = i;
13794 asm volatile(_ASM_XADD "%0, %1;"
13795 : "+r" (i), "+m" (l->a.counter)
13796 : : "memory");
13797 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13798
13799 #define local_cmpxchg(l, o, n) \
13800 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13801 +#define local_cmpxchg_unchecked(l, o, n) \
13802 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13803 /* Always has a lock prefix */
13804 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13805
13806 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13807 new file mode 100644
13808 index 0000000..2bfd3ba
13809 --- /dev/null
13810 +++ b/arch/x86/include/asm/mman.h
13811 @@ -0,0 +1,15 @@
13812 +#ifndef _X86_MMAN_H
13813 +#define _X86_MMAN_H
13814 +
13815 +#include <uapi/asm/mman.h>
13816 +
13817 +#ifdef __KERNEL__
13818 +#ifndef __ASSEMBLY__
13819 +#ifdef CONFIG_X86_32
13820 +#define arch_mmap_check i386_mmap_check
13821 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13822 +#endif
13823 +#endif
13824 +#endif
13825 +
13826 +#endif /* X86_MMAN_H */
13827 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13828 index 5f55e69..e20bfb1 100644
13829 --- a/arch/x86/include/asm/mmu.h
13830 +++ b/arch/x86/include/asm/mmu.h
13831 @@ -9,7 +9,7 @@
13832 * we put the segment information here.
13833 */
13834 typedef struct {
13835 - void *ldt;
13836 + struct desc_struct *ldt;
13837 int size;
13838
13839 #ifdef CONFIG_X86_64
13840 @@ -18,7 +18,19 @@ typedef struct {
13841 #endif
13842
13843 struct mutex lock;
13844 - void *vdso;
13845 + unsigned long vdso;
13846 +
13847 +#ifdef CONFIG_X86_32
13848 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13849 + unsigned long user_cs_base;
13850 + unsigned long user_cs_limit;
13851 +
13852 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13853 + cpumask_t cpu_user_cs_mask;
13854 +#endif
13855 +
13856 +#endif
13857 +#endif
13858 } mm_context_t;
13859
13860 #ifdef CONFIG_SMP
13861 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13862 index cdbf367..adb37ac 100644
13863 --- a/arch/x86/include/asm/mmu_context.h
13864 +++ b/arch/x86/include/asm/mmu_context.h
13865 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13866
13867 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13868 {
13869 +
13870 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13871 + unsigned int i;
13872 + pgd_t *pgd;
13873 +
13874 + pax_open_kernel();
13875 + pgd = get_cpu_pgd(smp_processor_id());
13876 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13877 + set_pgd_batched(pgd+i, native_make_pgd(0));
13878 + pax_close_kernel();
13879 +#endif
13880 +
13881 #ifdef CONFIG_SMP
13882 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13883 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13884 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13885 struct task_struct *tsk)
13886 {
13887 unsigned cpu = smp_processor_id();
13888 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13889 + int tlbstate = TLBSTATE_OK;
13890 +#endif
13891
13892 if (likely(prev != next)) {
13893 #ifdef CONFIG_SMP
13894 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13895 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13896 +#endif
13897 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13898 this_cpu_write(cpu_tlbstate.active_mm, next);
13899 #endif
13900 cpumask_set_cpu(cpu, mm_cpumask(next));
13901
13902 /* Re-load page tables */
13903 +#ifdef CONFIG_PAX_PER_CPU_PGD
13904 + pax_open_kernel();
13905 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13906 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13907 + pax_close_kernel();
13908 + load_cr3(get_cpu_pgd(cpu));
13909 +#else
13910 load_cr3(next->pgd);
13911 +#endif
13912
13913 /* stop flush ipis for the previous mm */
13914 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13915 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13916 */
13917 if (unlikely(prev->context.ldt != next->context.ldt))
13918 load_LDT_nolock(&next->context);
13919 - }
13920 +
13921 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13922 + if (!(__supported_pte_mask & _PAGE_NX)) {
13923 + smp_mb__before_clear_bit();
13924 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13925 + smp_mb__after_clear_bit();
13926 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13927 + }
13928 +#endif
13929 +
13930 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13931 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13932 + prev->context.user_cs_limit != next->context.user_cs_limit))
13933 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13934 #ifdef CONFIG_SMP
13935 + else if (unlikely(tlbstate != TLBSTATE_OK))
13936 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13937 +#endif
13938 +#endif
13939 +
13940 + }
13941 else {
13942 +
13943 +#ifdef CONFIG_PAX_PER_CPU_PGD
13944 + pax_open_kernel();
13945 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13946 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13947 + pax_close_kernel();
13948 + load_cr3(get_cpu_pgd(cpu));
13949 +#endif
13950 +
13951 +#ifdef CONFIG_SMP
13952 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13953 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
13954
13955 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13956 * tlb flush IPI delivery. We must reload CR3
13957 * to make sure to use no freed page tables.
13958 */
13959 +
13960 +#ifndef CONFIG_PAX_PER_CPU_PGD
13961 load_cr3(next->pgd);
13962 +#endif
13963 +
13964 load_LDT_nolock(&next->context);
13965 +
13966 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
13967 + if (!(__supported_pte_mask & _PAGE_NX))
13968 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13969 +#endif
13970 +
13971 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13972 +#ifdef CONFIG_PAX_PAGEEXEC
13973 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
13974 +#endif
13975 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13976 +#endif
13977 +
13978 }
13979 +#endif
13980 }
13981 -#endif
13982 }
13983
13984 #define activate_mm(prev, next) \
13985 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
13986 index e3b7819..b257c64 100644
13987 --- a/arch/x86/include/asm/module.h
13988 +++ b/arch/x86/include/asm/module.h
13989 @@ -5,6 +5,7 @@
13990
13991 #ifdef CONFIG_X86_64
13992 /* X86_64 does not define MODULE_PROC_FAMILY */
13993 +#define MODULE_PROC_FAMILY ""
13994 #elif defined CONFIG_M486
13995 #define MODULE_PROC_FAMILY "486 "
13996 #elif defined CONFIG_M586
13997 @@ -57,8 +58,20 @@
13998 #error unknown processor family
13999 #endif
14000
14001 -#ifdef CONFIG_X86_32
14002 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14003 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14004 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14005 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14006 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14007 +#else
14008 +#define MODULE_PAX_KERNEXEC ""
14009 #endif
14010
14011 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14012 +#define MODULE_PAX_UDEREF "UDEREF "
14013 +#else
14014 +#define MODULE_PAX_UDEREF ""
14015 +#endif
14016 +
14017 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14018 +
14019 #endif /* _ASM_X86_MODULE_H */
14020 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14021 index c0fa356..07a498a 100644
14022 --- a/arch/x86/include/asm/nmi.h
14023 +++ b/arch/x86/include/asm/nmi.h
14024 @@ -42,11 +42,11 @@ struct nmiaction {
14025 nmi_handler_t handler;
14026 unsigned long flags;
14027 const char *name;
14028 -};
14029 +} __do_const;
14030
14031 #define register_nmi_handler(t, fn, fg, n, init...) \
14032 ({ \
14033 - static struct nmiaction init fn##_na = { \
14034 + static const struct nmiaction init fn##_na = { \
14035 .handler = (fn), \
14036 .name = (n), \
14037 .flags = (fg), \
14038 @@ -54,7 +54,7 @@ struct nmiaction {
14039 __register_nmi_handler((t), &fn##_na); \
14040 })
14041
14042 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14043 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14044
14045 void unregister_nmi_handler(unsigned int, const char *);
14046
14047 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
14048 index 0f1ddee..e2fc3d1 100644
14049 --- a/arch/x86/include/asm/page_64.h
14050 +++ b/arch/x86/include/asm/page_64.h
14051 @@ -7,9 +7,9 @@
14052
14053 /* duplicated to the one in bootmem.h */
14054 extern unsigned long max_pfn;
14055 -extern unsigned long phys_base;
14056 +extern const unsigned long phys_base;
14057
14058 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
14059 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
14060 {
14061 unsigned long y = x - __START_KERNEL_map;
14062
14063 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14064 index 7361e47..16dc226 100644
14065 --- a/arch/x86/include/asm/paravirt.h
14066 +++ b/arch/x86/include/asm/paravirt.h
14067 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14068 return (pmd_t) { ret };
14069 }
14070
14071 -static inline pmdval_t pmd_val(pmd_t pmd)
14072 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14073 {
14074 pmdval_t ret;
14075
14076 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14077 val);
14078 }
14079
14080 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14081 +{
14082 + pgdval_t val = native_pgd_val(pgd);
14083 +
14084 + if (sizeof(pgdval_t) > sizeof(long))
14085 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14086 + val, (u64)val >> 32);
14087 + else
14088 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14089 + val);
14090 +}
14091 +
14092 static inline void pgd_clear(pgd_t *pgdp)
14093 {
14094 set_pgd(pgdp, __pgd(0));
14095 @@ -714,6 +726,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14096 pv_mmu_ops.set_fixmap(idx, phys, flags);
14097 }
14098
14099 +#ifdef CONFIG_PAX_KERNEXEC
14100 +static inline unsigned long pax_open_kernel(void)
14101 +{
14102 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14103 +}
14104 +
14105 +static inline unsigned long pax_close_kernel(void)
14106 +{
14107 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14108 +}
14109 +#else
14110 +static inline unsigned long pax_open_kernel(void) { return 0; }
14111 +static inline unsigned long pax_close_kernel(void) { return 0; }
14112 +#endif
14113 +
14114 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14115
14116 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14117 @@ -930,7 +957,7 @@ extern void default_banner(void);
14118
14119 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14120 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14121 -#define PARA_INDIRECT(addr) *%cs:addr
14122 +#define PARA_INDIRECT(addr) *%ss:addr
14123 #endif
14124
14125 #define INTERRUPT_RETURN \
14126 @@ -1005,6 +1032,21 @@ extern void default_banner(void);
14127 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14128 CLBR_NONE, \
14129 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14130 +
14131 +#define GET_CR0_INTO_RDI \
14132 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14133 + mov %rax,%rdi
14134 +
14135 +#define SET_RDI_INTO_CR0 \
14136 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14137 +
14138 +#define GET_CR3_INTO_RDI \
14139 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14140 + mov %rax,%rdi
14141 +
14142 +#define SET_RDI_INTO_CR3 \
14143 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14144 +
14145 #endif /* CONFIG_X86_32 */
14146
14147 #endif /* __ASSEMBLY__ */
14148 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14149 index b3b0ec1..b1cd3eb 100644
14150 --- a/arch/x86/include/asm/paravirt_types.h
14151 +++ b/arch/x86/include/asm/paravirt_types.h
14152 @@ -84,7 +84,7 @@ struct pv_init_ops {
14153 */
14154 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14155 unsigned long addr, unsigned len);
14156 -};
14157 +} __no_const;
14158
14159
14160 struct pv_lazy_ops {
14161 @@ -98,7 +98,7 @@ struct pv_time_ops {
14162 unsigned long long (*sched_clock)(void);
14163 unsigned long long (*steal_clock)(int cpu);
14164 unsigned long (*get_tsc_khz)(void);
14165 -};
14166 +} __no_const;
14167
14168 struct pv_cpu_ops {
14169 /* hooks for various privileged instructions */
14170 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14171
14172 void (*start_context_switch)(struct task_struct *prev);
14173 void (*end_context_switch)(struct task_struct *next);
14174 -};
14175 +} __no_const;
14176
14177 struct pv_irq_ops {
14178 /*
14179 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14180 unsigned long start_eip,
14181 unsigned long start_esp);
14182 #endif
14183 -};
14184 +} __no_const;
14185
14186 struct pv_mmu_ops {
14187 unsigned long (*read_cr2)(void);
14188 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14189 struct paravirt_callee_save make_pud;
14190
14191 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14192 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14193 #endif /* PAGETABLE_LEVELS == 4 */
14194 #endif /* PAGETABLE_LEVELS >= 3 */
14195
14196 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14197 an mfn. We can tell which is which from the index. */
14198 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14199 phys_addr_t phys, pgprot_t flags);
14200 +
14201 +#ifdef CONFIG_PAX_KERNEXEC
14202 + unsigned long (*pax_open_kernel)(void);
14203 + unsigned long (*pax_close_kernel)(void);
14204 +#endif
14205 +
14206 };
14207
14208 struct arch_spinlock;
14209 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14210 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14211 int (*spin_trylock)(struct arch_spinlock *lock);
14212 void (*spin_unlock)(struct arch_spinlock *lock);
14213 -};
14214 +} __no_const;
14215
14216 /* This contains all the paravirt structures: we get a convenient
14217 * number for each function using the offset which we use to indicate
14218 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14219 index b4389a4..7024269 100644
14220 --- a/arch/x86/include/asm/pgalloc.h
14221 +++ b/arch/x86/include/asm/pgalloc.h
14222 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14223 pmd_t *pmd, pte_t *pte)
14224 {
14225 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14226 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14227 +}
14228 +
14229 +static inline void pmd_populate_user(struct mm_struct *mm,
14230 + pmd_t *pmd, pte_t *pte)
14231 +{
14232 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14233 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14234 }
14235
14236 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14237
14238 #ifdef CONFIG_X86_PAE
14239 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14240 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14241 +{
14242 + pud_populate(mm, pudp, pmd);
14243 +}
14244 #else /* !CONFIG_X86_PAE */
14245 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14246 {
14247 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14248 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14249 }
14250 +
14251 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14252 +{
14253 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14254 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14255 +}
14256 #endif /* CONFIG_X86_PAE */
14257
14258 #if PAGETABLE_LEVELS > 3
14259 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14260 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14261 }
14262
14263 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14264 +{
14265 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14266 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14267 +}
14268 +
14269 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14270 {
14271 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14272 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14273 index f2b489c..4f7e2e5 100644
14274 --- a/arch/x86/include/asm/pgtable-2level.h
14275 +++ b/arch/x86/include/asm/pgtable-2level.h
14276 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14277
14278 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14279 {
14280 + pax_open_kernel();
14281 *pmdp = pmd;
14282 + pax_close_kernel();
14283 }
14284
14285 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14286 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14287 index 4cc9f2b..5fd9226 100644
14288 --- a/arch/x86/include/asm/pgtable-3level.h
14289 +++ b/arch/x86/include/asm/pgtable-3level.h
14290 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14291
14292 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14293 {
14294 + pax_open_kernel();
14295 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14296 + pax_close_kernel();
14297 }
14298
14299 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14300 {
14301 + pax_open_kernel();
14302 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14303 + pax_close_kernel();
14304 }
14305
14306 /*
14307 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14308 index 1e67223..dd6e7ea 100644
14309 --- a/arch/x86/include/asm/pgtable.h
14310 +++ b/arch/x86/include/asm/pgtable.h
14311 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14312
14313 #ifndef __PAGETABLE_PUD_FOLDED
14314 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14315 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14316 #define pgd_clear(pgd) native_pgd_clear(pgd)
14317 #endif
14318
14319 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14320
14321 #define arch_end_context_switch(prev) do {} while(0)
14322
14323 +#define pax_open_kernel() native_pax_open_kernel()
14324 +#define pax_close_kernel() native_pax_close_kernel()
14325 #endif /* CONFIG_PARAVIRT */
14326
14327 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14328 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14329 +
14330 +#ifdef CONFIG_PAX_KERNEXEC
14331 +static inline unsigned long native_pax_open_kernel(void)
14332 +{
14333 + unsigned long cr0;
14334 +
14335 + preempt_disable();
14336 + barrier();
14337 + cr0 = read_cr0() ^ X86_CR0_WP;
14338 + BUG_ON(cr0 & X86_CR0_WP);
14339 + write_cr0(cr0);
14340 + return cr0 ^ X86_CR0_WP;
14341 +}
14342 +
14343 +static inline unsigned long native_pax_close_kernel(void)
14344 +{
14345 + unsigned long cr0;
14346 +
14347 + cr0 = read_cr0() ^ X86_CR0_WP;
14348 + BUG_ON(!(cr0 & X86_CR0_WP));
14349 + write_cr0(cr0);
14350 + barrier();
14351 + preempt_enable_no_resched();
14352 + return cr0 ^ X86_CR0_WP;
14353 +}
14354 +#else
14355 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14356 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14357 +#endif
14358 +
14359 /*
14360 * The following only work if pte_present() is true.
14361 * Undefined behaviour if not..
14362 */
14363 +static inline int pte_user(pte_t pte)
14364 +{
14365 + return pte_val(pte) & _PAGE_USER;
14366 +}
14367 +
14368 static inline int pte_dirty(pte_t pte)
14369 {
14370 return pte_flags(pte) & _PAGE_DIRTY;
14371 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
14372 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
14373 }
14374
14375 +static inline unsigned long pgd_pfn(pgd_t pgd)
14376 +{
14377 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
14378 +}
14379 +
14380 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
14381
14382 static inline int pmd_large(pmd_t pte)
14383 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14384 return pte_clear_flags(pte, _PAGE_RW);
14385 }
14386
14387 +static inline pte_t pte_mkread(pte_t pte)
14388 +{
14389 + return __pte(pte_val(pte) | _PAGE_USER);
14390 +}
14391 +
14392 static inline pte_t pte_mkexec(pte_t pte)
14393 {
14394 - return pte_clear_flags(pte, _PAGE_NX);
14395 +#ifdef CONFIG_X86_PAE
14396 + if (__supported_pte_mask & _PAGE_NX)
14397 + return pte_clear_flags(pte, _PAGE_NX);
14398 + else
14399 +#endif
14400 + return pte_set_flags(pte, _PAGE_USER);
14401 +}
14402 +
14403 +static inline pte_t pte_exprotect(pte_t pte)
14404 +{
14405 +#ifdef CONFIG_X86_PAE
14406 + if (__supported_pte_mask & _PAGE_NX)
14407 + return pte_set_flags(pte, _PAGE_NX);
14408 + else
14409 +#endif
14410 + return pte_clear_flags(pte, _PAGE_USER);
14411 }
14412
14413 static inline pte_t pte_mkdirty(pte_t pte)
14414 @@ -394,6 +459,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14415 #endif
14416
14417 #ifndef __ASSEMBLY__
14418 +
14419 +#ifdef CONFIG_PAX_PER_CPU_PGD
14420 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14421 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14422 +{
14423 + return cpu_pgd[cpu];
14424 +}
14425 +#endif
14426 +
14427 #include <linux/mm_types.h>
14428 #include <linux/log2.h>
14429
14430 @@ -529,7 +603,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
14431 * Currently stuck as a macro due to indirect forward reference to
14432 * linux/mmzone.h's __section_mem_map_addr() definition:
14433 */
14434 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
14435 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
14436
14437 /* Find an entry in the second-level page table.. */
14438 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
14439 @@ -569,7 +643,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
14440 * Currently stuck as a macro due to indirect forward reference to
14441 * linux/mmzone.h's __section_mem_map_addr() definition:
14442 */
14443 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
14444 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
14445
14446 /* to find an entry in a page-table-directory. */
14447 static inline unsigned long pud_index(unsigned long address)
14448 @@ -584,7 +658,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14449
14450 static inline int pgd_bad(pgd_t pgd)
14451 {
14452 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14453 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14454 }
14455
14456 static inline int pgd_none(pgd_t pgd)
14457 @@ -607,7 +681,12 @@ static inline int pgd_none(pgd_t pgd)
14458 * pgd_offset() returns a (pgd_t *)
14459 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14460 */
14461 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14462 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14463 +
14464 +#ifdef CONFIG_PAX_PER_CPU_PGD
14465 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14466 +#endif
14467 +
14468 /*
14469 * a shortcut which implies the use of the kernel's pgd, instead
14470 * of a process's
14471 @@ -618,6 +697,22 @@ static inline int pgd_none(pgd_t pgd)
14472 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14473 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14474
14475 +#ifdef CONFIG_X86_32
14476 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14477 +#else
14478 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14479 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14480 +
14481 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14482 +#ifdef __ASSEMBLY__
14483 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
14484 +#else
14485 +extern unsigned long pax_user_shadow_base;
14486 +#endif
14487 +#endif
14488 +
14489 +#endif
14490 +
14491 #ifndef __ASSEMBLY__
14492
14493 extern int direct_gbpages;
14494 @@ -784,11 +879,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14495 * dst and src can be on the same page, but the range must not overlap,
14496 * and must not cross a page boundary.
14497 */
14498 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14499 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14500 {
14501 - memcpy(dst, src, count * sizeof(pgd_t));
14502 + pax_open_kernel();
14503 + while (count--)
14504 + *dst++ = *src++;
14505 + pax_close_kernel();
14506 }
14507
14508 +#ifdef CONFIG_PAX_PER_CPU_PGD
14509 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14510 +#endif
14511 +
14512 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14513 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14514 +#else
14515 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14516 +#endif
14517 +
14518 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
14519 static inline int page_level_shift(enum pg_level level)
14520 {
14521 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14522 index 9ee3221..b979c6b 100644
14523 --- a/arch/x86/include/asm/pgtable_32.h
14524 +++ b/arch/x86/include/asm/pgtable_32.h
14525 @@ -25,9 +25,6 @@
14526 struct mm_struct;
14527 struct vm_area_struct;
14528
14529 -extern pgd_t swapper_pg_dir[1024];
14530 -extern pgd_t initial_page_table[1024];
14531 -
14532 static inline void pgtable_cache_init(void) { }
14533 static inline void check_pgt_cache(void) { }
14534 void paging_init(void);
14535 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14536 # include <asm/pgtable-2level.h>
14537 #endif
14538
14539 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14540 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14541 +#ifdef CONFIG_X86_PAE
14542 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14543 +#endif
14544 +
14545 #if defined(CONFIG_HIGHPTE)
14546 #define pte_offset_map(dir, address) \
14547 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14548 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14549 /* Clear a kernel PTE and flush it from the TLB */
14550 #define kpte_clear_flush(ptep, vaddr) \
14551 do { \
14552 + pax_open_kernel(); \
14553 pte_clear(&init_mm, (vaddr), (ptep)); \
14554 + pax_close_kernel(); \
14555 __flush_tlb_one((vaddr)); \
14556 } while (0)
14557
14558 #endif /* !__ASSEMBLY__ */
14559
14560 +#define HAVE_ARCH_UNMAPPED_AREA
14561 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14562 +
14563 /*
14564 * kern_addr_valid() is (1) for FLATMEM and (0) for
14565 * SPARSEMEM and DISCONTIGMEM
14566 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14567 index ed5903b..c7fe163 100644
14568 --- a/arch/x86/include/asm/pgtable_32_types.h
14569 +++ b/arch/x86/include/asm/pgtable_32_types.h
14570 @@ -8,7 +8,7 @@
14571 */
14572 #ifdef CONFIG_X86_PAE
14573 # include <asm/pgtable-3level_types.h>
14574 -# define PMD_SIZE (1UL << PMD_SHIFT)
14575 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14576 # define PMD_MASK (~(PMD_SIZE - 1))
14577 #else
14578 # include <asm/pgtable-2level_types.h>
14579 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14580 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14581 #endif
14582
14583 +#ifdef CONFIG_PAX_KERNEXEC
14584 +#ifndef __ASSEMBLY__
14585 +extern unsigned char MODULES_EXEC_VADDR[];
14586 +extern unsigned char MODULES_EXEC_END[];
14587 +#endif
14588 +#include <asm/boot.h>
14589 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14590 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14591 +#else
14592 +#define ktla_ktva(addr) (addr)
14593 +#define ktva_ktla(addr) (addr)
14594 +#endif
14595 +
14596 #define MODULES_VADDR VMALLOC_START
14597 #define MODULES_END VMALLOC_END
14598 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14599 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14600 index e22c1db..23a625a 100644
14601 --- a/arch/x86/include/asm/pgtable_64.h
14602 +++ b/arch/x86/include/asm/pgtable_64.h
14603 @@ -16,10 +16,14 @@
14604
14605 extern pud_t level3_kernel_pgt[512];
14606 extern pud_t level3_ident_pgt[512];
14607 +extern pud_t level3_vmalloc_start_pgt[512];
14608 +extern pud_t level3_vmalloc_end_pgt[512];
14609 +extern pud_t level3_vmemmap_pgt[512];
14610 +extern pud_t level2_vmemmap_pgt[512];
14611 extern pmd_t level2_kernel_pgt[512];
14612 extern pmd_t level2_fixmap_pgt[512];
14613 -extern pmd_t level2_ident_pgt[512];
14614 -extern pgd_t init_level4_pgt[];
14615 +extern pmd_t level2_ident_pgt[512*2];
14616 +extern pgd_t init_level4_pgt[512];
14617
14618 #define swapper_pg_dir init_level4_pgt
14619
14620 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14621
14622 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14623 {
14624 + pax_open_kernel();
14625 *pmdp = pmd;
14626 + pax_close_kernel();
14627 }
14628
14629 static inline void native_pmd_clear(pmd_t *pmd)
14630 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14631
14632 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14633 {
14634 + pax_open_kernel();
14635 *pudp = pud;
14636 + pax_close_kernel();
14637 }
14638
14639 static inline void native_pud_clear(pud_t *pud)
14640 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14641
14642 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14643 {
14644 + pax_open_kernel();
14645 + *pgdp = pgd;
14646 + pax_close_kernel();
14647 +}
14648 +
14649 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14650 +{
14651 *pgdp = pgd;
14652 }
14653
14654 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14655 index 2d88344..4679fc3 100644
14656 --- a/arch/x86/include/asm/pgtable_64_types.h
14657 +++ b/arch/x86/include/asm/pgtable_64_types.h
14658 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
14659 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14660 #define MODULES_END _AC(0xffffffffff000000, UL)
14661 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14662 +#define MODULES_EXEC_VADDR MODULES_VADDR
14663 +#define MODULES_EXEC_END MODULES_END
14664 +
14665 +#define ktla_ktva(addr) (addr)
14666 +#define ktva_ktla(addr) (addr)
14667
14668 #define EARLY_DYNAMIC_PAGE_TABLES 64
14669
14670 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14671 index 567b5d0..bd91d64 100644
14672 --- a/arch/x86/include/asm/pgtable_types.h
14673 +++ b/arch/x86/include/asm/pgtable_types.h
14674 @@ -16,13 +16,12 @@
14675 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14676 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14677 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14678 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14679 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14680 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14681 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14682 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14683 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14684 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14685 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14686 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14687 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14688 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14689
14690 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14691 @@ -40,7 +39,6 @@
14692 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14693 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14694 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14695 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14696 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14697 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14698 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14699 @@ -57,8 +55,10 @@
14700
14701 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14702 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14703 -#else
14704 +#elif defined(CONFIG_KMEMCHECK)
14705 #define _PAGE_NX (_AT(pteval_t, 0))
14706 +#else
14707 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14708 #endif
14709
14710 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14711 @@ -116,6 +116,9 @@
14712 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14713 _PAGE_ACCESSED)
14714
14715 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14716 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14717 +
14718 #define __PAGE_KERNEL_EXEC \
14719 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14720 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14721 @@ -126,7 +129,7 @@
14722 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14723 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14724 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14725 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14726 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14727 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14728 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14729 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14730 @@ -188,8 +191,8 @@
14731 * bits are combined, this will alow user to access the high address mapped
14732 * VDSO in the presence of CONFIG_COMPAT_VDSO
14733 */
14734 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14735 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14736 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14737 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14738 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14739 #endif
14740
14741 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14742 {
14743 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14744 }
14745 +#endif
14746
14747 +#if PAGETABLE_LEVELS == 3
14748 +#include <asm-generic/pgtable-nopud.h>
14749 +#endif
14750 +
14751 +#if PAGETABLE_LEVELS == 2
14752 +#include <asm-generic/pgtable-nopmd.h>
14753 +#endif
14754 +
14755 +#ifndef __ASSEMBLY__
14756 #if PAGETABLE_LEVELS > 3
14757 typedef struct { pudval_t pud; } pud_t;
14758
14759 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14760 return pud.pud;
14761 }
14762 #else
14763 -#include <asm-generic/pgtable-nopud.h>
14764 -
14765 static inline pudval_t native_pud_val(pud_t pud)
14766 {
14767 return native_pgd_val(pud.pgd);
14768 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14769 return pmd.pmd;
14770 }
14771 #else
14772 -#include <asm-generic/pgtable-nopmd.h>
14773 -
14774 static inline pmdval_t native_pmd_val(pmd_t pmd)
14775 {
14776 return native_pgd_val(pmd.pud.pgd);
14777 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14778
14779 extern pteval_t __supported_pte_mask;
14780 extern void set_nx(void);
14781 -extern int nx_enabled;
14782
14783 #define pgprot_writecombine pgprot_writecombine
14784 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14785 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14786 index 3270116..8d99d82 100644
14787 --- a/arch/x86/include/asm/processor.h
14788 +++ b/arch/x86/include/asm/processor.h
14789 @@ -285,7 +285,7 @@ struct tss_struct {
14790
14791 } ____cacheline_aligned;
14792
14793 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14794 +extern struct tss_struct init_tss[NR_CPUS];
14795
14796 /*
14797 * Save the original ist values for checking stack pointers during debugging
14798 @@ -826,11 +826,18 @@ static inline void spin_lock_prefetch(const void *x)
14799 */
14800 #define TASK_SIZE PAGE_OFFSET
14801 #define TASK_SIZE_MAX TASK_SIZE
14802 +
14803 +#ifdef CONFIG_PAX_SEGMEXEC
14804 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14805 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14806 +#else
14807 #define STACK_TOP TASK_SIZE
14808 -#define STACK_TOP_MAX STACK_TOP
14809 +#endif
14810 +
14811 +#define STACK_TOP_MAX TASK_SIZE
14812
14813 #define INIT_THREAD { \
14814 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14815 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14816 .vm86_info = NULL, \
14817 .sysenter_cs = __KERNEL_CS, \
14818 .io_bitmap_ptr = NULL, \
14819 @@ -844,7 +851,7 @@ static inline void spin_lock_prefetch(const void *x)
14820 */
14821 #define INIT_TSS { \
14822 .x86_tss = { \
14823 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14824 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14825 .ss0 = __KERNEL_DS, \
14826 .ss1 = __KERNEL_CS, \
14827 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14828 @@ -855,11 +862,7 @@ static inline void spin_lock_prefetch(const void *x)
14829 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14830
14831 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14832 -#define KSTK_TOP(info) \
14833 -({ \
14834 - unsigned long *__ptr = (unsigned long *)(info); \
14835 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14836 -})
14837 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14838
14839 /*
14840 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14841 @@ -874,7 +877,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14842 #define task_pt_regs(task) \
14843 ({ \
14844 struct pt_regs *__regs__; \
14845 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14846 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14847 __regs__ - 1; \
14848 })
14849
14850 @@ -884,13 +887,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14851 /*
14852 * User space process size. 47bits minus one guard page.
14853 */
14854 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14855 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14856
14857 /* This decides where the kernel will search for a free chunk of vm
14858 * space during mmap's.
14859 */
14860 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14861 - 0xc0000000 : 0xFFFFe000)
14862 + 0xc0000000 : 0xFFFFf000)
14863
14864 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14865 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14866 @@ -901,11 +904,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14867 #define STACK_TOP_MAX TASK_SIZE_MAX
14868
14869 #define INIT_THREAD { \
14870 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14871 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14872 }
14873
14874 #define INIT_TSS { \
14875 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14876 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14877 }
14878
14879 /*
14880 @@ -933,6 +936,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14881 */
14882 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14883
14884 +#ifdef CONFIG_PAX_SEGMEXEC
14885 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14886 +#endif
14887 +
14888 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14889
14890 /* Get/set a process' ability to use the timestamp counter instruction */
14891 @@ -993,7 +1000,7 @@ extern bool cpu_has_amd_erratum(const int *);
14892 #define cpu_has_amd_erratum(x) (false)
14893 #endif /* CONFIG_CPU_SUP_AMD */
14894
14895 -extern unsigned long arch_align_stack(unsigned long sp);
14896 +#define arch_align_stack(x) ((x) & ~0xfUL)
14897 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14898
14899 void default_idle(void);
14900 @@ -1003,6 +1010,6 @@ bool xen_set_default_idle(void);
14901 #define xen_set_default_idle 0
14902 #endif
14903
14904 -void stop_this_cpu(void *dummy);
14905 +void stop_this_cpu(void *dummy) __noreturn;
14906
14907 #endif /* _ASM_X86_PROCESSOR_H */
14908 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14909 index 942a086..6c26446 100644
14910 --- a/arch/x86/include/asm/ptrace.h
14911 +++ b/arch/x86/include/asm/ptrace.h
14912 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14913 }
14914
14915 /*
14916 - * user_mode_vm(regs) determines whether a register set came from user mode.
14917 + * user_mode(regs) determines whether a register set came from user mode.
14918 * This is true if V8086 mode was enabled OR if the register set was from
14919 * protected mode with RPL-3 CS value. This tricky test checks that with
14920 * one comparison. Many places in the kernel can bypass this full check
14921 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14922 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14923 + * be used.
14924 */
14925 -static inline int user_mode(struct pt_regs *regs)
14926 +static inline int user_mode_novm(struct pt_regs *regs)
14927 {
14928 #ifdef CONFIG_X86_32
14929 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
14930 #else
14931 - return !!(regs->cs & 3);
14932 + return !!(regs->cs & SEGMENT_RPL_MASK);
14933 #endif
14934 }
14935
14936 -static inline int user_mode_vm(struct pt_regs *regs)
14937 +static inline int user_mode(struct pt_regs *regs)
14938 {
14939 #ifdef CONFIG_X86_32
14940 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
14941 USER_RPL;
14942 #else
14943 - return user_mode(regs);
14944 + return user_mode_novm(regs);
14945 #endif
14946 }
14947
14948 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
14949 #ifdef CONFIG_X86_64
14950 static inline bool user_64bit_mode(struct pt_regs *regs)
14951 {
14952 + unsigned long cs = regs->cs & 0xffff;
14953 #ifndef CONFIG_PARAVIRT
14954 /*
14955 * On non-paravirt systems, this is the only long mode CPL 3
14956 * selector. We do not allow long mode selectors in the LDT.
14957 */
14958 - return regs->cs == __USER_CS;
14959 + return cs == __USER_CS;
14960 #else
14961 /* Headers are too twisted for this to go in paravirt.h. */
14962 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
14963 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
14964 #endif
14965 }
14966
14967 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
14968 * Traps from the kernel do not save sp and ss.
14969 * Use the helper function to retrieve sp.
14970 */
14971 - if (offset == offsetof(struct pt_regs, sp) &&
14972 - regs->cs == __KERNEL_CS)
14973 - return kernel_stack_pointer(regs);
14974 + if (offset == offsetof(struct pt_regs, sp)) {
14975 + unsigned long cs = regs->cs & 0xffff;
14976 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
14977 + return kernel_stack_pointer(regs);
14978 + }
14979 #endif
14980 return *(unsigned long *)((unsigned long)regs + offset);
14981 }
14982 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
14983 index 9c6b890..5305f53 100644
14984 --- a/arch/x86/include/asm/realmode.h
14985 +++ b/arch/x86/include/asm/realmode.h
14986 @@ -22,16 +22,14 @@ struct real_mode_header {
14987 #endif
14988 /* APM/BIOS reboot */
14989 u32 machine_real_restart_asm;
14990 -#ifdef CONFIG_X86_64
14991 u32 machine_real_restart_seg;
14992 -#endif
14993 };
14994
14995 /* This must match data at trampoline_32/64.S */
14996 struct trampoline_header {
14997 #ifdef CONFIG_X86_32
14998 u32 start;
14999 - u16 gdt_pad;
15000 + u16 boot_cs;
15001 u16 gdt_limit;
15002 u32 gdt_base;
15003 #else
15004 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15005 index a82c4f1..ac45053 100644
15006 --- a/arch/x86/include/asm/reboot.h
15007 +++ b/arch/x86/include/asm/reboot.h
15008 @@ -6,13 +6,13 @@
15009 struct pt_regs;
15010
15011 struct machine_ops {
15012 - void (*restart)(char *cmd);
15013 - void (*halt)(void);
15014 - void (*power_off)(void);
15015 + void (* __noreturn restart)(char *cmd);
15016 + void (* __noreturn halt)(void);
15017 + void (* __noreturn power_off)(void);
15018 void (*shutdown)(void);
15019 void (*crash_shutdown)(struct pt_regs *);
15020 - void (*emergency_restart)(void);
15021 -};
15022 + void (* __noreturn emergency_restart)(void);
15023 +} __no_const;
15024
15025 extern struct machine_ops machine_ops;
15026
15027 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15028 index 2dbe4a7..ce1db00 100644
15029 --- a/arch/x86/include/asm/rwsem.h
15030 +++ b/arch/x86/include/asm/rwsem.h
15031 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15032 {
15033 asm volatile("# beginning down_read\n\t"
15034 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15035 +
15036 +#ifdef CONFIG_PAX_REFCOUNT
15037 + "jno 0f\n"
15038 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15039 + "int $4\n0:\n"
15040 + _ASM_EXTABLE(0b, 0b)
15041 +#endif
15042 +
15043 /* adds 0x00000001 */
15044 " jns 1f\n"
15045 " call call_rwsem_down_read_failed\n"
15046 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15047 "1:\n\t"
15048 " mov %1,%2\n\t"
15049 " add %3,%2\n\t"
15050 +
15051 +#ifdef CONFIG_PAX_REFCOUNT
15052 + "jno 0f\n"
15053 + "sub %3,%2\n"
15054 + "int $4\n0:\n"
15055 + _ASM_EXTABLE(0b, 0b)
15056 +#endif
15057 +
15058 " jle 2f\n\t"
15059 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15060 " jnz 1b\n\t"
15061 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15062 long tmp;
15063 asm volatile("# beginning down_write\n\t"
15064 LOCK_PREFIX " xadd %1,(%2)\n\t"
15065 +
15066 +#ifdef CONFIG_PAX_REFCOUNT
15067 + "jno 0f\n"
15068 + "mov %1,(%2)\n"
15069 + "int $4\n0:\n"
15070 + _ASM_EXTABLE(0b, 0b)
15071 +#endif
15072 +
15073 /* adds 0xffff0001, returns the old value */
15074 " test %1,%1\n\t"
15075 /* was the count 0 before? */
15076 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15077 long tmp;
15078 asm volatile("# beginning __up_read\n\t"
15079 LOCK_PREFIX " xadd %1,(%2)\n\t"
15080 +
15081 +#ifdef CONFIG_PAX_REFCOUNT
15082 + "jno 0f\n"
15083 + "mov %1,(%2)\n"
15084 + "int $4\n0:\n"
15085 + _ASM_EXTABLE(0b, 0b)
15086 +#endif
15087 +
15088 /* subtracts 1, returns the old value */
15089 " jns 1f\n\t"
15090 " call call_rwsem_wake\n" /* expects old value in %edx */
15091 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15092 long tmp;
15093 asm volatile("# beginning __up_write\n\t"
15094 LOCK_PREFIX " xadd %1,(%2)\n\t"
15095 +
15096 +#ifdef CONFIG_PAX_REFCOUNT
15097 + "jno 0f\n"
15098 + "mov %1,(%2)\n"
15099 + "int $4\n0:\n"
15100 + _ASM_EXTABLE(0b, 0b)
15101 +#endif
15102 +
15103 /* subtracts 0xffff0001, returns the old value */
15104 " jns 1f\n\t"
15105 " call call_rwsem_wake\n" /* expects old value in %edx */
15106 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15107 {
15108 asm volatile("# beginning __downgrade_write\n\t"
15109 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15110 +
15111 +#ifdef CONFIG_PAX_REFCOUNT
15112 + "jno 0f\n"
15113 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15114 + "int $4\n0:\n"
15115 + _ASM_EXTABLE(0b, 0b)
15116 +#endif
15117 +
15118 /*
15119 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15120 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15121 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15122 */
15123 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15124 {
15125 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15126 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15127 +
15128 +#ifdef CONFIG_PAX_REFCOUNT
15129 + "jno 0f\n"
15130 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15131 + "int $4\n0:\n"
15132 + _ASM_EXTABLE(0b, 0b)
15133 +#endif
15134 +
15135 : "+m" (sem->count)
15136 : "er" (delta));
15137 }
15138 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15139 */
15140 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15141 {
15142 - return delta + xadd(&sem->count, delta);
15143 + return delta + xadd_check_overflow(&sem->count, delta);
15144 }
15145
15146 #endif /* __KERNEL__ */
15147 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15148 index c48a950..c6d7468 100644
15149 --- a/arch/x86/include/asm/segment.h
15150 +++ b/arch/x86/include/asm/segment.h
15151 @@ -64,10 +64,15 @@
15152 * 26 - ESPFIX small SS
15153 * 27 - per-cpu [ offset to per-cpu data area ]
15154 * 28 - stack_canary-20 [ for stack protector ]
15155 - * 29 - unused
15156 - * 30 - unused
15157 + * 29 - PCI BIOS CS
15158 + * 30 - PCI BIOS DS
15159 * 31 - TSS for double fault handler
15160 */
15161 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15162 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15163 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15164 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15165 +
15166 #define GDT_ENTRY_TLS_MIN 6
15167 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15168
15169 @@ -79,6 +84,8 @@
15170
15171 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15172
15173 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15174 +
15175 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15176
15177 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15178 @@ -104,6 +111,12 @@
15179 #define __KERNEL_STACK_CANARY 0
15180 #endif
15181
15182 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15183 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15184 +
15185 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15186 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15187 +
15188 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15189
15190 /*
15191 @@ -141,7 +154,7 @@
15192 */
15193
15194 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15195 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15196 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15197
15198
15199 #else
15200 @@ -165,6 +178,8 @@
15201 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15202 #define __USER32_DS __USER_DS
15203
15204 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15205 +
15206 #define GDT_ENTRY_TSS 8 /* needs two entries */
15207 #define GDT_ENTRY_LDT 10 /* needs two entries */
15208 #define GDT_ENTRY_TLS_MIN 12
15209 @@ -185,6 +200,7 @@
15210 #endif
15211
15212 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15213 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15214 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15215 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15216 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15217 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15218 {
15219 unsigned long __limit;
15220 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15221 - return __limit + 1;
15222 + return __limit;
15223 }
15224
15225 #endif /* !__ASSEMBLY__ */
15226 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15227 index b073aae..39f9bdd 100644
15228 --- a/arch/x86/include/asm/smp.h
15229 +++ b/arch/x86/include/asm/smp.h
15230 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15231 /* cpus sharing the last level cache: */
15232 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15233 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15234 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15235 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15236
15237 static inline struct cpumask *cpu_sibling_mask(int cpu)
15238 {
15239 @@ -79,7 +79,7 @@ struct smp_ops {
15240
15241 void (*send_call_func_ipi)(const struct cpumask *mask);
15242 void (*send_call_func_single_ipi)(int cpu);
15243 -};
15244 +} __no_const;
15245
15246 /* Globals due to paravirt */
15247 extern void set_cpu_sibling_map(int cpu);
15248 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15249 extern int safe_smp_processor_id(void);
15250
15251 #elif defined(CONFIG_X86_64_SMP)
15252 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15253 -
15254 -#define stack_smp_processor_id() \
15255 -({ \
15256 - struct thread_info *ti; \
15257 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15258 - ti->cpu; \
15259 -})
15260 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15261 +#define stack_smp_processor_id() raw_smp_processor_id()
15262 #define safe_smp_processor_id() smp_processor_id()
15263
15264 #endif
15265 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15266 index 33692ea..350a534 100644
15267 --- a/arch/x86/include/asm/spinlock.h
15268 +++ b/arch/x86/include/asm/spinlock.h
15269 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15270 static inline void arch_read_lock(arch_rwlock_t *rw)
15271 {
15272 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15273 +
15274 +#ifdef CONFIG_PAX_REFCOUNT
15275 + "jno 0f\n"
15276 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15277 + "int $4\n0:\n"
15278 + _ASM_EXTABLE(0b, 0b)
15279 +#endif
15280 +
15281 "jns 1f\n"
15282 "call __read_lock_failed\n\t"
15283 "1:\n"
15284 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15285 static inline void arch_write_lock(arch_rwlock_t *rw)
15286 {
15287 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15288 +
15289 +#ifdef CONFIG_PAX_REFCOUNT
15290 + "jno 0f\n"
15291 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15292 + "int $4\n0:\n"
15293 + _ASM_EXTABLE(0b, 0b)
15294 +#endif
15295 +
15296 "jz 1f\n"
15297 "call __write_lock_failed\n\t"
15298 "1:\n"
15299 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15300
15301 static inline void arch_read_unlock(arch_rwlock_t *rw)
15302 {
15303 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15304 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15305 +
15306 +#ifdef CONFIG_PAX_REFCOUNT
15307 + "jno 0f\n"
15308 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15309 + "int $4\n0:\n"
15310 + _ASM_EXTABLE(0b, 0b)
15311 +#endif
15312 +
15313 :"+m" (rw->lock) : : "memory");
15314 }
15315
15316 static inline void arch_write_unlock(arch_rwlock_t *rw)
15317 {
15318 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15319 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15320 +
15321 +#ifdef CONFIG_PAX_REFCOUNT
15322 + "jno 0f\n"
15323 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15324 + "int $4\n0:\n"
15325 + _ASM_EXTABLE(0b, 0b)
15326 +#endif
15327 +
15328 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15329 }
15330
15331 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15332 index 6a99859..03cb807 100644
15333 --- a/arch/x86/include/asm/stackprotector.h
15334 +++ b/arch/x86/include/asm/stackprotector.h
15335 @@ -47,7 +47,7 @@
15336 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15337 */
15338 #define GDT_STACK_CANARY_INIT \
15339 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15340 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15341
15342 /*
15343 * Initialize the stackprotector canary value.
15344 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15345
15346 static inline void load_stack_canary_segment(void)
15347 {
15348 -#ifdef CONFIG_X86_32
15349 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15350 asm volatile ("mov %0, %%gs" : : "r" (0));
15351 #endif
15352 }
15353 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15354 index 70bbe39..4ae2bd4 100644
15355 --- a/arch/x86/include/asm/stacktrace.h
15356 +++ b/arch/x86/include/asm/stacktrace.h
15357 @@ -11,28 +11,20 @@
15358
15359 extern int kstack_depth_to_print;
15360
15361 -struct thread_info;
15362 +struct task_struct;
15363 struct stacktrace_ops;
15364
15365 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15366 - unsigned long *stack,
15367 - unsigned long bp,
15368 - const struct stacktrace_ops *ops,
15369 - void *data,
15370 - unsigned long *end,
15371 - int *graph);
15372 +typedef unsigned long walk_stack_t(struct task_struct *task,
15373 + void *stack_start,
15374 + unsigned long *stack,
15375 + unsigned long bp,
15376 + const struct stacktrace_ops *ops,
15377 + void *data,
15378 + unsigned long *end,
15379 + int *graph);
15380
15381 -extern unsigned long
15382 -print_context_stack(struct thread_info *tinfo,
15383 - unsigned long *stack, unsigned long bp,
15384 - const struct stacktrace_ops *ops, void *data,
15385 - unsigned long *end, int *graph);
15386 -
15387 -extern unsigned long
15388 -print_context_stack_bp(struct thread_info *tinfo,
15389 - unsigned long *stack, unsigned long bp,
15390 - const struct stacktrace_ops *ops, void *data,
15391 - unsigned long *end, int *graph);
15392 +extern walk_stack_t print_context_stack;
15393 +extern walk_stack_t print_context_stack_bp;
15394
15395 /* Generic stack tracer with callbacks */
15396
15397 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15398 void (*address)(void *data, unsigned long address, int reliable);
15399 /* On negative return stop dumping */
15400 int (*stack)(void *data, char *name);
15401 - walk_stack_t walk_stack;
15402 + walk_stack_t *walk_stack;
15403 };
15404
15405 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15406 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15407 index 4ec45b3..a4f0a8a 100644
15408 --- a/arch/x86/include/asm/switch_to.h
15409 +++ b/arch/x86/include/asm/switch_to.h
15410 @@ -108,7 +108,7 @@ do { \
15411 "call __switch_to\n\t" \
15412 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15413 __switch_canary \
15414 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15415 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15416 "movq %%rax,%%rdi\n\t" \
15417 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15418 "jnz ret_from_fork\n\t" \
15419 @@ -119,7 +119,7 @@ do { \
15420 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15421 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15422 [_tif_fork] "i" (_TIF_FORK), \
15423 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15424 + [thread_info] "m" (current_tinfo), \
15425 [current_task] "m" (current_task) \
15426 __switch_canary_iparam \
15427 : "memory", "cc" __EXTRA_CLOBBER)
15428 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15429 index 2cd056e..0224df8 100644
15430 --- a/arch/x86/include/asm/thread_info.h
15431 +++ b/arch/x86/include/asm/thread_info.h
15432 @@ -10,6 +10,7 @@
15433 #include <linux/compiler.h>
15434 #include <asm/page.h>
15435 #include <asm/types.h>
15436 +#include <asm/percpu.h>
15437
15438 /*
15439 * low level task data that entry.S needs immediate access to
15440 @@ -23,7 +24,6 @@ struct exec_domain;
15441 #include <linux/atomic.h>
15442
15443 struct thread_info {
15444 - struct task_struct *task; /* main task structure */
15445 struct exec_domain *exec_domain; /* execution domain */
15446 __u32 flags; /* low level flags */
15447 __u32 status; /* thread synchronous flags */
15448 @@ -33,19 +33,13 @@ struct thread_info {
15449 mm_segment_t addr_limit;
15450 struct restart_block restart_block;
15451 void __user *sysenter_return;
15452 -#ifdef CONFIG_X86_32
15453 - unsigned long previous_esp; /* ESP of the previous stack in
15454 - case of nested (IRQ) stacks
15455 - */
15456 - __u8 supervisor_stack[0];
15457 -#endif
15458 + unsigned long lowest_stack;
15459 unsigned int sig_on_uaccess_error:1;
15460 unsigned int uaccess_err:1; /* uaccess failed */
15461 };
15462
15463 -#define INIT_THREAD_INFO(tsk) \
15464 +#define INIT_THREAD_INFO \
15465 { \
15466 - .task = &tsk, \
15467 .exec_domain = &default_exec_domain, \
15468 .flags = 0, \
15469 .cpu = 0, \
15470 @@ -56,7 +50,7 @@ struct thread_info {
15471 }, \
15472 }
15473
15474 -#define init_thread_info (init_thread_union.thread_info)
15475 +#define init_thread_info (init_thread_union.stack)
15476 #define init_stack (init_thread_union.stack)
15477
15478 #else /* !__ASSEMBLY__ */
15479 @@ -97,6 +91,7 @@ struct thread_info {
15480 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15481 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15482 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15483 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15484
15485 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15486 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15487 @@ -121,17 +116,18 @@ struct thread_info {
15488 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15489 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15490 #define _TIF_X32 (1 << TIF_X32)
15491 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15492
15493 /* work to do in syscall_trace_enter() */
15494 #define _TIF_WORK_SYSCALL_ENTRY \
15495 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15496 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15497 - _TIF_NOHZ)
15498 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15499
15500 /* work to do in syscall_trace_leave() */
15501 #define _TIF_WORK_SYSCALL_EXIT \
15502 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15503 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15504 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15505
15506 /* work to do on interrupt/exception return */
15507 #define _TIF_WORK_MASK \
15508 @@ -142,7 +138,7 @@ struct thread_info {
15509 /* work to do on any return to user space */
15510 #define _TIF_ALLWORK_MASK \
15511 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15512 - _TIF_NOHZ)
15513 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15514
15515 /* Only used for 64 bit */
15516 #define _TIF_DO_NOTIFY_MASK \
15517 @@ -158,45 +154,40 @@ struct thread_info {
15518
15519 #define PREEMPT_ACTIVE 0x10000000
15520
15521 -#ifdef CONFIG_X86_32
15522 -
15523 -#define STACK_WARN (THREAD_SIZE/8)
15524 -/*
15525 - * macros/functions for gaining access to the thread information structure
15526 - *
15527 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15528 - */
15529 -#ifndef __ASSEMBLY__
15530 -
15531 -
15532 -/* how to get the current stack pointer from C */
15533 -register unsigned long current_stack_pointer asm("esp") __used;
15534 -
15535 -/* how to get the thread information struct from C */
15536 -static inline struct thread_info *current_thread_info(void)
15537 -{
15538 - return (struct thread_info *)
15539 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15540 -}
15541 -
15542 -#else /* !__ASSEMBLY__ */
15543 -
15544 +#ifdef __ASSEMBLY__
15545 /* how to get the thread information struct from ASM */
15546 #define GET_THREAD_INFO(reg) \
15547 - movl $-THREAD_SIZE, reg; \
15548 - andl %esp, reg
15549 + mov PER_CPU_VAR(current_tinfo), reg
15550
15551 /* use this one if reg already contains %esp */
15552 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15553 - andl $-THREAD_SIZE, reg
15554 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15555 +#else
15556 +/* how to get the thread information struct from C */
15557 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15558 +
15559 +static __always_inline struct thread_info *current_thread_info(void)
15560 +{
15561 + return this_cpu_read_stable(current_tinfo);
15562 +}
15563 +#endif
15564 +
15565 +#ifdef CONFIG_X86_32
15566 +
15567 +#define STACK_WARN (THREAD_SIZE/8)
15568 +/*
15569 + * macros/functions for gaining access to the thread information structure
15570 + *
15571 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15572 + */
15573 +#ifndef __ASSEMBLY__
15574 +
15575 +/* how to get the current stack pointer from C */
15576 +register unsigned long current_stack_pointer asm("esp") __used;
15577
15578 #endif
15579
15580 #else /* X86_32 */
15581
15582 -#include <asm/percpu.h>
15583 -#define KERNEL_STACK_OFFSET (5*8)
15584 -
15585 /*
15586 * macros/functions for gaining access to the thread information structure
15587 * preempt_count needs to be 1 initially, until the scheduler is functional.
15588 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
15589 #ifndef __ASSEMBLY__
15590 DECLARE_PER_CPU(unsigned long, kernel_stack);
15591
15592 -static inline struct thread_info *current_thread_info(void)
15593 -{
15594 - struct thread_info *ti;
15595 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15596 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15597 - return ti;
15598 -}
15599 -
15600 -#else /* !__ASSEMBLY__ */
15601 -
15602 -/* how to get the thread information struct from ASM */
15603 -#define GET_THREAD_INFO(reg) \
15604 - movq PER_CPU_VAR(kernel_stack),reg ; \
15605 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15606 -
15607 -/*
15608 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15609 - * a certain register (to be used in assembler memory operands).
15610 - */
15611 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15612 -
15613 +/* how to get the current stack pointer from C */
15614 +register unsigned long current_stack_pointer asm("rsp") __used;
15615 #endif
15616
15617 #endif /* !X86_32 */
15618 @@ -285,5 +257,12 @@ static inline bool is_ia32_task(void)
15619 extern void arch_task_cache_init(void);
15620 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15621 extern void arch_release_task_struct(struct task_struct *tsk);
15622 +
15623 +#define __HAVE_THREAD_FUNCTIONS
15624 +#define task_thread_info(task) (&(task)->tinfo)
15625 +#define task_stack_page(task) ((task)->stack)
15626 +#define setup_thread_stack(p, org) do {} while (0)
15627 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15628 +
15629 #endif
15630 #endif /* _ASM_X86_THREAD_INFO_H */
15631 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15632 index 5ee2687..70d5895 100644
15633 --- a/arch/x86/include/asm/uaccess.h
15634 +++ b/arch/x86/include/asm/uaccess.h
15635 @@ -7,6 +7,7 @@
15636 #include <linux/compiler.h>
15637 #include <linux/thread_info.h>
15638 #include <linux/string.h>
15639 +#include <linux/sched.h>
15640 #include <asm/asm.h>
15641 #include <asm/page.h>
15642 #include <asm/smap.h>
15643 @@ -29,7 +30,12 @@
15644
15645 #define get_ds() (KERNEL_DS)
15646 #define get_fs() (current_thread_info()->addr_limit)
15647 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15648 +void __set_fs(mm_segment_t x);
15649 +void set_fs(mm_segment_t x);
15650 +#else
15651 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15652 +#endif
15653
15654 #define segment_eq(a, b) ((a).seg == (b).seg)
15655
15656 @@ -77,8 +83,33 @@
15657 * checks that the pointer is in the user space range - after calling
15658 * this function, memory access functions may still return -EFAULT.
15659 */
15660 -#define access_ok(type, addr, size) \
15661 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15662 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15663 +#define access_ok(type, addr, size) \
15664 +({ \
15665 + long __size = size; \
15666 + unsigned long __addr = (unsigned long)addr; \
15667 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15668 + unsigned long __end_ao = __addr + __size - 1; \
15669 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15670 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15671 + while(__addr_ao <= __end_ao) { \
15672 + char __c_ao; \
15673 + __addr_ao += PAGE_SIZE; \
15674 + if (__size > PAGE_SIZE) \
15675 + cond_resched(); \
15676 + if (__get_user(__c_ao, (char __user *)__addr)) \
15677 + break; \
15678 + if (type != VERIFY_WRITE) { \
15679 + __addr = __addr_ao; \
15680 + continue; \
15681 + } \
15682 + if (__put_user(__c_ao, (char __user *)__addr)) \
15683 + break; \
15684 + __addr = __addr_ao; \
15685 + } \
15686 + } \
15687 + __ret_ao; \
15688 +})
15689
15690 /*
15691 * The exception table consists of pairs of addresses relative to the
15692 @@ -176,13 +207,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15693 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15694 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15695
15696 -
15697 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15698 +#define __copyuser_seg "gs;"
15699 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15700 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15701 +#else
15702 +#define __copyuser_seg
15703 +#define __COPYUSER_SET_ES
15704 +#define __COPYUSER_RESTORE_ES
15705 +#endif
15706
15707 #ifdef CONFIG_X86_32
15708 #define __put_user_asm_u64(x, addr, err, errret) \
15709 asm volatile(ASM_STAC "\n" \
15710 - "1: movl %%eax,0(%2)\n" \
15711 - "2: movl %%edx,4(%2)\n" \
15712 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15713 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15714 "3: " ASM_CLAC "\n" \
15715 ".section .fixup,\"ax\"\n" \
15716 "4: movl %3,%0\n" \
15717 @@ -195,8 +234,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15718
15719 #define __put_user_asm_ex_u64(x, addr) \
15720 asm volatile(ASM_STAC "\n" \
15721 - "1: movl %%eax,0(%1)\n" \
15722 - "2: movl %%edx,4(%1)\n" \
15723 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15724 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15725 "3: " ASM_CLAC "\n" \
15726 _ASM_EXTABLE_EX(1b, 2b) \
15727 _ASM_EXTABLE_EX(2b, 3b) \
15728 @@ -246,7 +285,7 @@ extern void __put_user_8(void);
15729 __typeof__(*(ptr)) __pu_val; \
15730 __chk_user_ptr(ptr); \
15731 might_fault(); \
15732 - __pu_val = x; \
15733 + __pu_val = (x); \
15734 switch (sizeof(*(ptr))) { \
15735 case 1: \
15736 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15737 @@ -345,7 +384,7 @@ do { \
15738
15739 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15740 asm volatile(ASM_STAC "\n" \
15741 - "1: mov"itype" %2,%"rtype"1\n" \
15742 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15743 "2: " ASM_CLAC "\n" \
15744 ".section .fixup,\"ax\"\n" \
15745 "3: mov %3,%0\n" \
15746 @@ -353,7 +392,7 @@ do { \
15747 " jmp 2b\n" \
15748 ".previous\n" \
15749 _ASM_EXTABLE(1b, 3b) \
15750 - : "=r" (err), ltype(x) \
15751 + : "=r" (err), ltype (x) \
15752 : "m" (__m(addr)), "i" (errret), "0" (err))
15753
15754 #define __get_user_size_ex(x, ptr, size) \
15755 @@ -378,7 +417,7 @@ do { \
15756 } while (0)
15757
15758 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15759 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15760 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15761 "2:\n" \
15762 _ASM_EXTABLE_EX(1b, 2b) \
15763 : ltype(x) : "m" (__m(addr)))
15764 @@ -395,13 +434,24 @@ do { \
15765 int __gu_err; \
15766 unsigned long __gu_val; \
15767 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15768 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15769 + (x) = (__typeof__(*(ptr)))__gu_val; \
15770 __gu_err; \
15771 })
15772
15773 /* FIXME: this hack is definitely wrong -AK */
15774 struct __large_struct { unsigned long buf[100]; };
15775 -#define __m(x) (*(struct __large_struct __user *)(x))
15776 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15777 +#define ____m(x) \
15778 +({ \
15779 + unsigned long ____x = (unsigned long)(x); \
15780 + if (____x < pax_user_shadow_base) \
15781 + ____x += pax_user_shadow_base; \
15782 + (typeof(x))____x; \
15783 +})
15784 +#else
15785 +#define ____m(x) (x)
15786 +#endif
15787 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15788
15789 /*
15790 * Tell gcc we read from memory instead of writing: this is because
15791 @@ -410,7 +460,7 @@ struct __large_struct { unsigned long buf[100]; };
15792 */
15793 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15794 asm volatile(ASM_STAC "\n" \
15795 - "1: mov"itype" %"rtype"1,%2\n" \
15796 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15797 "2: " ASM_CLAC "\n" \
15798 ".section .fixup,\"ax\"\n" \
15799 "3: mov %3,%0\n" \
15800 @@ -418,10 +468,10 @@ struct __large_struct { unsigned long buf[100]; };
15801 ".previous\n" \
15802 _ASM_EXTABLE(1b, 3b) \
15803 : "=r"(err) \
15804 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15805 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15806
15807 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15808 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15809 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15810 "2:\n" \
15811 _ASM_EXTABLE_EX(1b, 2b) \
15812 : : ltype(x), "m" (__m(addr)))
15813 @@ -460,8 +510,12 @@ struct __large_struct { unsigned long buf[100]; };
15814 * On error, the variable @x is set to zero.
15815 */
15816
15817 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15818 +#define __get_user(x, ptr) get_user((x), (ptr))
15819 +#else
15820 #define __get_user(x, ptr) \
15821 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15822 +#endif
15823
15824 /**
15825 * __put_user: - Write a simple value into user space, with less checking.
15826 @@ -483,8 +537,12 @@ struct __large_struct { unsigned long buf[100]; };
15827 * Returns zero on success, or -EFAULT on error.
15828 */
15829
15830 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15831 +#define __put_user(x, ptr) put_user((x), (ptr))
15832 +#else
15833 #define __put_user(x, ptr) \
15834 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15835 +#endif
15836
15837 #define __get_user_unaligned __get_user
15838 #define __put_user_unaligned __put_user
15839 @@ -502,7 +560,7 @@ struct __large_struct { unsigned long buf[100]; };
15840 #define get_user_ex(x, ptr) do { \
15841 unsigned long __gue_val; \
15842 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15843 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15844 + (x) = (__typeof__(*(ptr)))__gue_val; \
15845 } while (0)
15846
15847 #define put_user_try uaccess_try
15848 @@ -519,8 +577,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15849 extern __must_check long strlen_user(const char __user *str);
15850 extern __must_check long strnlen_user(const char __user *str, long n);
15851
15852 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15853 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15854 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15855 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15856
15857 /*
15858 * movsl can be slow when source and dest are not both 8-byte aligned
15859 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15860 index 7f760a9..04b1c65 100644
15861 --- a/arch/x86/include/asm/uaccess_32.h
15862 +++ b/arch/x86/include/asm/uaccess_32.h
15863 @@ -11,15 +11,15 @@
15864 #include <asm/page.h>
15865
15866 unsigned long __must_check __copy_to_user_ll
15867 - (void __user *to, const void *from, unsigned long n);
15868 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15869 unsigned long __must_check __copy_from_user_ll
15870 - (void *to, const void __user *from, unsigned long n);
15871 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15872 unsigned long __must_check __copy_from_user_ll_nozero
15873 - (void *to, const void __user *from, unsigned long n);
15874 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15875 unsigned long __must_check __copy_from_user_ll_nocache
15876 - (void *to, const void __user *from, unsigned long n);
15877 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15878 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15879 - (void *to, const void __user *from, unsigned long n);
15880 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15881
15882 /**
15883 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15884 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15885 static __always_inline unsigned long __must_check
15886 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15887 {
15888 + if ((long)n < 0)
15889 + return n;
15890 +
15891 + check_object_size(from, n, true);
15892 +
15893 if (__builtin_constant_p(n)) {
15894 unsigned long ret;
15895
15896 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15897 __copy_to_user(void __user *to, const void *from, unsigned long n)
15898 {
15899 might_fault();
15900 +
15901 return __copy_to_user_inatomic(to, from, n);
15902 }
15903
15904 static __always_inline unsigned long
15905 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15906 {
15907 + if ((long)n < 0)
15908 + return n;
15909 +
15910 /* Avoid zeroing the tail if the copy fails..
15911 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15912 * but as the zeroing behaviour is only significant when n is not
15913 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15914 __copy_from_user(void *to, const void __user *from, unsigned long n)
15915 {
15916 might_fault();
15917 +
15918 + if ((long)n < 0)
15919 + return n;
15920 +
15921 + check_object_size(to, n, false);
15922 +
15923 if (__builtin_constant_p(n)) {
15924 unsigned long ret;
15925
15926 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
15927 const void __user *from, unsigned long n)
15928 {
15929 might_fault();
15930 +
15931 + if ((long)n < 0)
15932 + return n;
15933 +
15934 if (__builtin_constant_p(n)) {
15935 unsigned long ret;
15936
15937 @@ -181,15 +200,19 @@ static __always_inline unsigned long
15938 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
15939 unsigned long n)
15940 {
15941 - return __copy_from_user_ll_nocache_nozero(to, from, n);
15942 + if ((long)n < 0)
15943 + return n;
15944 +
15945 + return __copy_from_user_ll_nocache_nozero(to, from, n);
15946 }
15947
15948 -unsigned long __must_check copy_to_user(void __user *to,
15949 - const void *from, unsigned long n);
15950 -unsigned long __must_check _copy_from_user(void *to,
15951 - const void __user *from,
15952 - unsigned long n);
15953 -
15954 +extern void copy_to_user_overflow(void)
15955 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15956 + __compiletime_error("copy_to_user() buffer size is not provably correct")
15957 +#else
15958 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
15959 +#endif
15960 +;
15961
15962 extern void copy_from_user_overflow(void)
15963 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15964 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
15965 #endif
15966 ;
15967
15968 -static inline unsigned long __must_check copy_from_user(void *to,
15969 - const void __user *from,
15970 - unsigned long n)
15971 +/**
15972 + * copy_to_user: - Copy a block of data into user space.
15973 + * @to: Destination address, in user space.
15974 + * @from: Source address, in kernel space.
15975 + * @n: Number of bytes to copy.
15976 + *
15977 + * Context: User context only. This function may sleep.
15978 + *
15979 + * Copy data from kernel space to user space.
15980 + *
15981 + * Returns number of bytes that could not be copied.
15982 + * On success, this will be zero.
15983 + */
15984 +static inline unsigned long __must_check
15985 +copy_to_user(void __user *to, const void *from, unsigned long n)
15986 {
15987 - int sz = __compiletime_object_size(to);
15988 + size_t sz = __compiletime_object_size(from);
15989
15990 - if (likely(sz == -1 || sz >= n))
15991 - n = _copy_from_user(to, from, n);
15992 - else
15993 + if (unlikely(sz != (size_t)-1 && sz < n))
15994 + copy_to_user_overflow();
15995 + else if (access_ok(VERIFY_WRITE, to, n))
15996 + n = __copy_to_user(to, from, n);
15997 + return n;
15998 +}
15999 +
16000 +/**
16001 + * copy_from_user: - Copy a block of data from user space.
16002 + * @to: Destination address, in kernel space.
16003 + * @from: Source address, in user space.
16004 + * @n: Number of bytes to copy.
16005 + *
16006 + * Context: User context only. This function may sleep.
16007 + *
16008 + * Copy data from user space to kernel space.
16009 + *
16010 + * Returns number of bytes that could not be copied.
16011 + * On success, this will be zero.
16012 + *
16013 + * If some data could not be copied, this function will pad the copied
16014 + * data to the requested size using zero bytes.
16015 + */
16016 +static inline unsigned long __must_check
16017 +copy_from_user(void *to, const void __user *from, unsigned long n)
16018 +{
16019 + size_t sz = __compiletime_object_size(to);
16020 +
16021 + check_object_size(to, n, false);
16022 +
16023 + if (unlikely(sz != (size_t)-1 && sz < n))
16024 copy_from_user_overflow();
16025 -
16026 + else if (access_ok(VERIFY_READ, from, n))
16027 + n = __copy_from_user(to, from, n);
16028 + else if ((long)n > 0)
16029 + memset(to, 0, n);
16030 return n;
16031 }
16032
16033 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16034 index 142810c..1f2a0a7 100644
16035 --- a/arch/x86/include/asm/uaccess_64.h
16036 +++ b/arch/x86/include/asm/uaccess_64.h
16037 @@ -10,6 +10,9 @@
16038 #include <asm/alternative.h>
16039 #include <asm/cpufeature.h>
16040 #include <asm/page.h>
16041 +#include <asm/pgtable.h>
16042 +
16043 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16044
16045 /*
16046 * Copy To/From Userspace
16047 @@ -17,13 +20,13 @@
16048
16049 /* Handles exceptions in both to and from, but doesn't do access_ok */
16050 __must_check unsigned long
16051 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16052 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16053 __must_check unsigned long
16054 -copy_user_generic_string(void *to, const void *from, unsigned len);
16055 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16056 __must_check unsigned long
16057 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16058 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16059
16060 -static __always_inline __must_check unsigned long
16061 +static __always_inline __must_check __size_overflow(3) unsigned long
16062 copy_user_generic(void *to, const void *from, unsigned len)
16063 {
16064 unsigned ret;
16065 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16066 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16067 "=d" (len)),
16068 "1" (to), "2" (from), "3" (len)
16069 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16070 + : "memory", "rcx", "r8", "r9", "r11");
16071 return ret;
16072 }
16073
16074 +static __always_inline __must_check unsigned long
16075 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16076 +static __always_inline __must_check unsigned long
16077 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16078 __must_check unsigned long
16079 -_copy_to_user(void __user *to, const void *from, unsigned len);
16080 -__must_check unsigned long
16081 -_copy_from_user(void *to, const void __user *from, unsigned len);
16082 -__must_check unsigned long
16083 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16084 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16085 +
16086 +extern void copy_to_user_overflow(void)
16087 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16088 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16089 +#else
16090 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16091 +#endif
16092 +;
16093 +
16094 +extern void copy_from_user_overflow(void)
16095 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16096 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16097 +#else
16098 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16099 +#endif
16100 +;
16101
16102 static inline unsigned long __must_check copy_from_user(void *to,
16103 const void __user *from,
16104 unsigned long n)
16105 {
16106 - int sz = __compiletime_object_size(to);
16107 -
16108 might_fault();
16109 - if (likely(sz == -1 || sz >= n))
16110 - n = _copy_from_user(to, from, n);
16111 -#ifdef CONFIG_DEBUG_VM
16112 - else
16113 - WARN(1, "Buffer overflow detected!\n");
16114 -#endif
16115 +
16116 + check_object_size(to, n, false);
16117 +
16118 + if (access_ok(VERIFY_READ, from, n))
16119 + n = __copy_from_user(to, from, n);
16120 + else if (n < INT_MAX)
16121 + memset(to, 0, n);
16122 return n;
16123 }
16124
16125 static __always_inline __must_check
16126 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16127 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16128 {
16129 might_fault();
16130
16131 - return _copy_to_user(dst, src, size);
16132 + if (access_ok(VERIFY_WRITE, dst, size))
16133 + size = __copy_to_user(dst, src, size);
16134 + return size;
16135 }
16136
16137 static __always_inline __must_check
16138 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16139 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16140 {
16141 - int ret = 0;
16142 + size_t sz = __compiletime_object_size(dst);
16143 + unsigned ret = 0;
16144
16145 might_fault();
16146 +
16147 + if (size > INT_MAX)
16148 + return size;
16149 +
16150 + check_object_size(dst, size, false);
16151 +
16152 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16153 + if (!__access_ok(VERIFY_READ, src, size))
16154 + return size;
16155 +#endif
16156 +
16157 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16158 + copy_from_user_overflow();
16159 + return size;
16160 + }
16161 +
16162 if (!__builtin_constant_p(size))
16163 - return copy_user_generic(dst, (__force void *)src, size);
16164 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16165 switch (size) {
16166 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16167 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16168 ret, "b", "b", "=q", 1);
16169 return ret;
16170 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16171 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16172 ret, "w", "w", "=r", 2);
16173 return ret;
16174 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16175 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16176 ret, "l", "k", "=r", 4);
16177 return ret;
16178 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16179 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16180 ret, "q", "", "=r", 8);
16181 return ret;
16182 case 10:
16183 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16184 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16185 ret, "q", "", "=r", 10);
16186 if (unlikely(ret))
16187 return ret;
16188 __get_user_asm(*(u16 *)(8 + (char *)dst),
16189 - (u16 __user *)(8 + (char __user *)src),
16190 + (const u16 __user *)(8 + (const char __user *)src),
16191 ret, "w", "w", "=r", 2);
16192 return ret;
16193 case 16:
16194 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16195 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16196 ret, "q", "", "=r", 16);
16197 if (unlikely(ret))
16198 return ret;
16199 __get_user_asm(*(u64 *)(8 + (char *)dst),
16200 - (u64 __user *)(8 + (char __user *)src),
16201 + (const u64 __user *)(8 + (const char __user *)src),
16202 ret, "q", "", "=r", 8);
16203 return ret;
16204 default:
16205 - return copy_user_generic(dst, (__force void *)src, size);
16206 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16207 }
16208 }
16209
16210 static __always_inline __must_check
16211 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16212 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16213 {
16214 - int ret = 0;
16215 + size_t sz = __compiletime_object_size(src);
16216 + unsigned ret = 0;
16217
16218 might_fault();
16219 +
16220 + if (size > INT_MAX)
16221 + return size;
16222 +
16223 + check_object_size(src, size, true);
16224 +
16225 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16226 + if (!__access_ok(VERIFY_WRITE, dst, size))
16227 + return size;
16228 +#endif
16229 +
16230 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16231 + copy_to_user_overflow();
16232 + return size;
16233 + }
16234 +
16235 if (!__builtin_constant_p(size))
16236 - return copy_user_generic((__force void *)dst, src, size);
16237 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16238 switch (size) {
16239 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16240 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16241 ret, "b", "b", "iq", 1);
16242 return ret;
16243 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16244 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16245 ret, "w", "w", "ir", 2);
16246 return ret;
16247 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16248 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16249 ret, "l", "k", "ir", 4);
16250 return ret;
16251 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16252 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16253 ret, "q", "", "er", 8);
16254 return ret;
16255 case 10:
16256 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16257 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16258 ret, "q", "", "er", 10);
16259 if (unlikely(ret))
16260 return ret;
16261 asm("":::"memory");
16262 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16263 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16264 ret, "w", "w", "ir", 2);
16265 return ret;
16266 case 16:
16267 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16268 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16269 ret, "q", "", "er", 16);
16270 if (unlikely(ret))
16271 return ret;
16272 asm("":::"memory");
16273 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16274 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16275 ret, "q", "", "er", 8);
16276 return ret;
16277 default:
16278 - return copy_user_generic((__force void *)dst, src, size);
16279 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16280 }
16281 }
16282
16283 static __always_inline __must_check
16284 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16285 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16286 {
16287 - int ret = 0;
16288 + unsigned ret = 0;
16289
16290 might_fault();
16291 +
16292 + if (size > INT_MAX)
16293 + return size;
16294 +
16295 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16296 + if (!__access_ok(VERIFY_READ, src, size))
16297 + return size;
16298 + if (!__access_ok(VERIFY_WRITE, dst, size))
16299 + return size;
16300 +#endif
16301 +
16302 if (!__builtin_constant_p(size))
16303 - return copy_user_generic((__force void *)dst,
16304 - (__force void *)src, size);
16305 + return copy_user_generic((__force_kernel void *)____m(dst),
16306 + (__force_kernel const void *)____m(src), size);
16307 switch (size) {
16308 case 1: {
16309 u8 tmp;
16310 - __get_user_asm(tmp, (u8 __user *)src,
16311 + __get_user_asm(tmp, (const u8 __user *)src,
16312 ret, "b", "b", "=q", 1);
16313 if (likely(!ret))
16314 __put_user_asm(tmp, (u8 __user *)dst,
16315 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16316 }
16317 case 2: {
16318 u16 tmp;
16319 - __get_user_asm(tmp, (u16 __user *)src,
16320 + __get_user_asm(tmp, (const u16 __user *)src,
16321 ret, "w", "w", "=r", 2);
16322 if (likely(!ret))
16323 __put_user_asm(tmp, (u16 __user *)dst,
16324 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16325
16326 case 4: {
16327 u32 tmp;
16328 - __get_user_asm(tmp, (u32 __user *)src,
16329 + __get_user_asm(tmp, (const u32 __user *)src,
16330 ret, "l", "k", "=r", 4);
16331 if (likely(!ret))
16332 __put_user_asm(tmp, (u32 __user *)dst,
16333 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16334 }
16335 case 8: {
16336 u64 tmp;
16337 - __get_user_asm(tmp, (u64 __user *)src,
16338 + __get_user_asm(tmp, (const u64 __user *)src,
16339 ret, "q", "", "=r", 8);
16340 if (likely(!ret))
16341 __put_user_asm(tmp, (u64 __user *)dst,
16342 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16343 return ret;
16344 }
16345 default:
16346 - return copy_user_generic((__force void *)dst,
16347 - (__force void *)src, size);
16348 + return copy_user_generic((__force_kernel void *)____m(dst),
16349 + (__force_kernel const void *)____m(src), size);
16350 }
16351 }
16352
16353 static __must_check __always_inline int
16354 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16355 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16356 {
16357 - return copy_user_generic(dst, (__force const void *)src, size);
16358 + if (size > INT_MAX)
16359 + return size;
16360 +
16361 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16362 + if (!__access_ok(VERIFY_READ, src, size))
16363 + return size;
16364 +#endif
16365 +
16366 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16367 }
16368
16369 -static __must_check __always_inline int
16370 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16371 +static __must_check __always_inline unsigned long
16372 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16373 {
16374 - return copy_user_generic((__force void *)dst, src, size);
16375 + if (size > INT_MAX)
16376 + return size;
16377 +
16378 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16379 + if (!__access_ok(VERIFY_WRITE, dst, size))
16380 + return size;
16381 +#endif
16382 +
16383 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16384 }
16385
16386 -extern long __copy_user_nocache(void *dst, const void __user *src,
16387 - unsigned size, int zerorest);
16388 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16389 + unsigned long size, int zerorest) __size_overflow(3);
16390
16391 -static inline int
16392 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16393 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16394 {
16395 might_sleep();
16396 +
16397 + if (size > INT_MAX)
16398 + return size;
16399 +
16400 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16401 + if (!__access_ok(VERIFY_READ, src, size))
16402 + return size;
16403 +#endif
16404 +
16405 return __copy_user_nocache(dst, src, size, 1);
16406 }
16407
16408 -static inline int
16409 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16410 - unsigned size)
16411 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16412 + unsigned long size)
16413 {
16414 + if (size > INT_MAX)
16415 + return size;
16416 +
16417 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16418 + if (!__access_ok(VERIFY_READ, src, size))
16419 + return size;
16420 +#endif
16421 +
16422 return __copy_user_nocache(dst, src, size, 0);
16423 }
16424
16425 -unsigned long
16426 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16427 +extern unsigned long
16428 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16429
16430 #endif /* _ASM_X86_UACCESS_64_H */
16431 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16432 index 5b238981..77fdd78 100644
16433 --- a/arch/x86/include/asm/word-at-a-time.h
16434 +++ b/arch/x86/include/asm/word-at-a-time.h
16435 @@ -11,7 +11,7 @@
16436 * and shift, for example.
16437 */
16438 struct word_at_a_time {
16439 - const unsigned long one_bits, high_bits;
16440 + unsigned long one_bits, high_bits;
16441 };
16442
16443 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16444 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16445 index d8d9922..bf6cecb 100644
16446 --- a/arch/x86/include/asm/x86_init.h
16447 +++ b/arch/x86/include/asm/x86_init.h
16448 @@ -129,7 +129,7 @@ struct x86_init_ops {
16449 struct x86_init_timers timers;
16450 struct x86_init_iommu iommu;
16451 struct x86_init_pci pci;
16452 -};
16453 +} __no_const;
16454
16455 /**
16456 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16457 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
16458 void (*setup_percpu_clockev)(void);
16459 void (*early_percpu_clock_init)(void);
16460 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16461 -};
16462 +} __no_const;
16463
16464 /**
16465 * struct x86_platform_ops - platform specific runtime functions
16466 @@ -166,7 +166,7 @@ struct x86_platform_ops {
16467 void (*save_sched_clock_state)(void);
16468 void (*restore_sched_clock_state)(void);
16469 void (*apic_post_init)(void);
16470 -};
16471 +} __no_const;
16472
16473 struct pci_dev;
16474 struct msi_msg;
16475 @@ -180,7 +180,7 @@ struct x86_msi_ops {
16476 void (*teardown_msi_irqs)(struct pci_dev *dev);
16477 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16478 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
16479 -};
16480 +} __no_const;
16481
16482 struct IO_APIC_route_entry;
16483 struct io_apic_irq_attr;
16484 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
16485 unsigned int destination, int vector,
16486 struct io_apic_irq_attr *attr);
16487 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
16488 -};
16489 +} __no_const;
16490
16491 extern struct x86_init_ops x86_init;
16492 extern struct x86_cpuinit_ops x86_cpuinit;
16493 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16494 index 0415cda..b43d877 100644
16495 --- a/arch/x86/include/asm/xsave.h
16496 +++ b/arch/x86/include/asm/xsave.h
16497 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16498 return -EFAULT;
16499
16500 __asm__ __volatile__(ASM_STAC "\n"
16501 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16502 + "1:"
16503 + __copyuser_seg
16504 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16505 "2: " ASM_CLAC "\n"
16506 ".section .fixup,\"ax\"\n"
16507 "3: movl $-1,%[err]\n"
16508 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16509 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16510 {
16511 int err;
16512 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16513 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16514 u32 lmask = mask;
16515 u32 hmask = mask >> 32;
16516
16517 __asm__ __volatile__(ASM_STAC "\n"
16518 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16519 + "1:"
16520 + __copyuser_seg
16521 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16522 "2: " ASM_CLAC "\n"
16523 ".section .fixup,\"ax\"\n"
16524 "3: movl $-1,%[err]\n"
16525 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16526 index bbae024..e1528f9 100644
16527 --- a/arch/x86/include/uapi/asm/e820.h
16528 +++ b/arch/x86/include/uapi/asm/e820.h
16529 @@ -63,7 +63,7 @@ struct e820map {
16530 #define ISA_START_ADDRESS 0xa0000
16531 #define ISA_END_ADDRESS 0x100000
16532
16533 -#define BIOS_BEGIN 0x000a0000
16534 +#define BIOS_BEGIN 0x000c0000
16535 #define BIOS_END 0x00100000
16536
16537 #define BIOS_ROM_BASE 0xffe00000
16538 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16539 index 7bd3bd3..5dac791 100644
16540 --- a/arch/x86/kernel/Makefile
16541 +++ b/arch/x86/kernel/Makefile
16542 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16543 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16544 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16545 obj-y += probe_roms.o
16546 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16547 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16548 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16549 obj-y += syscall_$(BITS).o
16550 obj-$(CONFIG_X86_64) += vsyscall_64.o
16551 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16552 index 230c8ea..f915130 100644
16553 --- a/arch/x86/kernel/acpi/boot.c
16554 +++ b/arch/x86/kernel/acpi/boot.c
16555 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16556 * If your system is blacklisted here, but you find that acpi=force
16557 * works for you, please contact linux-acpi@vger.kernel.org
16558 */
16559 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16560 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16561 /*
16562 * Boxes that need ACPI disabled
16563 */
16564 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16565 };
16566
16567 /* second table for DMI checks that should run after early-quirks */
16568 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16569 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16570 /*
16571 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16572 * which includes some code which overrides all temperature
16573 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16574 index 0532f5d..36afc0a 100644
16575 --- a/arch/x86/kernel/acpi/sleep.c
16576 +++ b/arch/x86/kernel/acpi/sleep.c
16577 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16578 #else /* CONFIG_64BIT */
16579 #ifdef CONFIG_SMP
16580 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16581 +
16582 + pax_open_kernel();
16583 early_gdt_descr.address =
16584 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16585 + pax_close_kernel();
16586 +
16587 initial_gs = per_cpu_offset(smp_processor_id());
16588 #endif
16589 initial_code = (unsigned long)wakeup_long64;
16590 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16591 index 13ab720..95d5442 100644
16592 --- a/arch/x86/kernel/acpi/wakeup_32.S
16593 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16594 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16595 # and restore the stack ... but you need gdt for this to work
16596 movl saved_context_esp, %esp
16597
16598 - movl %cs:saved_magic, %eax
16599 - cmpl $0x12345678, %eax
16600 + cmpl $0x12345678, saved_magic
16601 jne bogus_magic
16602
16603 # jump to place where we left off
16604 - movl saved_eip, %eax
16605 - jmp *%eax
16606 + jmp *(saved_eip)
16607
16608 bogus_magic:
16609 jmp bogus_magic
16610 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16611 index ef5ccca..bd83949 100644
16612 --- a/arch/x86/kernel/alternative.c
16613 +++ b/arch/x86/kernel/alternative.c
16614 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16615 */
16616 for (a = start; a < end; a++) {
16617 instr = (u8 *)&a->instr_offset + a->instr_offset;
16618 +
16619 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16620 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16621 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16622 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16623 +#endif
16624 +
16625 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16626 BUG_ON(a->replacementlen > a->instrlen);
16627 BUG_ON(a->instrlen > sizeof(insnbuf));
16628 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16629 for (poff = start; poff < end; poff++) {
16630 u8 *ptr = (u8 *)poff + *poff;
16631
16632 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16633 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16634 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16635 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16636 +#endif
16637 +
16638 if (!*poff || ptr < text || ptr >= text_end)
16639 continue;
16640 /* turn DS segment override prefix into lock prefix */
16641 - if (*ptr == 0x3e)
16642 + if (*ktla_ktva(ptr) == 0x3e)
16643 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16644 }
16645 mutex_unlock(&text_mutex);
16646 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16647 for (poff = start; poff < end; poff++) {
16648 u8 *ptr = (u8 *)poff + *poff;
16649
16650 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16651 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16652 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16653 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16654 +#endif
16655 +
16656 if (!*poff || ptr < text || ptr >= text_end)
16657 continue;
16658 /* turn lock prefix into DS segment override prefix */
16659 - if (*ptr == 0xf0)
16660 + if (*ktla_ktva(ptr) == 0xf0)
16661 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16662 }
16663 mutex_unlock(&text_mutex);
16664 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16665
16666 BUG_ON(p->len > MAX_PATCH_LEN);
16667 /* prep the buffer with the original instructions */
16668 - memcpy(insnbuf, p->instr, p->len);
16669 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16670 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16671 (unsigned long)p->instr, p->len);
16672
16673 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16674 if (!uniproc_patched || num_possible_cpus() == 1)
16675 free_init_pages("SMP alternatives",
16676 (unsigned long)__smp_locks,
16677 - (unsigned long)__smp_locks_end);
16678 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16679 #endif
16680
16681 apply_paravirt(__parainstructions, __parainstructions_end);
16682 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16683 * instructions. And on the local CPU you need to be protected again NMI or MCE
16684 * handlers seeing an inconsistent instruction while you patch.
16685 */
16686 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16687 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16688 size_t len)
16689 {
16690 unsigned long flags;
16691 local_irq_save(flags);
16692 - memcpy(addr, opcode, len);
16693 +
16694 + pax_open_kernel();
16695 + memcpy(ktla_ktva(addr), opcode, len);
16696 sync_core();
16697 + pax_close_kernel();
16698 +
16699 local_irq_restore(flags);
16700 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16701 that causes hangs on some VIA CPUs. */
16702 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16703 */
16704 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16705 {
16706 - unsigned long flags;
16707 - char *vaddr;
16708 + unsigned char *vaddr = ktla_ktva(addr);
16709 struct page *pages[2];
16710 - int i;
16711 + size_t i;
16712
16713 if (!core_kernel_text((unsigned long)addr)) {
16714 - pages[0] = vmalloc_to_page(addr);
16715 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16716 + pages[0] = vmalloc_to_page(vaddr);
16717 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16718 } else {
16719 - pages[0] = virt_to_page(addr);
16720 + pages[0] = virt_to_page(vaddr);
16721 WARN_ON(!PageReserved(pages[0]));
16722 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16723 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16724 }
16725 BUG_ON(!pages[0]);
16726 - local_irq_save(flags);
16727 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16728 - if (pages[1])
16729 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16730 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16731 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16732 - clear_fixmap(FIX_TEXT_POKE0);
16733 - if (pages[1])
16734 - clear_fixmap(FIX_TEXT_POKE1);
16735 - local_flush_tlb();
16736 - sync_core();
16737 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16738 - that causes hangs on some VIA CPUs. */
16739 + text_poke_early(addr, opcode, len);
16740 for (i = 0; i < len; i++)
16741 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16742 - local_irq_restore(flags);
16743 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16744 return addr;
16745 }
16746
16747 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16748 index 904611b..004dde6 100644
16749 --- a/arch/x86/kernel/apic/apic.c
16750 +++ b/arch/x86/kernel/apic/apic.c
16751 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16752 /*
16753 * Debug level, exported for io_apic.c
16754 */
16755 -unsigned int apic_verbosity;
16756 +int apic_verbosity;
16757
16758 int pic_mode;
16759
16760 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16761 apic_write(APIC_ESR, 0);
16762 v1 = apic_read(APIC_ESR);
16763 ack_APIC_irq();
16764 - atomic_inc(&irq_err_count);
16765 + atomic_inc_unchecked(&irq_err_count);
16766
16767 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16768 smp_processor_id(), v0 , v1);
16769 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16770 index 00c77cf..2dc6a2d 100644
16771 --- a/arch/x86/kernel/apic/apic_flat_64.c
16772 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16773 @@ -157,7 +157,7 @@ static int flat_probe(void)
16774 return 1;
16775 }
16776
16777 -static struct apic apic_flat = {
16778 +static struct apic apic_flat __read_only = {
16779 .name = "flat",
16780 .probe = flat_probe,
16781 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16782 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16783 return 0;
16784 }
16785
16786 -static struct apic apic_physflat = {
16787 +static struct apic apic_physflat __read_only = {
16788
16789 .name = "physical flat",
16790 .probe = physflat_probe,
16791 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16792 index e145f28..2752888 100644
16793 --- a/arch/x86/kernel/apic/apic_noop.c
16794 +++ b/arch/x86/kernel/apic/apic_noop.c
16795 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16796 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16797 }
16798
16799 -struct apic apic_noop = {
16800 +struct apic apic_noop __read_only = {
16801 .name = "noop",
16802 .probe = noop_probe,
16803 .acpi_madt_oem_check = NULL,
16804 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16805 index d50e364..543bee3 100644
16806 --- a/arch/x86/kernel/apic/bigsmp_32.c
16807 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16808 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16809 return dmi_bigsmp;
16810 }
16811
16812 -static struct apic apic_bigsmp = {
16813 +static struct apic apic_bigsmp __read_only = {
16814
16815 .name = "bigsmp",
16816 .probe = probe_bigsmp,
16817 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16818 index 0874799..a7a7892 100644
16819 --- a/arch/x86/kernel/apic/es7000_32.c
16820 +++ b/arch/x86/kernel/apic/es7000_32.c
16821 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16822 return ret && es7000_apic_is_cluster();
16823 }
16824
16825 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16826 -static struct apic __refdata apic_es7000_cluster = {
16827 +static struct apic apic_es7000_cluster __read_only = {
16828
16829 .name = "es7000",
16830 .probe = probe_es7000,
16831 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16832 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16833 };
16834
16835 -static struct apic __refdata apic_es7000 = {
16836 +static struct apic apic_es7000 __read_only = {
16837
16838 .name = "es7000",
16839 .probe = probe_es7000,
16840 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16841 index 9ed796c..e930fe4 100644
16842 --- a/arch/x86/kernel/apic/io_apic.c
16843 +++ b/arch/x86/kernel/apic/io_apic.c
16844 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16845 }
16846 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16847
16848 -void lock_vector_lock(void)
16849 +void lock_vector_lock(void) __acquires(vector_lock)
16850 {
16851 /* Used to the online set of cpus does not change
16852 * during assign_irq_vector.
16853 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
16854 raw_spin_lock(&vector_lock);
16855 }
16856
16857 -void unlock_vector_lock(void)
16858 +void unlock_vector_lock(void) __releases(vector_lock)
16859 {
16860 raw_spin_unlock(&vector_lock);
16861 }
16862 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
16863 ack_APIC_irq();
16864 }
16865
16866 -atomic_t irq_mis_count;
16867 +atomic_unchecked_t irq_mis_count;
16868
16869 #ifdef CONFIG_GENERIC_PENDING_IRQ
16870 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16871 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
16872 * at the cpu.
16873 */
16874 if (!(v & (1 << (i & 0x1f)))) {
16875 - atomic_inc(&irq_mis_count);
16876 + atomic_inc_unchecked(&irq_mis_count);
16877
16878 eoi_ioapic_irq(irq, cfg);
16879 }
16880 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16881 index d661ee9..791fd33 100644
16882 --- a/arch/x86/kernel/apic/numaq_32.c
16883 +++ b/arch/x86/kernel/apic/numaq_32.c
16884 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16885 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16886 }
16887
16888 -/* Use __refdata to keep false positive warning calm. */
16889 -static struct apic __refdata apic_numaq = {
16890 +static struct apic apic_numaq __read_only = {
16891
16892 .name = "NUMAQ",
16893 .probe = probe_numaq,
16894 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16895 index eb35ef9..f184a21 100644
16896 --- a/arch/x86/kernel/apic/probe_32.c
16897 +++ b/arch/x86/kernel/apic/probe_32.c
16898 @@ -72,7 +72,7 @@ static int probe_default(void)
16899 return 1;
16900 }
16901
16902 -static struct apic apic_default = {
16903 +static struct apic apic_default __read_only = {
16904
16905 .name = "default",
16906 .probe = probe_default,
16907 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16908 index 77c95c0..434f8a4 100644
16909 --- a/arch/x86/kernel/apic/summit_32.c
16910 +++ b/arch/x86/kernel/apic/summit_32.c
16911 @@ -486,7 +486,7 @@ void setup_summit(void)
16912 }
16913 #endif
16914
16915 -static struct apic apic_summit = {
16916 +static struct apic apic_summit __read_only = {
16917
16918 .name = "summit",
16919 .probe = probe_summit,
16920 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16921 index c88baa4..757aee1 100644
16922 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16923 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16924 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16925 return notifier_from_errno(err);
16926 }
16927
16928 -static struct notifier_block __refdata x2apic_cpu_notifier = {
16929 +static struct notifier_block x2apic_cpu_notifier = {
16930 .notifier_call = update_clusterinfo,
16931 };
16932
16933 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
16934 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
16935 }
16936
16937 -static struct apic apic_x2apic_cluster = {
16938 +static struct apic apic_x2apic_cluster __read_only = {
16939
16940 .name = "cluster x2apic",
16941 .probe = x2apic_cluster_probe,
16942 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
16943 index 562a76d..a003c0f 100644
16944 --- a/arch/x86/kernel/apic/x2apic_phys.c
16945 +++ b/arch/x86/kernel/apic/x2apic_phys.c
16946 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
16947 return apic == &apic_x2apic_phys;
16948 }
16949
16950 -static struct apic apic_x2apic_phys = {
16951 +static struct apic apic_x2apic_phys __read_only = {
16952
16953 .name = "physical x2apic",
16954 .probe = x2apic_phys_probe,
16955 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
16956 index 794f6eb..67e1db2 100644
16957 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
16958 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
16959 @@ -342,7 +342,7 @@ static int uv_probe(void)
16960 return apic == &apic_x2apic_uv_x;
16961 }
16962
16963 -static struct apic __refdata apic_x2apic_uv_x = {
16964 +static struct apic apic_x2apic_uv_x __read_only = {
16965
16966 .name = "UV large system",
16967 .probe = uv_probe,
16968 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
16969 index 66b5faf..3442423 100644
16970 --- a/arch/x86/kernel/apm_32.c
16971 +++ b/arch/x86/kernel/apm_32.c
16972 @@ -434,7 +434,7 @@ static DEFINE_MUTEX(apm_mutex);
16973 * This is for buggy BIOS's that refer to (real mode) segment 0x40
16974 * even though they are called in protected mode.
16975 */
16976 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
16977 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
16978 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
16979
16980 static const char driver_version[] = "1.16ac"; /* no spaces */
16981 @@ -612,7 +612,10 @@ static long __apm_bios_call(void *_call)
16982 BUG_ON(cpu != 0);
16983 gdt = get_cpu_gdt_table(cpu);
16984 save_desc_40 = gdt[0x40 / 8];
16985 +
16986 + pax_open_kernel();
16987 gdt[0x40 / 8] = bad_bios_desc;
16988 + pax_close_kernel();
16989
16990 apm_irq_save(flags);
16991 APM_DO_SAVE_SEGS;
16992 @@ -621,7 +624,11 @@ static long __apm_bios_call(void *_call)
16993 &call->esi);
16994 APM_DO_RESTORE_SEGS;
16995 apm_irq_restore(flags);
16996 +
16997 + pax_open_kernel();
16998 gdt[0x40 / 8] = save_desc_40;
16999 + pax_close_kernel();
17000 +
17001 put_cpu();
17002
17003 return call->eax & 0xff;
17004 @@ -688,7 +695,10 @@ static long __apm_bios_call_simple(void *_call)
17005 BUG_ON(cpu != 0);
17006 gdt = get_cpu_gdt_table(cpu);
17007 save_desc_40 = gdt[0x40 / 8];
17008 +
17009 + pax_open_kernel();
17010 gdt[0x40 / 8] = bad_bios_desc;
17011 + pax_close_kernel();
17012
17013 apm_irq_save(flags);
17014 APM_DO_SAVE_SEGS;
17015 @@ -696,7 +706,11 @@ static long __apm_bios_call_simple(void *_call)
17016 &call->eax);
17017 APM_DO_RESTORE_SEGS;
17018 apm_irq_restore(flags);
17019 +
17020 + pax_open_kernel();
17021 gdt[0x40 / 8] = save_desc_40;
17022 + pax_close_kernel();
17023 +
17024 put_cpu();
17025 return error;
17026 }
17027 @@ -2363,12 +2377,15 @@ static int __init apm_init(void)
17028 * code to that CPU.
17029 */
17030 gdt = get_cpu_gdt_table(0);
17031 +
17032 + pax_open_kernel();
17033 set_desc_base(&gdt[APM_CS >> 3],
17034 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17035 set_desc_base(&gdt[APM_CS_16 >> 3],
17036 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17037 set_desc_base(&gdt[APM_DS >> 3],
17038 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17039 + pax_close_kernel();
17040
17041 proc_create("apm", 0, NULL, &apm_file_ops);
17042
17043 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17044 index 2861082..6d4718e 100644
17045 --- a/arch/x86/kernel/asm-offsets.c
17046 +++ b/arch/x86/kernel/asm-offsets.c
17047 @@ -33,6 +33,8 @@ void common(void) {
17048 OFFSET(TI_status, thread_info, status);
17049 OFFSET(TI_addr_limit, thread_info, addr_limit);
17050 OFFSET(TI_preempt_count, thread_info, preempt_count);
17051 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17052 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17053
17054 BLANK();
17055 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17056 @@ -53,8 +55,26 @@ void common(void) {
17057 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17058 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17059 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17060 +
17061 +#ifdef CONFIG_PAX_KERNEXEC
17062 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17063 #endif
17064
17065 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17066 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17067 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17068 +#ifdef CONFIG_X86_64
17069 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17070 +#endif
17071 +#endif
17072 +
17073 +#endif
17074 +
17075 + BLANK();
17076 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17077 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17078 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17079 +
17080 #ifdef CONFIG_XEN
17081 BLANK();
17082 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17083 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17084 index 1b4754f..fbb4227 100644
17085 --- a/arch/x86/kernel/asm-offsets_64.c
17086 +++ b/arch/x86/kernel/asm-offsets_64.c
17087 @@ -76,6 +76,7 @@ int main(void)
17088 BLANK();
17089 #undef ENTRY
17090
17091 + DEFINE(TSS_size, sizeof(struct tss_struct));
17092 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17093 BLANK();
17094
17095 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17096 index a0e067d..9c7db16 100644
17097 --- a/arch/x86/kernel/cpu/Makefile
17098 +++ b/arch/x86/kernel/cpu/Makefile
17099 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17100 CFLAGS_REMOVE_perf_event.o = -pg
17101 endif
17102
17103 -# Make sure load_percpu_segment has no stackprotector
17104 -nostackp := $(call cc-option, -fno-stack-protector)
17105 -CFLAGS_common.o := $(nostackp)
17106 -
17107 obj-y := intel_cacheinfo.o scattered.o topology.o
17108 obj-y += proc.o capflags.o powerflags.o common.o
17109 obj-y += vmware.o hypervisor.o mshyperv.o
17110 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17111 index fa96eb0..03efe73 100644
17112 --- a/arch/x86/kernel/cpu/amd.c
17113 +++ b/arch/x86/kernel/cpu/amd.c
17114 @@ -737,7 +737,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17115 unsigned int size)
17116 {
17117 /* AMD errata T13 (order #21922) */
17118 - if ((c->x86 == 6)) {
17119 + if (c->x86 == 6) {
17120 /* Duron Rev A0 */
17121 if (c->x86_model == 3 && c->x86_mask == 0)
17122 size = 64;
17123 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17124 index d814772..c615653 100644
17125 --- a/arch/x86/kernel/cpu/common.c
17126 +++ b/arch/x86/kernel/cpu/common.c
17127 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17128
17129 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17130
17131 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17132 -#ifdef CONFIG_X86_64
17133 - /*
17134 - * We need valid kernel segments for data and code in long mode too
17135 - * IRET will check the segment types kkeil 2000/10/28
17136 - * Also sysret mandates a special GDT layout
17137 - *
17138 - * TLS descriptors are currently at a different place compared to i386.
17139 - * Hopefully nobody expects them at a fixed place (Wine?)
17140 - */
17141 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17142 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17143 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17144 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17145 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17146 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17147 -#else
17148 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17149 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17150 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17151 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17152 - /*
17153 - * Segments used for calling PnP BIOS have byte granularity.
17154 - * They code segments and data segments have fixed 64k limits,
17155 - * the transfer segment sizes are set at run time.
17156 - */
17157 - /* 32-bit code */
17158 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17159 - /* 16-bit code */
17160 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17161 - /* 16-bit data */
17162 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17163 - /* 16-bit data */
17164 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17165 - /* 16-bit data */
17166 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17167 - /*
17168 - * The APM segments have byte granularity and their bases
17169 - * are set at run time. All have 64k limits.
17170 - */
17171 - /* 32-bit code */
17172 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17173 - /* 16-bit code */
17174 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17175 - /* data */
17176 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17177 -
17178 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17179 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17180 - GDT_STACK_CANARY_INIT
17181 -#endif
17182 -} };
17183 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17184 -
17185 static int __init x86_xsave_setup(char *s)
17186 {
17187 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17188 @@ -386,7 +332,7 @@ void switch_to_new_gdt(int cpu)
17189 {
17190 struct desc_ptr gdt_descr;
17191
17192 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17193 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17194 gdt_descr.size = GDT_SIZE - 1;
17195 load_gdt(&gdt_descr);
17196 /* Reload the per-cpu base */
17197 @@ -882,6 +828,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17198 /* Filter out anything that depends on CPUID levels we don't have */
17199 filter_cpuid_features(c, true);
17200
17201 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17202 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17203 +#endif
17204 +
17205 /* If the model name is still unset, do table lookup. */
17206 if (!c->x86_model_id[0]) {
17207 const char *p;
17208 @@ -1065,10 +1015,12 @@ static __init int setup_disablecpuid(char *arg)
17209 }
17210 __setup("clearcpuid=", setup_disablecpuid);
17211
17212 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17213 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17214 +
17215 #ifdef CONFIG_X86_64
17216 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17217 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17218 - (unsigned long) nmi_idt_table };
17219 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17220
17221 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17222 irq_stack_union) __aligned(PAGE_SIZE);
17223 @@ -1082,7 +1034,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17224 EXPORT_PER_CPU_SYMBOL(current_task);
17225
17226 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17227 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17228 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17229 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17230
17231 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17232 @@ -1227,7 +1179,7 @@ void __cpuinit cpu_init(void)
17233 load_ucode_ap();
17234
17235 cpu = stack_smp_processor_id();
17236 - t = &per_cpu(init_tss, cpu);
17237 + t = init_tss + cpu;
17238 oist = &per_cpu(orig_ist, cpu);
17239
17240 #ifdef CONFIG_NUMA
17241 @@ -1253,7 +1205,7 @@ void __cpuinit cpu_init(void)
17242 switch_to_new_gdt(cpu);
17243 loadsegment(fs, 0);
17244
17245 - load_idt((const struct desc_ptr *)&idt_descr);
17246 + load_idt(&idt_descr);
17247
17248 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17249 syscall_init();
17250 @@ -1262,7 +1214,6 @@ void __cpuinit cpu_init(void)
17251 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17252 barrier();
17253
17254 - x86_configure_nx();
17255 enable_x2apic();
17256
17257 /*
17258 @@ -1314,7 +1265,7 @@ void __cpuinit cpu_init(void)
17259 {
17260 int cpu = smp_processor_id();
17261 struct task_struct *curr = current;
17262 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17263 + struct tss_struct *t = init_tss + cpu;
17264 struct thread_struct *thread = &curr->thread;
17265
17266 show_ucode_info_early();
17267 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17268 index 1905ce9..a7ac587 100644
17269 --- a/arch/x86/kernel/cpu/intel.c
17270 +++ b/arch/x86/kernel/cpu/intel.c
17271 @@ -173,7 +173,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17272 * Update the IDT descriptor and reload the IDT so that
17273 * it uses the read-only mapped virtual address.
17274 */
17275 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17276 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17277 load_idt(&idt_descr);
17278 }
17279 #endif
17280 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17281 index 7c6f7d5..8cac382 100644
17282 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17283 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17284 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17285 };
17286
17287 #ifdef CONFIG_AMD_NB
17288 +static struct attribute *default_attrs_amd_nb[] = {
17289 + &type.attr,
17290 + &level.attr,
17291 + &coherency_line_size.attr,
17292 + &physical_line_partition.attr,
17293 + &ways_of_associativity.attr,
17294 + &number_of_sets.attr,
17295 + &size.attr,
17296 + &shared_cpu_map.attr,
17297 + &shared_cpu_list.attr,
17298 + NULL,
17299 + NULL,
17300 + NULL,
17301 + NULL
17302 +};
17303 +
17304 static struct attribute ** __cpuinit amd_l3_attrs(void)
17305 {
17306 static struct attribute **attrs;
17307 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17308
17309 n = ARRAY_SIZE(default_attrs);
17310
17311 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17312 - n += 2;
17313 -
17314 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17315 - n += 1;
17316 -
17317 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17318 - if (attrs == NULL)
17319 - return attrs = default_attrs;
17320 -
17321 - for (n = 0; default_attrs[n]; n++)
17322 - attrs[n] = default_attrs[n];
17323 + attrs = default_attrs_amd_nb;
17324
17325 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17326 attrs[n++] = &cache_disable_0.attr;
17327 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17328 .default_attrs = default_attrs,
17329 };
17330
17331 +#ifdef CONFIG_AMD_NB
17332 +static struct kobj_type ktype_cache_amd_nb = {
17333 + .sysfs_ops = &sysfs_ops,
17334 + .default_attrs = default_attrs_amd_nb,
17335 +};
17336 +#endif
17337 +
17338 static struct kobj_type ktype_percpu_entry = {
17339 .sysfs_ops = &sysfs_ops,
17340 };
17341 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17342 return retval;
17343 }
17344
17345 +#ifdef CONFIG_AMD_NB
17346 + amd_l3_attrs();
17347 +#endif
17348 +
17349 for (i = 0; i < num_cache_leaves; i++) {
17350 + struct kobj_type *ktype;
17351 +
17352 this_object = INDEX_KOBJECT_PTR(cpu, i);
17353 this_object->cpu = cpu;
17354 this_object->index = i;
17355
17356 this_leaf = CPUID4_INFO_IDX(cpu, i);
17357
17358 - ktype_cache.default_attrs = default_attrs;
17359 + ktype = &ktype_cache;
17360 #ifdef CONFIG_AMD_NB
17361 if (this_leaf->base.nb)
17362 - ktype_cache.default_attrs = amd_l3_attrs();
17363 + ktype = &ktype_cache_amd_nb;
17364 #endif
17365 retval = kobject_init_and_add(&(this_object->kobj),
17366 - &ktype_cache,
17367 + ktype,
17368 per_cpu(ici_cache_kobject, cpu),
17369 "index%1lu", i);
17370 if (unlikely(retval)) {
17371 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17372 return NOTIFY_OK;
17373 }
17374
17375 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17376 +static struct notifier_block cacheinfo_cpu_notifier = {
17377 .notifier_call = cacheinfo_cpu_callback,
17378 };
17379
17380 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17381 index 7bc1263..ce2cbfb 100644
17382 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17383 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17384 @@ -45,6 +45,7 @@
17385 #include <asm/processor.h>
17386 #include <asm/mce.h>
17387 #include <asm/msr.h>
17388 +#include <asm/local.h>
17389
17390 #include "mce-internal.h"
17391
17392 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17393 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17394 m->cs, m->ip);
17395
17396 - if (m->cs == __KERNEL_CS)
17397 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17398 print_symbol("{%s}", m->ip);
17399 pr_cont("\n");
17400 }
17401 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17402
17403 #define PANIC_TIMEOUT 5 /* 5 seconds */
17404
17405 -static atomic_t mce_paniced;
17406 +static atomic_unchecked_t mce_paniced;
17407
17408 static int fake_panic;
17409 -static atomic_t mce_fake_paniced;
17410 +static atomic_unchecked_t mce_fake_paniced;
17411
17412 /* Panic in progress. Enable interrupts and wait for final IPI */
17413 static void wait_for_panic(void)
17414 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17415 /*
17416 * Make sure only one CPU runs in machine check panic
17417 */
17418 - if (atomic_inc_return(&mce_paniced) > 1)
17419 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17420 wait_for_panic();
17421 barrier();
17422
17423 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17424 console_verbose();
17425 } else {
17426 /* Don't log too much for fake panic */
17427 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17428 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17429 return;
17430 }
17431 /* First print corrected ones that are still unlogged */
17432 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
17433 * might have been modified by someone else.
17434 */
17435 rmb();
17436 - if (atomic_read(&mce_paniced))
17437 + if (atomic_read_unchecked(&mce_paniced))
17438 wait_for_panic();
17439 if (!mca_cfg.monarch_timeout)
17440 goto out;
17441 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17442 }
17443
17444 /* Call the installed machine check handler for this CPU setup. */
17445 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17446 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17447 unexpected_machine_check;
17448
17449 /*
17450 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17451 return;
17452 }
17453
17454 + pax_open_kernel();
17455 machine_check_vector = do_machine_check;
17456 + pax_close_kernel();
17457
17458 __mcheck_cpu_init_generic();
17459 __mcheck_cpu_init_vendor(c);
17460 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17461 */
17462
17463 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17464 -static int mce_chrdev_open_count; /* #times opened */
17465 +static local_t mce_chrdev_open_count; /* #times opened */
17466 static int mce_chrdev_open_exclu; /* already open exclusive? */
17467
17468 static int mce_chrdev_open(struct inode *inode, struct file *file)
17469 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17470 spin_lock(&mce_chrdev_state_lock);
17471
17472 if (mce_chrdev_open_exclu ||
17473 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17474 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17475 spin_unlock(&mce_chrdev_state_lock);
17476
17477 return -EBUSY;
17478 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17479
17480 if (file->f_flags & O_EXCL)
17481 mce_chrdev_open_exclu = 1;
17482 - mce_chrdev_open_count++;
17483 + local_inc(&mce_chrdev_open_count);
17484
17485 spin_unlock(&mce_chrdev_state_lock);
17486
17487 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17488 {
17489 spin_lock(&mce_chrdev_state_lock);
17490
17491 - mce_chrdev_open_count--;
17492 + local_dec(&mce_chrdev_open_count);
17493 mce_chrdev_open_exclu = 0;
17494
17495 spin_unlock(&mce_chrdev_state_lock);
17496 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17497 return NOTIFY_OK;
17498 }
17499
17500 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17501 +static struct notifier_block mce_cpu_notifier = {
17502 .notifier_call = mce_cpu_callback,
17503 };
17504
17505 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
17506
17507 for (i = 0; i < mca_cfg.banks; i++) {
17508 struct mce_bank *b = &mce_banks[i];
17509 - struct device_attribute *a = &b->attr;
17510 + device_attribute_no_const *a = &b->attr;
17511
17512 sysfs_attr_init(&a->attr);
17513 a->attr.name = b->attrname;
17514 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
17515 static void mce_reset(void)
17516 {
17517 cpu_missing = 0;
17518 - atomic_set(&mce_fake_paniced, 0);
17519 + atomic_set_unchecked(&mce_fake_paniced, 0);
17520 atomic_set(&mce_executing, 0);
17521 atomic_set(&mce_callin, 0);
17522 atomic_set(&global_nwo, 0);
17523 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17524 index 1c044b1..37a2a43 100644
17525 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17526 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17527 @@ -11,6 +11,7 @@
17528 #include <asm/processor.h>
17529 #include <asm/mce.h>
17530 #include <asm/msr.h>
17531 +#include <asm/pgtable.h>
17532
17533 /* By default disabled */
17534 int mce_p5_enabled __read_mostly;
17535 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17536 if (!cpu_has(c, X86_FEATURE_MCE))
17537 return;
17538
17539 + pax_open_kernel();
17540 machine_check_vector = pentium_machine_check;
17541 + pax_close_kernel();
17542 /* Make sure the vector pointer is visible before we enable MCEs: */
17543 wmb();
17544
17545 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17546 index 47a1870..8c019a7 100644
17547 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17548 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17549 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17550 return notifier_from_errno(err);
17551 }
17552
17553 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17554 +static struct notifier_block thermal_throttle_cpu_notifier =
17555 {
17556 .notifier_call = thermal_throttle_cpu_callback,
17557 };
17558 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17559 index e9a701a..35317d6 100644
17560 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17561 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17562 @@ -10,6 +10,7 @@
17563 #include <asm/processor.h>
17564 #include <asm/mce.h>
17565 #include <asm/msr.h>
17566 +#include <asm/pgtable.h>
17567
17568 /* Machine check handler for WinChip C6: */
17569 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17570 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17571 {
17572 u32 lo, hi;
17573
17574 + pax_open_kernel();
17575 machine_check_vector = winchip_machine_check;
17576 + pax_close_kernel();
17577 /* Make sure the vector pointer is visible before we enable MCEs: */
17578 wmb();
17579
17580 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17581 index 726bf96..81f0526 100644
17582 --- a/arch/x86/kernel/cpu/mtrr/main.c
17583 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17584 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17585 u64 size_or_mask, size_and_mask;
17586 static bool mtrr_aps_delayed_init;
17587
17588 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17589 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17590
17591 const struct mtrr_ops *mtrr_if;
17592
17593 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17594 index df5e41f..816c719 100644
17595 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17596 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17597 @@ -25,7 +25,7 @@ struct mtrr_ops {
17598 int (*validate_add_page)(unsigned long base, unsigned long size,
17599 unsigned int type);
17600 int (*have_wrcomb)(void);
17601 -};
17602 +} __do_const;
17603
17604 extern int generic_get_free_region(unsigned long base, unsigned long size,
17605 int replace_reg);
17606 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17607 index bf0f01a..9adfee1 100644
17608 --- a/arch/x86/kernel/cpu/perf_event.c
17609 +++ b/arch/x86/kernel/cpu/perf_event.c
17610 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17611 pr_info("no hardware sampling interrupt available.\n");
17612 }
17613
17614 -static struct attribute_group x86_pmu_format_group = {
17615 +static attribute_group_no_const x86_pmu_format_group = {
17616 .name = "format",
17617 .attrs = NULL,
17618 };
17619 @@ -1374,7 +1374,7 @@ static struct attribute *events_attr[] = {
17620 NULL,
17621 };
17622
17623 -static struct attribute_group x86_pmu_events_group = {
17624 +static attribute_group_no_const x86_pmu_events_group = {
17625 .name = "events",
17626 .attrs = events_attr,
17627 };
17628 @@ -1873,7 +1873,7 @@ static unsigned long get_segment_base(unsigned int segment)
17629 if (idx > GDT_ENTRIES)
17630 return 0;
17631
17632 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17633 + desc = get_cpu_gdt_table(smp_processor_id());
17634 }
17635
17636 return get_desc_base(desc + idx);
17637 @@ -1963,7 +1963,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17638 break;
17639
17640 perf_callchain_store(entry, frame.return_address);
17641 - fp = frame.next_frame;
17642 + fp = (const void __force_user *)frame.next_frame;
17643 }
17644 }
17645
17646 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17647 index 4a0a462..be3b204 100644
17648 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17649 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17650 @@ -1994,10 +1994,10 @@ __init int intel_pmu_init(void)
17651 * v2 and above have a perf capabilities MSR
17652 */
17653 if (version > 1) {
17654 - u64 capabilities;
17655 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17656
17657 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17658 - x86_pmu.intel_cap.capabilities = capabilities;
17659 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17660 + x86_pmu.intel_cap.capabilities = capabilities;
17661 }
17662
17663 intel_ds_init();
17664 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17665 index 3e091f0..d2dc8d6 100644
17666 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17667 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17668 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17669 static int __init uncore_type_init(struct intel_uncore_type *type)
17670 {
17671 struct intel_uncore_pmu *pmus;
17672 - struct attribute_group *attr_group;
17673 + attribute_group_no_const *attr_group;
17674 struct attribute **attrs;
17675 int i, j;
17676
17677 @@ -2826,7 +2826,7 @@ static int
17678 return NOTIFY_OK;
17679 }
17680
17681 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17682 +static struct notifier_block uncore_cpu_nb = {
17683 .notifier_call = uncore_cpu_notifier,
17684 /*
17685 * to migrate uncore events, our notifier should be executed
17686 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17687 index e68a455..975a932 100644
17688 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17689 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17690 @@ -428,7 +428,7 @@ struct intel_uncore_box {
17691 struct uncore_event_desc {
17692 struct kobj_attribute attr;
17693 const char *config;
17694 -};
17695 +} __do_const;
17696
17697 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17698 { \
17699 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17700 index 1e4dbcf..b9a34c2 100644
17701 --- a/arch/x86/kernel/cpuid.c
17702 +++ b/arch/x86/kernel/cpuid.c
17703 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17704 return notifier_from_errno(err);
17705 }
17706
17707 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17708 +static struct notifier_block cpuid_class_cpu_notifier =
17709 {
17710 .notifier_call = cpuid_class_cpu_callback,
17711 };
17712 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17713 index 74467fe..18793d5 100644
17714 --- a/arch/x86/kernel/crash.c
17715 +++ b/arch/x86/kernel/crash.c
17716 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17717 {
17718 #ifdef CONFIG_X86_32
17719 struct pt_regs fixed_regs;
17720 -#endif
17721
17722 -#ifdef CONFIG_X86_32
17723 - if (!user_mode_vm(regs)) {
17724 + if (!user_mode(regs)) {
17725 crash_fixup_ss_esp(&fixed_regs, regs);
17726 regs = &fixed_regs;
17727 }
17728 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
17729 index afa64ad..dce67dd 100644
17730 --- a/arch/x86/kernel/crash_dump_64.c
17731 +++ b/arch/x86/kernel/crash_dump_64.c
17732 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
17733 return -ENOMEM;
17734
17735 if (userbuf) {
17736 - if (copy_to_user(buf, vaddr + offset, csize)) {
17737 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
17738 iounmap(vaddr);
17739 return -EFAULT;
17740 }
17741 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17742 index 37250fe..bf2ec74 100644
17743 --- a/arch/x86/kernel/doublefault_32.c
17744 +++ b/arch/x86/kernel/doublefault_32.c
17745 @@ -11,7 +11,7 @@
17746
17747 #define DOUBLEFAULT_STACKSIZE (1024)
17748 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17749 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17750 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17751
17752 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17753
17754 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17755 unsigned long gdt, tss;
17756
17757 store_gdt(&gdt_desc);
17758 - gdt = gdt_desc.address;
17759 + gdt = (unsigned long)gdt_desc.address;
17760
17761 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17762
17763 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17764 /* 0x2 bit is always set */
17765 .flags = X86_EFLAGS_SF | 0x2,
17766 .sp = STACK_START,
17767 - .es = __USER_DS,
17768 + .es = __KERNEL_DS,
17769 .cs = __KERNEL_CS,
17770 .ss = __KERNEL_DS,
17771 - .ds = __USER_DS,
17772 + .ds = __KERNEL_DS,
17773 .fs = __KERNEL_PERCPU,
17774
17775 .__cr3 = __pa_nodebug(swapper_pg_dir),
17776 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17777 index c8797d5..c605e53 100644
17778 --- a/arch/x86/kernel/dumpstack.c
17779 +++ b/arch/x86/kernel/dumpstack.c
17780 @@ -2,6 +2,9 @@
17781 * Copyright (C) 1991, 1992 Linus Torvalds
17782 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17783 */
17784 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17785 +#define __INCLUDED_BY_HIDESYM 1
17786 +#endif
17787 #include <linux/kallsyms.h>
17788 #include <linux/kprobes.h>
17789 #include <linux/uaccess.h>
17790 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17791 static void
17792 print_ftrace_graph_addr(unsigned long addr, void *data,
17793 const struct stacktrace_ops *ops,
17794 - struct thread_info *tinfo, int *graph)
17795 + struct task_struct *task, int *graph)
17796 {
17797 - struct task_struct *task;
17798 unsigned long ret_addr;
17799 int index;
17800
17801 if (addr != (unsigned long)return_to_handler)
17802 return;
17803
17804 - task = tinfo->task;
17805 index = task->curr_ret_stack;
17806
17807 if (!task->ret_stack || index < *graph)
17808 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17809 static inline void
17810 print_ftrace_graph_addr(unsigned long addr, void *data,
17811 const struct stacktrace_ops *ops,
17812 - struct thread_info *tinfo, int *graph)
17813 + struct task_struct *task, int *graph)
17814 { }
17815 #endif
17816
17817 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17818 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17819 */
17820
17821 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17822 - void *p, unsigned int size, void *end)
17823 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17824 {
17825 - void *t = tinfo;
17826 if (end) {
17827 if (p < end && p >= (end-THREAD_SIZE))
17828 return 1;
17829 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17830 }
17831
17832 unsigned long
17833 -print_context_stack(struct thread_info *tinfo,
17834 +print_context_stack(struct task_struct *task, void *stack_start,
17835 unsigned long *stack, unsigned long bp,
17836 const struct stacktrace_ops *ops, void *data,
17837 unsigned long *end, int *graph)
17838 {
17839 struct stack_frame *frame = (struct stack_frame *)bp;
17840
17841 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17842 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17843 unsigned long addr;
17844
17845 addr = *stack;
17846 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17847 } else {
17848 ops->address(data, addr, 0);
17849 }
17850 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17851 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17852 }
17853 stack++;
17854 }
17855 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17856 EXPORT_SYMBOL_GPL(print_context_stack);
17857
17858 unsigned long
17859 -print_context_stack_bp(struct thread_info *tinfo,
17860 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17861 unsigned long *stack, unsigned long bp,
17862 const struct stacktrace_ops *ops, void *data,
17863 unsigned long *end, int *graph)
17864 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17865 struct stack_frame *frame = (struct stack_frame *)bp;
17866 unsigned long *ret_addr = &frame->return_address;
17867
17868 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17869 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17870 unsigned long addr = *ret_addr;
17871
17872 if (!__kernel_text_address(addr))
17873 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17874 ops->address(data, addr, 1);
17875 frame = frame->next_frame;
17876 ret_addr = &frame->return_address;
17877 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17878 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17879 }
17880
17881 return (unsigned long)frame;
17882 @@ -189,7 +188,7 @@ void dump_stack(void)
17883
17884 bp = stack_frame(current, NULL);
17885 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
17886 - current->pid, current->comm, print_tainted(),
17887 + task_pid_nr(current), current->comm, print_tainted(),
17888 init_utsname()->release,
17889 (int)strcspn(init_utsname()->version, " "),
17890 init_utsname()->version);
17891 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
17892 }
17893 EXPORT_SYMBOL_GPL(oops_begin);
17894
17895 +extern void gr_handle_kernel_exploit(void);
17896 +
17897 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17898 {
17899 if (regs && kexec_should_crash(current))
17900 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17901 panic("Fatal exception in interrupt");
17902 if (panic_on_oops)
17903 panic("Fatal exception");
17904 - do_exit(signr);
17905 +
17906 + gr_handle_kernel_exploit();
17907 +
17908 + do_group_exit(signr);
17909 }
17910
17911 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17912 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17913 print_modules();
17914 show_regs(regs);
17915 #ifdef CONFIG_X86_32
17916 - if (user_mode_vm(regs)) {
17917 + if (user_mode(regs)) {
17918 sp = regs->sp;
17919 ss = regs->ss & 0xffff;
17920 } else {
17921 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17922 unsigned long flags = oops_begin();
17923 int sig = SIGSEGV;
17924
17925 - if (!user_mode_vm(regs))
17926 + if (!user_mode(regs))
17927 report_bug(regs->ip, regs);
17928
17929 if (__die(str, regs, err))
17930 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17931 index 1038a41..db2c12b 100644
17932 --- a/arch/x86/kernel/dumpstack_32.c
17933 +++ b/arch/x86/kernel/dumpstack_32.c
17934 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17935 bp = stack_frame(task, regs);
17936
17937 for (;;) {
17938 - struct thread_info *context;
17939 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17940
17941 - context = (struct thread_info *)
17942 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17943 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
17944 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
17945
17946 - stack = (unsigned long *)context->previous_esp;
17947 - if (!stack)
17948 + if (stack_start == task_stack_page(task))
17949 break;
17950 + stack = *(unsigned long **)stack_start;
17951 if (ops->stack(data, "IRQ") < 0)
17952 break;
17953 touch_nmi_watchdog();
17954 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
17955 {
17956 int i;
17957
17958 - __show_regs(regs, !user_mode_vm(regs));
17959 + __show_regs(regs, !user_mode(regs));
17960
17961 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
17962 TASK_COMM_LEN, current->comm, task_pid_nr(current),
17963 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
17964 * When in-kernel, we also print out the stack and code at the
17965 * time of the fault..
17966 */
17967 - if (!user_mode_vm(regs)) {
17968 + if (!user_mode(regs)) {
17969 unsigned int code_prologue = code_bytes * 43 / 64;
17970 unsigned int code_len = code_bytes;
17971 unsigned char c;
17972 u8 *ip;
17973 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
17974
17975 pr_emerg("Stack:\n");
17976 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
17977
17978 pr_emerg("Code:");
17979
17980 - ip = (u8 *)regs->ip - code_prologue;
17981 + ip = (u8 *)regs->ip - code_prologue + cs_base;
17982 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
17983 /* try starting at IP */
17984 - ip = (u8 *)regs->ip;
17985 + ip = (u8 *)regs->ip + cs_base;
17986 code_len = code_len - code_prologue + 1;
17987 }
17988 for (i = 0; i < code_len; i++, ip++) {
17989 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
17990 pr_cont(" Bad EIP value.");
17991 break;
17992 }
17993 - if (ip == (u8 *)regs->ip)
17994 + if (ip == (u8 *)regs->ip + cs_base)
17995 pr_cont(" <%02x>", c);
17996 else
17997 pr_cont(" %02x", c);
17998 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
17999 {
18000 unsigned short ud2;
18001
18002 + ip = ktla_ktva(ip);
18003 if (ip < PAGE_OFFSET)
18004 return 0;
18005 if (probe_kernel_address((unsigned short *)ip, ud2))
18006 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18007
18008 return ud2 == 0x0b0f;
18009 }
18010 +
18011 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18012 +void pax_check_alloca(unsigned long size)
18013 +{
18014 + unsigned long sp = (unsigned long)&sp, stack_left;
18015 +
18016 + /* all kernel stacks are of the same size */
18017 + stack_left = sp & (THREAD_SIZE - 1);
18018 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18019 +}
18020 +EXPORT_SYMBOL(pax_check_alloca);
18021 +#endif
18022 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18023 index b653675..51cc8c0 100644
18024 --- a/arch/x86/kernel/dumpstack_64.c
18025 +++ b/arch/x86/kernel/dumpstack_64.c
18026 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18027 unsigned long *irq_stack_end =
18028 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18029 unsigned used = 0;
18030 - struct thread_info *tinfo;
18031 int graph = 0;
18032 unsigned long dummy;
18033 + void *stack_start;
18034
18035 if (!task)
18036 task = current;
18037 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18038 * current stack address. If the stacks consist of nested
18039 * exceptions
18040 */
18041 - tinfo = task_thread_info(task);
18042 for (;;) {
18043 char *id;
18044 unsigned long *estack_end;
18045 +
18046 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18047 &used, &id);
18048
18049 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18050 if (ops->stack(data, id) < 0)
18051 break;
18052
18053 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18054 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18055 data, estack_end, &graph);
18056 ops->stack(data, "<EOE>");
18057 /*
18058 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18059 * second-to-last pointer (index -2 to end) in the
18060 * exception stack:
18061 */
18062 + if ((u16)estack_end[-1] != __KERNEL_DS)
18063 + goto out;
18064 stack = (unsigned long *) estack_end[-2];
18065 continue;
18066 }
18067 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18068 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18069 if (ops->stack(data, "IRQ") < 0)
18070 break;
18071 - bp = ops->walk_stack(tinfo, stack, bp,
18072 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18073 ops, data, irq_stack_end, &graph);
18074 /*
18075 * We link to the next stack (which would be
18076 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18077 /*
18078 * This handles the process stack:
18079 */
18080 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18081 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18082 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18083 +out:
18084 put_cpu();
18085 }
18086 EXPORT_SYMBOL(dump_trace);
18087 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18088 {
18089 int i;
18090 unsigned long sp;
18091 - const int cpu = smp_processor_id();
18092 + const int cpu = raw_smp_processor_id();
18093 struct task_struct *cur = current;
18094
18095 sp = regs->sp;
18096 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18097
18098 return ud2 == 0x0b0f;
18099 }
18100 +
18101 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18102 +void pax_check_alloca(unsigned long size)
18103 +{
18104 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18105 + unsigned cpu, used;
18106 + char *id;
18107 +
18108 + /* check the process stack first */
18109 + stack_start = (unsigned long)task_stack_page(current);
18110 + stack_end = stack_start + THREAD_SIZE;
18111 + if (likely(stack_start <= sp && sp < stack_end)) {
18112 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18113 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18114 + return;
18115 + }
18116 +
18117 + cpu = get_cpu();
18118 +
18119 + /* check the irq stacks */
18120 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18121 + stack_start = stack_end - IRQ_STACK_SIZE;
18122 + if (stack_start <= sp && sp < stack_end) {
18123 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18124 + put_cpu();
18125 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18126 + return;
18127 + }
18128 +
18129 + /* check the exception stacks */
18130 + used = 0;
18131 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18132 + stack_start = stack_end - EXCEPTION_STKSZ;
18133 + if (stack_end && stack_start <= sp && sp < stack_end) {
18134 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18135 + put_cpu();
18136 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18137 + return;
18138 + }
18139 +
18140 + put_cpu();
18141 +
18142 + /* unknown stack */
18143 + BUG();
18144 +}
18145 +EXPORT_SYMBOL(pax_check_alloca);
18146 +#endif
18147 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18148 index 9b9f18b..9fcaa04 100644
18149 --- a/arch/x86/kernel/early_printk.c
18150 +++ b/arch/x86/kernel/early_printk.c
18151 @@ -7,6 +7,7 @@
18152 #include <linux/pci_regs.h>
18153 #include <linux/pci_ids.h>
18154 #include <linux/errno.h>
18155 +#include <linux/sched.h>
18156 #include <asm/io.h>
18157 #include <asm/processor.h>
18158 #include <asm/fcntl.h>
18159 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18160 index 8f3e2de..934870f 100644
18161 --- a/arch/x86/kernel/entry_32.S
18162 +++ b/arch/x86/kernel/entry_32.S
18163 @@ -177,13 +177,153 @@
18164 /*CFI_REL_OFFSET gs, PT_GS*/
18165 .endm
18166 .macro SET_KERNEL_GS reg
18167 +
18168 +#ifdef CONFIG_CC_STACKPROTECTOR
18169 movl $(__KERNEL_STACK_CANARY), \reg
18170 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18171 + movl $(__USER_DS), \reg
18172 +#else
18173 + xorl \reg, \reg
18174 +#endif
18175 +
18176 movl \reg, %gs
18177 .endm
18178
18179 #endif /* CONFIG_X86_32_LAZY_GS */
18180
18181 -.macro SAVE_ALL
18182 +.macro pax_enter_kernel
18183 +#ifdef CONFIG_PAX_KERNEXEC
18184 + call pax_enter_kernel
18185 +#endif
18186 +.endm
18187 +
18188 +.macro pax_exit_kernel
18189 +#ifdef CONFIG_PAX_KERNEXEC
18190 + call pax_exit_kernel
18191 +#endif
18192 +.endm
18193 +
18194 +#ifdef CONFIG_PAX_KERNEXEC
18195 +ENTRY(pax_enter_kernel)
18196 +#ifdef CONFIG_PARAVIRT
18197 + pushl %eax
18198 + pushl %ecx
18199 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18200 + mov %eax, %esi
18201 +#else
18202 + mov %cr0, %esi
18203 +#endif
18204 + bts $16, %esi
18205 + jnc 1f
18206 + mov %cs, %esi
18207 + cmp $__KERNEL_CS, %esi
18208 + jz 3f
18209 + ljmp $__KERNEL_CS, $3f
18210 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18211 +2:
18212 +#ifdef CONFIG_PARAVIRT
18213 + mov %esi, %eax
18214 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18215 +#else
18216 + mov %esi, %cr0
18217 +#endif
18218 +3:
18219 +#ifdef CONFIG_PARAVIRT
18220 + popl %ecx
18221 + popl %eax
18222 +#endif
18223 + ret
18224 +ENDPROC(pax_enter_kernel)
18225 +
18226 +ENTRY(pax_exit_kernel)
18227 +#ifdef CONFIG_PARAVIRT
18228 + pushl %eax
18229 + pushl %ecx
18230 +#endif
18231 + mov %cs, %esi
18232 + cmp $__KERNEXEC_KERNEL_CS, %esi
18233 + jnz 2f
18234 +#ifdef CONFIG_PARAVIRT
18235 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18236 + mov %eax, %esi
18237 +#else
18238 + mov %cr0, %esi
18239 +#endif
18240 + btr $16, %esi
18241 + ljmp $__KERNEL_CS, $1f
18242 +1:
18243 +#ifdef CONFIG_PARAVIRT
18244 + mov %esi, %eax
18245 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18246 +#else
18247 + mov %esi, %cr0
18248 +#endif
18249 +2:
18250 +#ifdef CONFIG_PARAVIRT
18251 + popl %ecx
18252 + popl %eax
18253 +#endif
18254 + ret
18255 +ENDPROC(pax_exit_kernel)
18256 +#endif
18257 +
18258 +.macro pax_erase_kstack
18259 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18260 + call pax_erase_kstack
18261 +#endif
18262 +.endm
18263 +
18264 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18265 +/*
18266 + * ebp: thread_info
18267 + */
18268 +ENTRY(pax_erase_kstack)
18269 + pushl %edi
18270 + pushl %ecx
18271 + pushl %eax
18272 +
18273 + mov TI_lowest_stack(%ebp), %edi
18274 + mov $-0xBEEF, %eax
18275 + std
18276 +
18277 +1: mov %edi, %ecx
18278 + and $THREAD_SIZE_asm - 1, %ecx
18279 + shr $2, %ecx
18280 + repne scasl
18281 + jecxz 2f
18282 +
18283 + cmp $2*16, %ecx
18284 + jc 2f
18285 +
18286 + mov $2*16, %ecx
18287 + repe scasl
18288 + jecxz 2f
18289 + jne 1b
18290 +
18291 +2: cld
18292 + mov %esp, %ecx
18293 + sub %edi, %ecx
18294 +
18295 + cmp $THREAD_SIZE_asm, %ecx
18296 + jb 3f
18297 + ud2
18298 +3:
18299 +
18300 + shr $2, %ecx
18301 + rep stosl
18302 +
18303 + mov TI_task_thread_sp0(%ebp), %edi
18304 + sub $128, %edi
18305 + mov %edi, TI_lowest_stack(%ebp)
18306 +
18307 + popl %eax
18308 + popl %ecx
18309 + popl %edi
18310 + ret
18311 +ENDPROC(pax_erase_kstack)
18312 +#endif
18313 +
18314 +.macro __SAVE_ALL _DS
18315 cld
18316 PUSH_GS
18317 pushl_cfi %fs
18318 @@ -206,7 +346,7 @@
18319 CFI_REL_OFFSET ecx, 0
18320 pushl_cfi %ebx
18321 CFI_REL_OFFSET ebx, 0
18322 - movl $(__USER_DS), %edx
18323 + movl $\_DS, %edx
18324 movl %edx, %ds
18325 movl %edx, %es
18326 movl $(__KERNEL_PERCPU), %edx
18327 @@ -214,6 +354,15 @@
18328 SET_KERNEL_GS %edx
18329 .endm
18330
18331 +.macro SAVE_ALL
18332 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18333 + __SAVE_ALL __KERNEL_DS
18334 + pax_enter_kernel
18335 +#else
18336 + __SAVE_ALL __USER_DS
18337 +#endif
18338 +.endm
18339 +
18340 .macro RESTORE_INT_REGS
18341 popl_cfi %ebx
18342 CFI_RESTORE ebx
18343 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18344 popfl_cfi
18345 jmp syscall_exit
18346 CFI_ENDPROC
18347 -END(ret_from_fork)
18348 +ENDPROC(ret_from_fork)
18349
18350 ENTRY(ret_from_kernel_thread)
18351 CFI_STARTPROC
18352 @@ -344,7 +493,15 @@ ret_from_intr:
18353 andl $SEGMENT_RPL_MASK, %eax
18354 #endif
18355 cmpl $USER_RPL, %eax
18356 +
18357 +#ifdef CONFIG_PAX_KERNEXEC
18358 + jae resume_userspace
18359 +
18360 + pax_exit_kernel
18361 + jmp resume_kernel
18362 +#else
18363 jb resume_kernel # not returning to v8086 or userspace
18364 +#endif
18365
18366 ENTRY(resume_userspace)
18367 LOCKDEP_SYS_EXIT
18368 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18369 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18370 # int/exception return?
18371 jne work_pending
18372 - jmp restore_all
18373 -END(ret_from_exception)
18374 + jmp restore_all_pax
18375 +ENDPROC(ret_from_exception)
18376
18377 #ifdef CONFIG_PREEMPT
18378 ENTRY(resume_kernel)
18379 @@ -372,7 +529,7 @@ need_resched:
18380 jz restore_all
18381 call preempt_schedule_irq
18382 jmp need_resched
18383 -END(resume_kernel)
18384 +ENDPROC(resume_kernel)
18385 #endif
18386 CFI_ENDPROC
18387 /*
18388 @@ -406,30 +563,45 @@ sysenter_past_esp:
18389 /*CFI_REL_OFFSET cs, 0*/
18390 /*
18391 * Push current_thread_info()->sysenter_return to the stack.
18392 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18393 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18394 */
18395 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18396 + pushl_cfi $0
18397 CFI_REL_OFFSET eip, 0
18398
18399 pushl_cfi %eax
18400 SAVE_ALL
18401 + GET_THREAD_INFO(%ebp)
18402 + movl TI_sysenter_return(%ebp),%ebp
18403 + movl %ebp,PT_EIP(%esp)
18404 ENABLE_INTERRUPTS(CLBR_NONE)
18405
18406 /*
18407 * Load the potential sixth argument from user stack.
18408 * Careful about security.
18409 */
18410 + movl PT_OLDESP(%esp),%ebp
18411 +
18412 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18413 + mov PT_OLDSS(%esp),%ds
18414 +1: movl %ds:(%ebp),%ebp
18415 + push %ss
18416 + pop %ds
18417 +#else
18418 cmpl $__PAGE_OFFSET-3,%ebp
18419 jae syscall_fault
18420 ASM_STAC
18421 1: movl (%ebp),%ebp
18422 ASM_CLAC
18423 +#endif
18424 +
18425 movl %ebp,PT_EBP(%esp)
18426 _ASM_EXTABLE(1b,syscall_fault)
18427
18428 GET_THREAD_INFO(%ebp)
18429
18430 +#ifdef CONFIG_PAX_RANDKSTACK
18431 + pax_erase_kstack
18432 +#endif
18433 +
18434 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18435 jnz sysenter_audit
18436 sysenter_do_call:
18437 @@ -444,12 +616,24 @@ sysenter_do_call:
18438 testl $_TIF_ALLWORK_MASK, %ecx
18439 jne sysexit_audit
18440 sysenter_exit:
18441 +
18442 +#ifdef CONFIG_PAX_RANDKSTACK
18443 + pushl_cfi %eax
18444 + movl %esp, %eax
18445 + call pax_randomize_kstack
18446 + popl_cfi %eax
18447 +#endif
18448 +
18449 + pax_erase_kstack
18450 +
18451 /* if something modifies registers it must also disable sysexit */
18452 movl PT_EIP(%esp), %edx
18453 movl PT_OLDESP(%esp), %ecx
18454 xorl %ebp,%ebp
18455 TRACE_IRQS_ON
18456 1: mov PT_FS(%esp), %fs
18457 +2: mov PT_DS(%esp), %ds
18458 +3: mov PT_ES(%esp), %es
18459 PTGS_TO_GS
18460 ENABLE_INTERRUPTS_SYSEXIT
18461
18462 @@ -466,6 +650,9 @@ sysenter_audit:
18463 movl %eax,%edx /* 2nd arg: syscall number */
18464 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18465 call __audit_syscall_entry
18466 +
18467 + pax_erase_kstack
18468 +
18469 pushl_cfi %ebx
18470 movl PT_EAX(%esp),%eax /* reload syscall number */
18471 jmp sysenter_do_call
18472 @@ -491,10 +678,16 @@ sysexit_audit:
18473
18474 CFI_ENDPROC
18475 .pushsection .fixup,"ax"
18476 -2: movl $0,PT_FS(%esp)
18477 +4: movl $0,PT_FS(%esp)
18478 + jmp 1b
18479 +5: movl $0,PT_DS(%esp)
18480 + jmp 1b
18481 +6: movl $0,PT_ES(%esp)
18482 jmp 1b
18483 .popsection
18484 - _ASM_EXTABLE(1b,2b)
18485 + _ASM_EXTABLE(1b,4b)
18486 + _ASM_EXTABLE(2b,5b)
18487 + _ASM_EXTABLE(3b,6b)
18488 PTGS_TO_GS_EX
18489 ENDPROC(ia32_sysenter_target)
18490
18491 @@ -509,6 +702,11 @@ ENTRY(system_call)
18492 pushl_cfi %eax # save orig_eax
18493 SAVE_ALL
18494 GET_THREAD_INFO(%ebp)
18495 +
18496 +#ifdef CONFIG_PAX_RANDKSTACK
18497 + pax_erase_kstack
18498 +#endif
18499 +
18500 # system call tracing in operation / emulation
18501 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18502 jnz syscall_trace_entry
18503 @@ -527,6 +725,15 @@ syscall_exit:
18504 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18505 jne syscall_exit_work
18506
18507 +restore_all_pax:
18508 +
18509 +#ifdef CONFIG_PAX_RANDKSTACK
18510 + movl %esp, %eax
18511 + call pax_randomize_kstack
18512 +#endif
18513 +
18514 + pax_erase_kstack
18515 +
18516 restore_all:
18517 TRACE_IRQS_IRET
18518 restore_all_notrace:
18519 @@ -583,14 +790,34 @@ ldt_ss:
18520 * compensating for the offset by changing to the ESPFIX segment with
18521 * a base address that matches for the difference.
18522 */
18523 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18524 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18525 mov %esp, %edx /* load kernel esp */
18526 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18527 mov %dx, %ax /* eax: new kernel esp */
18528 sub %eax, %edx /* offset (low word is 0) */
18529 +#ifdef CONFIG_SMP
18530 + movl PER_CPU_VAR(cpu_number), %ebx
18531 + shll $PAGE_SHIFT_asm, %ebx
18532 + addl $cpu_gdt_table, %ebx
18533 +#else
18534 + movl $cpu_gdt_table, %ebx
18535 +#endif
18536 shr $16, %edx
18537 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18538 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18539 +
18540 +#ifdef CONFIG_PAX_KERNEXEC
18541 + mov %cr0, %esi
18542 + btr $16, %esi
18543 + mov %esi, %cr0
18544 +#endif
18545 +
18546 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18547 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18548 +
18549 +#ifdef CONFIG_PAX_KERNEXEC
18550 + bts $16, %esi
18551 + mov %esi, %cr0
18552 +#endif
18553 +
18554 pushl_cfi $__ESPFIX_SS
18555 pushl_cfi %eax /* new kernel esp */
18556 /* Disable interrupts, but do not irqtrace this section: we
18557 @@ -619,20 +846,18 @@ work_resched:
18558 movl TI_flags(%ebp), %ecx
18559 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18560 # than syscall tracing?
18561 - jz restore_all
18562 + jz restore_all_pax
18563 testb $_TIF_NEED_RESCHED, %cl
18564 jnz work_resched
18565
18566 work_notifysig: # deal with pending signals and
18567 # notify-resume requests
18568 + movl %esp, %eax
18569 #ifdef CONFIG_VM86
18570 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18571 - movl %esp, %eax
18572 jne work_notifysig_v86 # returning to kernel-space or
18573 # vm86-space
18574 1:
18575 -#else
18576 - movl %esp, %eax
18577 #endif
18578 TRACE_IRQS_ON
18579 ENABLE_INTERRUPTS(CLBR_NONE)
18580 @@ -653,7 +878,7 @@ work_notifysig_v86:
18581 movl %eax, %esp
18582 jmp 1b
18583 #endif
18584 -END(work_pending)
18585 +ENDPROC(work_pending)
18586
18587 # perform syscall exit tracing
18588 ALIGN
18589 @@ -661,11 +886,14 @@ syscall_trace_entry:
18590 movl $-ENOSYS,PT_EAX(%esp)
18591 movl %esp, %eax
18592 call syscall_trace_enter
18593 +
18594 + pax_erase_kstack
18595 +
18596 /* What it returned is what we'll actually use. */
18597 cmpl $(NR_syscalls), %eax
18598 jnae syscall_call
18599 jmp syscall_exit
18600 -END(syscall_trace_entry)
18601 +ENDPROC(syscall_trace_entry)
18602
18603 # perform syscall exit tracing
18604 ALIGN
18605 @@ -678,21 +906,25 @@ syscall_exit_work:
18606 movl %esp, %eax
18607 call syscall_trace_leave
18608 jmp resume_userspace
18609 -END(syscall_exit_work)
18610 +ENDPROC(syscall_exit_work)
18611 CFI_ENDPROC
18612
18613 RING0_INT_FRAME # can't unwind into user space anyway
18614 syscall_fault:
18615 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18616 + push %ss
18617 + pop %ds
18618 +#endif
18619 ASM_CLAC
18620 GET_THREAD_INFO(%ebp)
18621 movl $-EFAULT,PT_EAX(%esp)
18622 jmp resume_userspace
18623 -END(syscall_fault)
18624 +ENDPROC(syscall_fault)
18625
18626 syscall_badsys:
18627 movl $-ENOSYS,PT_EAX(%esp)
18628 jmp resume_userspace
18629 -END(syscall_badsys)
18630 +ENDPROC(syscall_badsys)
18631 CFI_ENDPROC
18632 /*
18633 * End of kprobes section
18634 @@ -708,8 +940,15 @@ END(syscall_badsys)
18635 * normal stack and adjusts ESP with the matching offset.
18636 */
18637 /* fixup the stack */
18638 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18639 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18640 +#ifdef CONFIG_SMP
18641 + movl PER_CPU_VAR(cpu_number), %ebx
18642 + shll $PAGE_SHIFT_asm, %ebx
18643 + addl $cpu_gdt_table, %ebx
18644 +#else
18645 + movl $cpu_gdt_table, %ebx
18646 +#endif
18647 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18648 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18649 shl $16, %eax
18650 addl %esp, %eax /* the adjusted stack pointer */
18651 pushl_cfi $__KERNEL_DS
18652 @@ -762,7 +1001,7 @@ vector=vector+1
18653 .endr
18654 2: jmp common_interrupt
18655 .endr
18656 -END(irq_entries_start)
18657 +ENDPROC(irq_entries_start)
18658
18659 .previous
18660 END(interrupt)
18661 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18662 pushl_cfi $do_coprocessor_error
18663 jmp error_code
18664 CFI_ENDPROC
18665 -END(coprocessor_error)
18666 +ENDPROC(coprocessor_error)
18667
18668 ENTRY(simd_coprocessor_error)
18669 RING0_INT_FRAME
18670 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18671 #endif
18672 jmp error_code
18673 CFI_ENDPROC
18674 -END(simd_coprocessor_error)
18675 +ENDPROC(simd_coprocessor_error)
18676
18677 ENTRY(device_not_available)
18678 RING0_INT_FRAME
18679 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18680 pushl_cfi $do_device_not_available
18681 jmp error_code
18682 CFI_ENDPROC
18683 -END(device_not_available)
18684 +ENDPROC(device_not_available)
18685
18686 #ifdef CONFIG_PARAVIRT
18687 ENTRY(native_iret)
18688 iret
18689 _ASM_EXTABLE(native_iret, iret_exc)
18690 -END(native_iret)
18691 +ENDPROC(native_iret)
18692
18693 ENTRY(native_irq_enable_sysexit)
18694 sti
18695 sysexit
18696 -END(native_irq_enable_sysexit)
18697 +ENDPROC(native_irq_enable_sysexit)
18698 #endif
18699
18700 ENTRY(overflow)
18701 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18702 pushl_cfi $do_overflow
18703 jmp error_code
18704 CFI_ENDPROC
18705 -END(overflow)
18706 +ENDPROC(overflow)
18707
18708 ENTRY(bounds)
18709 RING0_INT_FRAME
18710 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18711 pushl_cfi $do_bounds
18712 jmp error_code
18713 CFI_ENDPROC
18714 -END(bounds)
18715 +ENDPROC(bounds)
18716
18717 ENTRY(invalid_op)
18718 RING0_INT_FRAME
18719 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18720 pushl_cfi $do_invalid_op
18721 jmp error_code
18722 CFI_ENDPROC
18723 -END(invalid_op)
18724 +ENDPROC(invalid_op)
18725
18726 ENTRY(coprocessor_segment_overrun)
18727 RING0_INT_FRAME
18728 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18729 pushl_cfi $do_coprocessor_segment_overrun
18730 jmp error_code
18731 CFI_ENDPROC
18732 -END(coprocessor_segment_overrun)
18733 +ENDPROC(coprocessor_segment_overrun)
18734
18735 ENTRY(invalid_TSS)
18736 RING0_EC_FRAME
18737 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18738 pushl_cfi $do_invalid_TSS
18739 jmp error_code
18740 CFI_ENDPROC
18741 -END(invalid_TSS)
18742 +ENDPROC(invalid_TSS)
18743
18744 ENTRY(segment_not_present)
18745 RING0_EC_FRAME
18746 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18747 pushl_cfi $do_segment_not_present
18748 jmp error_code
18749 CFI_ENDPROC
18750 -END(segment_not_present)
18751 +ENDPROC(segment_not_present)
18752
18753 ENTRY(stack_segment)
18754 RING0_EC_FRAME
18755 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18756 pushl_cfi $do_stack_segment
18757 jmp error_code
18758 CFI_ENDPROC
18759 -END(stack_segment)
18760 +ENDPROC(stack_segment)
18761
18762 ENTRY(alignment_check)
18763 RING0_EC_FRAME
18764 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18765 pushl_cfi $do_alignment_check
18766 jmp error_code
18767 CFI_ENDPROC
18768 -END(alignment_check)
18769 +ENDPROC(alignment_check)
18770
18771 ENTRY(divide_error)
18772 RING0_INT_FRAME
18773 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18774 pushl_cfi $do_divide_error
18775 jmp error_code
18776 CFI_ENDPROC
18777 -END(divide_error)
18778 +ENDPROC(divide_error)
18779
18780 #ifdef CONFIG_X86_MCE
18781 ENTRY(machine_check)
18782 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18783 pushl_cfi machine_check_vector
18784 jmp error_code
18785 CFI_ENDPROC
18786 -END(machine_check)
18787 +ENDPROC(machine_check)
18788 #endif
18789
18790 ENTRY(spurious_interrupt_bug)
18791 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18792 pushl_cfi $do_spurious_interrupt_bug
18793 jmp error_code
18794 CFI_ENDPROC
18795 -END(spurious_interrupt_bug)
18796 +ENDPROC(spurious_interrupt_bug)
18797 /*
18798 * End of kprobes section
18799 */
18800 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18801
18802 ENTRY(mcount)
18803 ret
18804 -END(mcount)
18805 +ENDPROC(mcount)
18806
18807 ENTRY(ftrace_caller)
18808 cmpl $0, function_trace_stop
18809 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18810 .globl ftrace_stub
18811 ftrace_stub:
18812 ret
18813 -END(ftrace_caller)
18814 +ENDPROC(ftrace_caller)
18815
18816 ENTRY(ftrace_regs_caller)
18817 pushf /* push flags before compare (in cs location) */
18818 @@ -1197,7 +1436,7 @@ trace:
18819 popl %ecx
18820 popl %eax
18821 jmp ftrace_stub
18822 -END(mcount)
18823 +ENDPROC(mcount)
18824 #endif /* CONFIG_DYNAMIC_FTRACE */
18825 #endif /* CONFIG_FUNCTION_TRACER */
18826
18827 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18828 popl %ecx
18829 popl %eax
18830 ret
18831 -END(ftrace_graph_caller)
18832 +ENDPROC(ftrace_graph_caller)
18833
18834 .globl return_to_handler
18835 return_to_handler:
18836 @@ -1271,15 +1510,18 @@ error_code:
18837 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18838 REG_TO_PTGS %ecx
18839 SET_KERNEL_GS %ecx
18840 - movl $(__USER_DS), %ecx
18841 + movl $(__KERNEL_DS), %ecx
18842 movl %ecx, %ds
18843 movl %ecx, %es
18844 +
18845 + pax_enter_kernel
18846 +
18847 TRACE_IRQS_OFF
18848 movl %esp,%eax # pt_regs pointer
18849 call *%edi
18850 jmp ret_from_exception
18851 CFI_ENDPROC
18852 -END(page_fault)
18853 +ENDPROC(page_fault)
18854
18855 /*
18856 * Debug traps and NMI can happen at the one SYSENTER instruction
18857 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18858 call do_debug
18859 jmp ret_from_exception
18860 CFI_ENDPROC
18861 -END(debug)
18862 +ENDPROC(debug)
18863
18864 /*
18865 * NMI is doubly nasty. It can happen _while_ we're handling
18866 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18867 xorl %edx,%edx # zero error code
18868 movl %esp,%eax # pt_regs pointer
18869 call do_nmi
18870 +
18871 + pax_exit_kernel
18872 +
18873 jmp restore_all_notrace
18874 CFI_ENDPROC
18875
18876 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18877 FIXUP_ESPFIX_STACK # %eax == %esp
18878 xorl %edx,%edx # zero error code
18879 call do_nmi
18880 +
18881 + pax_exit_kernel
18882 +
18883 RESTORE_REGS
18884 lss 12+4(%esp), %esp # back to espfix stack
18885 CFI_ADJUST_CFA_OFFSET -24
18886 jmp irq_return
18887 CFI_ENDPROC
18888 -END(nmi)
18889 +ENDPROC(nmi)
18890
18891 ENTRY(int3)
18892 RING0_INT_FRAME
18893 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18894 call do_int3
18895 jmp ret_from_exception
18896 CFI_ENDPROC
18897 -END(int3)
18898 +ENDPROC(int3)
18899
18900 ENTRY(general_protection)
18901 RING0_EC_FRAME
18902 pushl_cfi $do_general_protection
18903 jmp error_code
18904 CFI_ENDPROC
18905 -END(general_protection)
18906 +ENDPROC(general_protection)
18907
18908 #ifdef CONFIG_KVM_GUEST
18909 ENTRY(async_page_fault)
18910 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
18911 pushl_cfi $do_async_page_fault
18912 jmp error_code
18913 CFI_ENDPROC
18914 -END(async_page_fault)
18915 +ENDPROC(async_page_fault)
18916 #endif
18917
18918 /*
18919 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18920 index c1d01e6..5625dce 100644
18921 --- a/arch/x86/kernel/entry_64.S
18922 +++ b/arch/x86/kernel/entry_64.S
18923 @@ -59,6 +59,8 @@
18924 #include <asm/context_tracking.h>
18925 #include <asm/smap.h>
18926 #include <linux/err.h>
18927 +#include <asm/pgtable.h>
18928 +#include <asm/alternative-asm.h>
18929
18930 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
18931 #include <linux/elf-em.h>
18932 @@ -80,8 +82,9 @@
18933 #ifdef CONFIG_DYNAMIC_FTRACE
18934
18935 ENTRY(function_hook)
18936 + pax_force_retaddr
18937 retq
18938 -END(function_hook)
18939 +ENDPROC(function_hook)
18940
18941 /* skip is set if stack has been adjusted */
18942 .macro ftrace_caller_setup skip=0
18943 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
18944 #endif
18945
18946 GLOBAL(ftrace_stub)
18947 + pax_force_retaddr
18948 retq
18949 -END(ftrace_caller)
18950 +ENDPROC(ftrace_caller)
18951
18952 ENTRY(ftrace_regs_caller)
18953 /* Save the current flags before compare (in SS location)*/
18954 @@ -191,7 +195,7 @@ ftrace_restore_flags:
18955 popfq
18956 jmp ftrace_stub
18957
18958 -END(ftrace_regs_caller)
18959 +ENDPROC(ftrace_regs_caller)
18960
18961
18962 #else /* ! CONFIG_DYNAMIC_FTRACE */
18963 @@ -212,6 +216,7 @@ ENTRY(function_hook)
18964 #endif
18965
18966 GLOBAL(ftrace_stub)
18967 + pax_force_retaddr
18968 retq
18969
18970 trace:
18971 @@ -225,12 +230,13 @@ trace:
18972 #endif
18973 subq $MCOUNT_INSN_SIZE, %rdi
18974
18975 + pax_force_fptr ftrace_trace_function
18976 call *ftrace_trace_function
18977
18978 MCOUNT_RESTORE_FRAME
18979
18980 jmp ftrace_stub
18981 -END(function_hook)
18982 +ENDPROC(function_hook)
18983 #endif /* CONFIG_DYNAMIC_FTRACE */
18984 #endif /* CONFIG_FUNCTION_TRACER */
18985
18986 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
18987
18988 MCOUNT_RESTORE_FRAME
18989
18990 + pax_force_retaddr
18991 retq
18992 -END(ftrace_graph_caller)
18993 +ENDPROC(ftrace_graph_caller)
18994
18995 GLOBAL(return_to_handler)
18996 subq $24, %rsp
18997 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
18998 movq 8(%rsp), %rdx
18999 movq (%rsp), %rax
19000 addq $24, %rsp
19001 + pax_force_fptr %rdi
19002 jmp *%rdi
19003 +ENDPROC(return_to_handler)
19004 #endif
19005
19006
19007 @@ -284,6 +293,282 @@ ENTRY(native_usergs_sysret64)
19008 ENDPROC(native_usergs_sysret64)
19009 #endif /* CONFIG_PARAVIRT */
19010
19011 + .macro ljmpq sel, off
19012 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19013 + .byte 0x48; ljmp *1234f(%rip)
19014 + .pushsection .rodata
19015 + .align 16
19016 + 1234: .quad \off; .word \sel
19017 + .popsection
19018 +#else
19019 + pushq $\sel
19020 + pushq $\off
19021 + lretq
19022 +#endif
19023 + .endm
19024 +
19025 + .macro pax_enter_kernel
19026 + pax_set_fptr_mask
19027 +#ifdef CONFIG_PAX_KERNEXEC
19028 + call pax_enter_kernel
19029 +#endif
19030 + .endm
19031 +
19032 + .macro pax_exit_kernel
19033 +#ifdef CONFIG_PAX_KERNEXEC
19034 + call pax_exit_kernel
19035 +#endif
19036 + .endm
19037 +
19038 +#ifdef CONFIG_PAX_KERNEXEC
19039 +ENTRY(pax_enter_kernel)
19040 + pushq %rdi
19041 +
19042 +#ifdef CONFIG_PARAVIRT
19043 + PV_SAVE_REGS(CLBR_RDI)
19044 +#endif
19045 +
19046 + GET_CR0_INTO_RDI
19047 + bts $16,%rdi
19048 + jnc 3f
19049 + mov %cs,%edi
19050 + cmp $__KERNEL_CS,%edi
19051 + jnz 2f
19052 +1:
19053 +
19054 +#ifdef CONFIG_PARAVIRT
19055 + PV_RESTORE_REGS(CLBR_RDI)
19056 +#endif
19057 +
19058 + popq %rdi
19059 + pax_force_retaddr
19060 + retq
19061 +
19062 +2: ljmpq __KERNEL_CS,1b
19063 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19064 +4: SET_RDI_INTO_CR0
19065 + jmp 1b
19066 +ENDPROC(pax_enter_kernel)
19067 +
19068 +ENTRY(pax_exit_kernel)
19069 + pushq %rdi
19070 +
19071 +#ifdef CONFIG_PARAVIRT
19072 + PV_SAVE_REGS(CLBR_RDI)
19073 +#endif
19074 +
19075 + mov %cs,%rdi
19076 + cmp $__KERNEXEC_KERNEL_CS,%edi
19077 + jz 2f
19078 + GET_CR0_INTO_RDI
19079 + bts $16,%rdi
19080 + jnc 4f
19081 +1:
19082 +
19083 +#ifdef CONFIG_PARAVIRT
19084 + PV_RESTORE_REGS(CLBR_RDI);
19085 +#endif
19086 +
19087 + popq %rdi
19088 + pax_force_retaddr
19089 + retq
19090 +
19091 +2: GET_CR0_INTO_RDI
19092 + btr $16,%rdi
19093 + jnc 4f
19094 + ljmpq __KERNEL_CS,3f
19095 +3: SET_RDI_INTO_CR0
19096 + jmp 1b
19097 +4: ud2
19098 + jmp 4b
19099 +ENDPROC(pax_exit_kernel)
19100 +#endif
19101 +
19102 + .macro pax_enter_kernel_user
19103 + pax_set_fptr_mask
19104 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19105 + call pax_enter_kernel_user
19106 +#endif
19107 + .endm
19108 +
19109 + .macro pax_exit_kernel_user
19110 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19111 + call pax_exit_kernel_user
19112 +#endif
19113 +#ifdef CONFIG_PAX_RANDKSTACK
19114 + pushq %rax
19115 + call pax_randomize_kstack
19116 + popq %rax
19117 +#endif
19118 + .endm
19119 +
19120 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19121 +ENTRY(pax_enter_kernel_user)
19122 + pushq %rdi
19123 + pushq %rbx
19124 +
19125 +#ifdef CONFIG_PARAVIRT
19126 + PV_SAVE_REGS(CLBR_RDI)
19127 +#endif
19128 +
19129 + GET_CR3_INTO_RDI
19130 + mov %rdi,%rbx
19131 + add $__START_KERNEL_map,%rbx
19132 + sub phys_base(%rip),%rbx
19133 +
19134 +#ifdef CONFIG_PARAVIRT
19135 + pushq %rdi
19136 + cmpl $0, pv_info+PARAVIRT_enabled
19137 + jz 1f
19138 + i = 0
19139 + .rept USER_PGD_PTRS
19140 + mov i*8(%rbx),%rsi
19141 + mov $0,%sil
19142 + lea i*8(%rbx),%rdi
19143 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19144 + i = i + 1
19145 + .endr
19146 + jmp 2f
19147 +1:
19148 +#endif
19149 +
19150 + i = 0
19151 + .rept USER_PGD_PTRS
19152 + movb $0,i*8(%rbx)
19153 + i = i + 1
19154 + .endr
19155 +
19156 +#ifdef CONFIG_PARAVIRT
19157 +2: popq %rdi
19158 +#endif
19159 + SET_RDI_INTO_CR3
19160 +
19161 +#ifdef CONFIG_PAX_KERNEXEC
19162 + GET_CR0_INTO_RDI
19163 + bts $16,%rdi
19164 + SET_RDI_INTO_CR0
19165 +#endif
19166 +
19167 +#ifdef CONFIG_PARAVIRT
19168 + PV_RESTORE_REGS(CLBR_RDI)
19169 +#endif
19170 +
19171 + popq %rbx
19172 + popq %rdi
19173 + pax_force_retaddr
19174 + retq
19175 +ENDPROC(pax_enter_kernel_user)
19176 +
19177 +ENTRY(pax_exit_kernel_user)
19178 + push %rdi
19179 +
19180 +#ifdef CONFIG_PARAVIRT
19181 + pushq %rbx
19182 + PV_SAVE_REGS(CLBR_RDI)
19183 +#endif
19184 +
19185 +#ifdef CONFIG_PAX_KERNEXEC
19186 + GET_CR0_INTO_RDI
19187 + btr $16,%rdi
19188 + jnc 3f
19189 + SET_RDI_INTO_CR0
19190 +#endif
19191 +
19192 + GET_CR3_INTO_RDI
19193 + add $__START_KERNEL_map,%rdi
19194 + sub phys_base(%rip),%rdi
19195 +
19196 +#ifdef CONFIG_PARAVIRT
19197 + cmpl $0, pv_info+PARAVIRT_enabled
19198 + jz 1f
19199 + mov %rdi,%rbx
19200 + i = 0
19201 + .rept USER_PGD_PTRS
19202 + mov i*8(%rbx),%rsi
19203 + mov $0x67,%sil
19204 + lea i*8(%rbx),%rdi
19205 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19206 + i = i + 1
19207 + .endr
19208 + jmp 2f
19209 +1:
19210 +#endif
19211 +
19212 + i = 0
19213 + .rept USER_PGD_PTRS
19214 + movb $0x67,i*8(%rdi)
19215 + i = i + 1
19216 + .endr
19217 +
19218 +#ifdef CONFIG_PARAVIRT
19219 +2: PV_RESTORE_REGS(CLBR_RDI)
19220 + popq %rbx
19221 +#endif
19222 +
19223 + popq %rdi
19224 + pax_force_retaddr
19225 + retq
19226 +3: ud2
19227 + jmp 3b
19228 +ENDPROC(pax_exit_kernel_user)
19229 +#endif
19230 +
19231 +.macro pax_erase_kstack
19232 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19233 + call pax_erase_kstack
19234 +#endif
19235 +.endm
19236 +
19237 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19238 +ENTRY(pax_erase_kstack)
19239 + pushq %rdi
19240 + pushq %rcx
19241 + pushq %rax
19242 + pushq %r11
19243 +
19244 + GET_THREAD_INFO(%r11)
19245 + mov TI_lowest_stack(%r11), %rdi
19246 + mov $-0xBEEF, %rax
19247 + std
19248 +
19249 +1: mov %edi, %ecx
19250 + and $THREAD_SIZE_asm - 1, %ecx
19251 + shr $3, %ecx
19252 + repne scasq
19253 + jecxz 2f
19254 +
19255 + cmp $2*8, %ecx
19256 + jc 2f
19257 +
19258 + mov $2*8, %ecx
19259 + repe scasq
19260 + jecxz 2f
19261 + jne 1b
19262 +
19263 +2: cld
19264 + mov %esp, %ecx
19265 + sub %edi, %ecx
19266 +
19267 + cmp $THREAD_SIZE_asm, %rcx
19268 + jb 3f
19269 + ud2
19270 +3:
19271 +
19272 + shr $3, %ecx
19273 + rep stosq
19274 +
19275 + mov TI_task_thread_sp0(%r11), %rdi
19276 + sub $256, %rdi
19277 + mov %rdi, TI_lowest_stack(%r11)
19278 +
19279 + popq %r11
19280 + popq %rax
19281 + popq %rcx
19282 + popq %rdi
19283 + pax_force_retaddr
19284 + ret
19285 +ENDPROC(pax_erase_kstack)
19286 +#endif
19287
19288 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19289 #ifdef CONFIG_TRACE_IRQFLAGS
19290 @@ -375,8 +660,8 @@ ENDPROC(native_usergs_sysret64)
19291 .endm
19292
19293 .macro UNFAKE_STACK_FRAME
19294 - addq $8*6, %rsp
19295 - CFI_ADJUST_CFA_OFFSET -(6*8)
19296 + addq $8*6 + ARG_SKIP, %rsp
19297 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19298 .endm
19299
19300 /*
19301 @@ -463,7 +748,7 @@ ENDPROC(native_usergs_sysret64)
19302 movq %rsp, %rsi
19303
19304 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19305 - testl $3, CS-RBP(%rsi)
19306 + testb $3, CS-RBP(%rsi)
19307 je 1f
19308 SWAPGS
19309 /*
19310 @@ -498,9 +783,10 @@ ENTRY(save_rest)
19311 movq_cfi r15, R15+16
19312 movq %r11, 8(%rsp) /* return address */
19313 FIXUP_TOP_OF_STACK %r11, 16
19314 + pax_force_retaddr
19315 ret
19316 CFI_ENDPROC
19317 -END(save_rest)
19318 +ENDPROC(save_rest)
19319
19320 /* save complete stack frame */
19321 .pushsection .kprobes.text, "ax"
19322 @@ -529,9 +815,10 @@ ENTRY(save_paranoid)
19323 js 1f /* negative -> in kernel */
19324 SWAPGS
19325 xorl %ebx,%ebx
19326 -1: ret
19327 +1: pax_force_retaddr_bts
19328 + ret
19329 CFI_ENDPROC
19330 -END(save_paranoid)
19331 +ENDPROC(save_paranoid)
19332 .popsection
19333
19334 /*
19335 @@ -553,7 +840,7 @@ ENTRY(ret_from_fork)
19336
19337 RESTORE_REST
19338
19339 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19340 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19341 jz 1f
19342
19343 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19344 @@ -571,7 +858,7 @@ ENTRY(ret_from_fork)
19345 RESTORE_REST
19346 jmp int_ret_from_sys_call
19347 CFI_ENDPROC
19348 -END(ret_from_fork)
19349 +ENDPROC(ret_from_fork)
19350
19351 /*
19352 * System call entry. Up to 6 arguments in registers are supported.
19353 @@ -608,7 +895,7 @@ END(ret_from_fork)
19354 ENTRY(system_call)
19355 CFI_STARTPROC simple
19356 CFI_SIGNAL_FRAME
19357 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19358 + CFI_DEF_CFA rsp,0
19359 CFI_REGISTER rip,rcx
19360 /*CFI_REGISTER rflags,r11*/
19361 SWAPGS_UNSAFE_STACK
19362 @@ -621,16 +908,23 @@ GLOBAL(system_call_after_swapgs)
19363
19364 movq %rsp,PER_CPU_VAR(old_rsp)
19365 movq PER_CPU_VAR(kernel_stack),%rsp
19366 + SAVE_ARGS 8*6,0
19367 + pax_enter_kernel_user
19368 +
19369 +#ifdef CONFIG_PAX_RANDKSTACK
19370 + pax_erase_kstack
19371 +#endif
19372 +
19373 /*
19374 * No need to follow this irqs off/on section - it's straight
19375 * and short:
19376 */
19377 ENABLE_INTERRUPTS(CLBR_NONE)
19378 - SAVE_ARGS 8,0
19379 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19380 movq %rcx,RIP-ARGOFFSET(%rsp)
19381 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19382 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19383 + GET_THREAD_INFO(%rcx)
19384 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19385 jnz tracesys
19386 system_call_fastpath:
19387 #if __SYSCALL_MASK == ~0
19388 @@ -640,7 +934,7 @@ system_call_fastpath:
19389 cmpl $__NR_syscall_max,%eax
19390 #endif
19391 ja badsys
19392 - movq %r10,%rcx
19393 + movq R10-ARGOFFSET(%rsp),%rcx
19394 call *sys_call_table(,%rax,8) # XXX: rip relative
19395 movq %rax,RAX-ARGOFFSET(%rsp)
19396 /*
19397 @@ -654,10 +948,13 @@ sysret_check:
19398 LOCKDEP_SYS_EXIT
19399 DISABLE_INTERRUPTS(CLBR_NONE)
19400 TRACE_IRQS_OFF
19401 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19402 + GET_THREAD_INFO(%rcx)
19403 + movl TI_flags(%rcx),%edx
19404 andl %edi,%edx
19405 jnz sysret_careful
19406 CFI_REMEMBER_STATE
19407 + pax_exit_kernel_user
19408 + pax_erase_kstack
19409 /*
19410 * sysretq will re-enable interrupts:
19411 */
19412 @@ -709,14 +1006,18 @@ badsys:
19413 * jump back to the normal fast path.
19414 */
19415 auditsys:
19416 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19417 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19418 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19419 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19420 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19421 movq %rax,%rsi /* 2nd arg: syscall number */
19422 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19423 call __audit_syscall_entry
19424 +
19425 + pax_erase_kstack
19426 +
19427 LOAD_ARGS 0 /* reload call-clobbered registers */
19428 + pax_set_fptr_mask
19429 jmp system_call_fastpath
19430
19431 /*
19432 @@ -737,7 +1038,7 @@ sysret_audit:
19433 /* Do syscall tracing */
19434 tracesys:
19435 #ifdef CONFIG_AUDITSYSCALL
19436 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19437 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19438 jz auditsys
19439 #endif
19440 SAVE_REST
19441 @@ -745,12 +1046,16 @@ tracesys:
19442 FIXUP_TOP_OF_STACK %rdi
19443 movq %rsp,%rdi
19444 call syscall_trace_enter
19445 +
19446 + pax_erase_kstack
19447 +
19448 /*
19449 * Reload arg registers from stack in case ptrace changed them.
19450 * We don't reload %rax because syscall_trace_enter() returned
19451 * the value it wants us to use in the table lookup.
19452 */
19453 LOAD_ARGS ARGOFFSET, 1
19454 + pax_set_fptr_mask
19455 RESTORE_REST
19456 #if __SYSCALL_MASK == ~0
19457 cmpq $__NR_syscall_max,%rax
19458 @@ -759,7 +1064,7 @@ tracesys:
19459 cmpl $__NR_syscall_max,%eax
19460 #endif
19461 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19462 - movq %r10,%rcx /* fixup for C */
19463 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19464 call *sys_call_table(,%rax,8)
19465 movq %rax,RAX-ARGOFFSET(%rsp)
19466 /* Use IRET because user could have changed frame */
19467 @@ -780,7 +1085,9 @@ GLOBAL(int_with_check)
19468 andl %edi,%edx
19469 jnz int_careful
19470 andl $~TS_COMPAT,TI_status(%rcx)
19471 - jmp retint_swapgs
19472 + pax_exit_kernel_user
19473 + pax_erase_kstack
19474 + jmp retint_swapgs_pax
19475
19476 /* Either reschedule or signal or syscall exit tracking needed. */
19477 /* First do a reschedule test. */
19478 @@ -826,7 +1133,7 @@ int_restore_rest:
19479 TRACE_IRQS_OFF
19480 jmp int_with_check
19481 CFI_ENDPROC
19482 -END(system_call)
19483 +ENDPROC(system_call)
19484
19485 .macro FORK_LIKE func
19486 ENTRY(stub_\func)
19487 @@ -839,9 +1146,10 @@ ENTRY(stub_\func)
19488 DEFAULT_FRAME 0 8 /* offset 8: return address */
19489 call sys_\func
19490 RESTORE_TOP_OF_STACK %r11, 8
19491 + pax_force_retaddr
19492 ret $REST_SKIP /* pop extended registers */
19493 CFI_ENDPROC
19494 -END(stub_\func)
19495 +ENDPROC(stub_\func)
19496 .endm
19497
19498 .macro FIXED_FRAME label,func
19499 @@ -851,9 +1159,10 @@ ENTRY(\label)
19500 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19501 call \func
19502 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19503 + pax_force_retaddr
19504 ret
19505 CFI_ENDPROC
19506 -END(\label)
19507 +ENDPROC(\label)
19508 .endm
19509
19510 FORK_LIKE clone
19511 @@ -870,9 +1179,10 @@ ENTRY(ptregscall_common)
19512 movq_cfi_restore R12+8, r12
19513 movq_cfi_restore RBP+8, rbp
19514 movq_cfi_restore RBX+8, rbx
19515 + pax_force_retaddr
19516 ret $REST_SKIP /* pop extended registers */
19517 CFI_ENDPROC
19518 -END(ptregscall_common)
19519 +ENDPROC(ptregscall_common)
19520
19521 ENTRY(stub_execve)
19522 CFI_STARTPROC
19523 @@ -885,7 +1195,7 @@ ENTRY(stub_execve)
19524 RESTORE_REST
19525 jmp int_ret_from_sys_call
19526 CFI_ENDPROC
19527 -END(stub_execve)
19528 +ENDPROC(stub_execve)
19529
19530 /*
19531 * sigreturn is special because it needs to restore all registers on return.
19532 @@ -902,7 +1212,7 @@ ENTRY(stub_rt_sigreturn)
19533 RESTORE_REST
19534 jmp int_ret_from_sys_call
19535 CFI_ENDPROC
19536 -END(stub_rt_sigreturn)
19537 +ENDPROC(stub_rt_sigreturn)
19538
19539 #ifdef CONFIG_X86_X32_ABI
19540 ENTRY(stub_x32_rt_sigreturn)
19541 @@ -916,7 +1226,7 @@ ENTRY(stub_x32_rt_sigreturn)
19542 RESTORE_REST
19543 jmp int_ret_from_sys_call
19544 CFI_ENDPROC
19545 -END(stub_x32_rt_sigreturn)
19546 +ENDPROC(stub_x32_rt_sigreturn)
19547
19548 ENTRY(stub_x32_execve)
19549 CFI_STARTPROC
19550 @@ -930,7 +1240,7 @@ ENTRY(stub_x32_execve)
19551 RESTORE_REST
19552 jmp int_ret_from_sys_call
19553 CFI_ENDPROC
19554 -END(stub_x32_execve)
19555 +ENDPROC(stub_x32_execve)
19556
19557 #endif
19558
19559 @@ -967,7 +1277,7 @@ vector=vector+1
19560 2: jmp common_interrupt
19561 .endr
19562 CFI_ENDPROC
19563 -END(irq_entries_start)
19564 +ENDPROC(irq_entries_start)
19565
19566 .previous
19567 END(interrupt)
19568 @@ -987,6 +1297,16 @@ END(interrupt)
19569 subq $ORIG_RAX-RBP, %rsp
19570 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19571 SAVE_ARGS_IRQ
19572 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19573 + testb $3, CS(%rdi)
19574 + jnz 1f
19575 + pax_enter_kernel
19576 + jmp 2f
19577 +1: pax_enter_kernel_user
19578 +2:
19579 +#else
19580 + pax_enter_kernel
19581 +#endif
19582 call \func
19583 .endm
19584
19585 @@ -1019,7 +1339,7 @@ ret_from_intr:
19586
19587 exit_intr:
19588 GET_THREAD_INFO(%rcx)
19589 - testl $3,CS-ARGOFFSET(%rsp)
19590 + testb $3,CS-ARGOFFSET(%rsp)
19591 je retint_kernel
19592
19593 /* Interrupt came from user space */
19594 @@ -1041,12 +1361,16 @@ retint_swapgs: /* return to user-space */
19595 * The iretq could re-enable interrupts:
19596 */
19597 DISABLE_INTERRUPTS(CLBR_ANY)
19598 + pax_exit_kernel_user
19599 +retint_swapgs_pax:
19600 TRACE_IRQS_IRETQ
19601 SWAPGS
19602 jmp restore_args
19603
19604 retint_restore_args: /* return to kernel space */
19605 DISABLE_INTERRUPTS(CLBR_ANY)
19606 + pax_exit_kernel
19607 + pax_force_retaddr (RIP-ARGOFFSET)
19608 /*
19609 * The iretq could re-enable interrupts:
19610 */
19611 @@ -1129,7 +1453,7 @@ ENTRY(retint_kernel)
19612 #endif
19613
19614 CFI_ENDPROC
19615 -END(common_interrupt)
19616 +ENDPROC(common_interrupt)
19617 /*
19618 * End of kprobes section
19619 */
19620 @@ -1147,7 +1471,7 @@ ENTRY(\sym)
19621 interrupt \do_sym
19622 jmp ret_from_intr
19623 CFI_ENDPROC
19624 -END(\sym)
19625 +ENDPROC(\sym)
19626 .endm
19627
19628 #ifdef CONFIG_SMP
19629 @@ -1203,12 +1527,22 @@ ENTRY(\sym)
19630 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19631 call error_entry
19632 DEFAULT_FRAME 0
19633 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19634 + testb $3, CS(%rsp)
19635 + jnz 1f
19636 + pax_enter_kernel
19637 + jmp 2f
19638 +1: pax_enter_kernel_user
19639 +2:
19640 +#else
19641 + pax_enter_kernel
19642 +#endif
19643 movq %rsp,%rdi /* pt_regs pointer */
19644 xorl %esi,%esi /* no error code */
19645 call \do_sym
19646 jmp error_exit /* %ebx: no swapgs flag */
19647 CFI_ENDPROC
19648 -END(\sym)
19649 +ENDPROC(\sym)
19650 .endm
19651
19652 .macro paranoidzeroentry sym do_sym
19653 @@ -1221,15 +1555,25 @@ ENTRY(\sym)
19654 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19655 call save_paranoid
19656 TRACE_IRQS_OFF
19657 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19658 + testb $3, CS(%rsp)
19659 + jnz 1f
19660 + pax_enter_kernel
19661 + jmp 2f
19662 +1: pax_enter_kernel_user
19663 +2:
19664 +#else
19665 + pax_enter_kernel
19666 +#endif
19667 movq %rsp,%rdi /* pt_regs pointer */
19668 xorl %esi,%esi /* no error code */
19669 call \do_sym
19670 jmp paranoid_exit /* %ebx: no swapgs flag */
19671 CFI_ENDPROC
19672 -END(\sym)
19673 +ENDPROC(\sym)
19674 .endm
19675
19676 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19677 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19678 .macro paranoidzeroentry_ist sym do_sym ist
19679 ENTRY(\sym)
19680 INTR_FRAME
19681 @@ -1240,14 +1584,30 @@ ENTRY(\sym)
19682 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19683 call save_paranoid
19684 TRACE_IRQS_OFF_DEBUG
19685 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19686 + testb $3, CS(%rsp)
19687 + jnz 1f
19688 + pax_enter_kernel
19689 + jmp 2f
19690 +1: pax_enter_kernel_user
19691 +2:
19692 +#else
19693 + pax_enter_kernel
19694 +#endif
19695 movq %rsp,%rdi /* pt_regs pointer */
19696 xorl %esi,%esi /* no error code */
19697 +#ifdef CONFIG_SMP
19698 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19699 + lea init_tss(%r12), %r12
19700 +#else
19701 + lea init_tss(%rip), %r12
19702 +#endif
19703 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19704 call \do_sym
19705 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19706 jmp paranoid_exit /* %ebx: no swapgs flag */
19707 CFI_ENDPROC
19708 -END(\sym)
19709 +ENDPROC(\sym)
19710 .endm
19711
19712 .macro errorentry sym do_sym
19713 @@ -1259,13 +1619,23 @@ ENTRY(\sym)
19714 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19715 call error_entry
19716 DEFAULT_FRAME 0
19717 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19718 + testb $3, CS(%rsp)
19719 + jnz 1f
19720 + pax_enter_kernel
19721 + jmp 2f
19722 +1: pax_enter_kernel_user
19723 +2:
19724 +#else
19725 + pax_enter_kernel
19726 +#endif
19727 movq %rsp,%rdi /* pt_regs pointer */
19728 movq ORIG_RAX(%rsp),%rsi /* get error code */
19729 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19730 call \do_sym
19731 jmp error_exit /* %ebx: no swapgs flag */
19732 CFI_ENDPROC
19733 -END(\sym)
19734 +ENDPROC(\sym)
19735 .endm
19736
19737 /* error code is on the stack already */
19738 @@ -1279,13 +1649,23 @@ ENTRY(\sym)
19739 call save_paranoid
19740 DEFAULT_FRAME 0
19741 TRACE_IRQS_OFF
19742 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19743 + testb $3, CS(%rsp)
19744 + jnz 1f
19745 + pax_enter_kernel
19746 + jmp 2f
19747 +1: pax_enter_kernel_user
19748 +2:
19749 +#else
19750 + pax_enter_kernel
19751 +#endif
19752 movq %rsp,%rdi /* pt_regs pointer */
19753 movq ORIG_RAX(%rsp),%rsi /* get error code */
19754 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19755 call \do_sym
19756 jmp paranoid_exit /* %ebx: no swapgs flag */
19757 CFI_ENDPROC
19758 -END(\sym)
19759 +ENDPROC(\sym)
19760 .endm
19761
19762 zeroentry divide_error do_divide_error
19763 @@ -1315,9 +1695,10 @@ gs_change:
19764 2: mfence /* workaround */
19765 SWAPGS
19766 popfq_cfi
19767 + pax_force_retaddr
19768 ret
19769 CFI_ENDPROC
19770 -END(native_load_gs_index)
19771 +ENDPROC(native_load_gs_index)
19772
19773 _ASM_EXTABLE(gs_change,bad_gs)
19774 .section .fixup,"ax"
19775 @@ -1345,9 +1726,10 @@ ENTRY(call_softirq)
19776 CFI_DEF_CFA_REGISTER rsp
19777 CFI_ADJUST_CFA_OFFSET -8
19778 decl PER_CPU_VAR(irq_count)
19779 + pax_force_retaddr
19780 ret
19781 CFI_ENDPROC
19782 -END(call_softirq)
19783 +ENDPROC(call_softirq)
19784
19785 #ifdef CONFIG_XEN
19786 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19787 @@ -1385,7 +1767,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19788 decl PER_CPU_VAR(irq_count)
19789 jmp error_exit
19790 CFI_ENDPROC
19791 -END(xen_do_hypervisor_callback)
19792 +ENDPROC(xen_do_hypervisor_callback)
19793
19794 /*
19795 * Hypervisor uses this for application faults while it executes.
19796 @@ -1444,7 +1826,7 @@ ENTRY(xen_failsafe_callback)
19797 SAVE_ALL
19798 jmp error_exit
19799 CFI_ENDPROC
19800 -END(xen_failsafe_callback)
19801 +ENDPROC(xen_failsafe_callback)
19802
19803 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19804 xen_hvm_callback_vector xen_evtchn_do_upcall
19805 @@ -1498,16 +1880,31 @@ ENTRY(paranoid_exit)
19806 TRACE_IRQS_OFF_DEBUG
19807 testl %ebx,%ebx /* swapgs needed? */
19808 jnz paranoid_restore
19809 - testl $3,CS(%rsp)
19810 + testb $3,CS(%rsp)
19811 jnz paranoid_userspace
19812 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19813 + pax_exit_kernel
19814 + TRACE_IRQS_IRETQ 0
19815 + SWAPGS_UNSAFE_STACK
19816 + RESTORE_ALL 8
19817 + pax_force_retaddr_bts
19818 + jmp irq_return
19819 +#endif
19820 paranoid_swapgs:
19821 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19822 + pax_exit_kernel_user
19823 +#else
19824 + pax_exit_kernel
19825 +#endif
19826 TRACE_IRQS_IRETQ 0
19827 SWAPGS_UNSAFE_STACK
19828 RESTORE_ALL 8
19829 jmp irq_return
19830 paranoid_restore:
19831 + pax_exit_kernel
19832 TRACE_IRQS_IRETQ_DEBUG 0
19833 RESTORE_ALL 8
19834 + pax_force_retaddr_bts
19835 jmp irq_return
19836 paranoid_userspace:
19837 GET_THREAD_INFO(%rcx)
19838 @@ -1536,7 +1933,7 @@ paranoid_schedule:
19839 TRACE_IRQS_OFF
19840 jmp paranoid_userspace
19841 CFI_ENDPROC
19842 -END(paranoid_exit)
19843 +ENDPROC(paranoid_exit)
19844
19845 /*
19846 * Exception entry point. This expects an error code/orig_rax on the stack.
19847 @@ -1563,12 +1960,13 @@ ENTRY(error_entry)
19848 movq_cfi r14, R14+8
19849 movq_cfi r15, R15+8
19850 xorl %ebx,%ebx
19851 - testl $3,CS+8(%rsp)
19852 + testb $3,CS+8(%rsp)
19853 je error_kernelspace
19854 error_swapgs:
19855 SWAPGS
19856 error_sti:
19857 TRACE_IRQS_OFF
19858 + pax_force_retaddr_bts
19859 ret
19860
19861 /*
19862 @@ -1595,7 +1993,7 @@ bstep_iret:
19863 movq %rcx,RIP+8(%rsp)
19864 jmp error_swapgs
19865 CFI_ENDPROC
19866 -END(error_entry)
19867 +ENDPROC(error_entry)
19868
19869
19870 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19871 @@ -1615,7 +2013,7 @@ ENTRY(error_exit)
19872 jnz retint_careful
19873 jmp retint_swapgs
19874 CFI_ENDPROC
19875 -END(error_exit)
19876 +ENDPROC(error_exit)
19877
19878 /*
19879 * Test if a given stack is an NMI stack or not.
19880 @@ -1673,9 +2071,11 @@ ENTRY(nmi)
19881 * If %cs was not the kernel segment, then the NMI triggered in user
19882 * space, which means it is definitely not nested.
19883 */
19884 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19885 + je 1f
19886 cmpl $__KERNEL_CS, 16(%rsp)
19887 jne first_nmi
19888 -
19889 +1:
19890 /*
19891 * Check the special variable on the stack to see if NMIs are
19892 * executing.
19893 @@ -1709,8 +2109,7 @@ nested_nmi:
19894
19895 1:
19896 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
19897 - leaq -1*8(%rsp), %rdx
19898 - movq %rdx, %rsp
19899 + subq $8, %rsp
19900 CFI_ADJUST_CFA_OFFSET 1*8
19901 leaq -10*8(%rsp), %rdx
19902 pushq_cfi $__KERNEL_DS
19903 @@ -1728,6 +2127,7 @@ nested_nmi_out:
19904 CFI_RESTORE rdx
19905
19906 /* No need to check faults here */
19907 + pax_force_retaddr_bts
19908 INTERRUPT_RETURN
19909
19910 CFI_RESTORE_STATE
19911 @@ -1844,6 +2244,17 @@ end_repeat_nmi:
19912 */
19913 movq %cr2, %r12
19914
19915 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19916 + testb $3, CS(%rsp)
19917 + jnz 1f
19918 + pax_enter_kernel
19919 + jmp 2f
19920 +1: pax_enter_kernel_user
19921 +2:
19922 +#else
19923 + pax_enter_kernel
19924 +#endif
19925 +
19926 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
19927 movq %rsp,%rdi
19928 movq $-1,%rsi
19929 @@ -1859,23 +2270,34 @@ end_repeat_nmi:
19930 testl %ebx,%ebx /* swapgs needed? */
19931 jnz nmi_restore
19932 nmi_swapgs:
19933 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19934 + pax_exit_kernel_user
19935 +#else
19936 + pax_exit_kernel
19937 +#endif
19938 SWAPGS_UNSAFE_STACK
19939 + RESTORE_ALL 6*8
19940 + /* Clear the NMI executing stack variable */
19941 + movq $0, 5*8(%rsp)
19942 + jmp irq_return
19943 nmi_restore:
19944 + pax_exit_kernel
19945 /* Pop the extra iret frame at once */
19946 RESTORE_ALL 6*8
19947 + pax_force_retaddr_bts
19948
19949 /* Clear the NMI executing stack variable */
19950 movq $0, 5*8(%rsp)
19951 jmp irq_return
19952 CFI_ENDPROC
19953 -END(nmi)
19954 +ENDPROC(nmi)
19955
19956 ENTRY(ignore_sysret)
19957 CFI_STARTPROC
19958 mov $-ENOSYS,%eax
19959 sysret
19960 CFI_ENDPROC
19961 -END(ignore_sysret)
19962 +ENDPROC(ignore_sysret)
19963
19964 /*
19965 * End of kprobes section
19966 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
19967 index 42a392a..fbbd930 100644
19968 --- a/arch/x86/kernel/ftrace.c
19969 +++ b/arch/x86/kernel/ftrace.c
19970 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
19971 {
19972 unsigned char replaced[MCOUNT_INSN_SIZE];
19973
19974 + ip = ktla_ktva(ip);
19975 +
19976 /*
19977 * Note: Due to modules and __init, code can
19978 * disappear and change, we need to protect against faulting
19979 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19980 unsigned char old[MCOUNT_INSN_SIZE], *new;
19981 int ret;
19982
19983 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
19984 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
19985 new = ftrace_call_replace(ip, (unsigned long)func);
19986
19987 /* See comment above by declaration of modifying_ftrace_code */
19988 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19989 /* Also update the regs callback function */
19990 if (!ret) {
19991 ip = (unsigned long)(&ftrace_regs_call);
19992 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
19993 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
19994 new = ftrace_call_replace(ip, (unsigned long)func);
19995 ret = ftrace_modify_code(ip, old, new);
19996 }
19997 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
19998 * kernel identity mapping to modify code.
19999 */
20000 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20001 - ip = (unsigned long)__va(__pa_symbol(ip));
20002 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
20003
20004 return probe_kernel_write((void *)ip, val, size);
20005 }
20006 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20007 unsigned char replaced[MCOUNT_INSN_SIZE];
20008 unsigned char brk = BREAKPOINT_INSTRUCTION;
20009
20010 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20011 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20012 return -EFAULT;
20013
20014 /* Make sure it is what we expect it to be */
20015 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20016 return ret;
20017
20018 fail_update:
20019 - probe_kernel_write((void *)ip, &old_code[0], 1);
20020 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20021 goto out;
20022 }
20023
20024 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20025 {
20026 unsigned char code[MCOUNT_INSN_SIZE];
20027
20028 + ip = ktla_ktva(ip);
20029 +
20030 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20031 return -EFAULT;
20032
20033 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
20034 index 8f3201d..aa860bf 100644
20035 --- a/arch/x86/kernel/head64.c
20036 +++ b/arch/x86/kernel/head64.c
20037 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
20038 if (console_loglevel == 10)
20039 early_printk("Kernel alive\n");
20040
20041 - clear_page(init_level4_pgt);
20042 /* set init_level4_pgt kernel high mapping*/
20043 init_level4_pgt[511] = early_level4_pgt[511];
20044
20045 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20046 index 73afd11..d1670f5 100644
20047 --- a/arch/x86/kernel/head_32.S
20048 +++ b/arch/x86/kernel/head_32.S
20049 @@ -26,6 +26,12 @@
20050 /* Physical address */
20051 #define pa(X) ((X) - __PAGE_OFFSET)
20052
20053 +#ifdef CONFIG_PAX_KERNEXEC
20054 +#define ta(X) (X)
20055 +#else
20056 +#define ta(X) ((X) - __PAGE_OFFSET)
20057 +#endif
20058 +
20059 /*
20060 * References to members of the new_cpu_data structure.
20061 */
20062 @@ -55,11 +61,7 @@
20063 * and small than max_low_pfn, otherwise will waste some page table entries
20064 */
20065
20066 -#if PTRS_PER_PMD > 1
20067 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20068 -#else
20069 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20070 -#endif
20071 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20072
20073 /* Number of possible pages in the lowmem region */
20074 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20075 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20076 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20077
20078 /*
20079 + * Real beginning of normal "text" segment
20080 + */
20081 +ENTRY(stext)
20082 +ENTRY(_stext)
20083 +
20084 +/*
20085 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20086 * %esi points to the real-mode code as a 32-bit pointer.
20087 * CS and DS must be 4 GB flat segments, but we don't depend on
20088 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20089 * can.
20090 */
20091 __HEAD
20092 +
20093 +#ifdef CONFIG_PAX_KERNEXEC
20094 + jmp startup_32
20095 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20096 +.fill PAGE_SIZE-5,1,0xcc
20097 +#endif
20098 +
20099 ENTRY(startup_32)
20100 movl pa(stack_start),%ecx
20101
20102 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20103 2:
20104 leal -__PAGE_OFFSET(%ecx),%esp
20105
20106 +#ifdef CONFIG_SMP
20107 + movl $pa(cpu_gdt_table),%edi
20108 + movl $__per_cpu_load,%eax
20109 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20110 + rorl $16,%eax
20111 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20112 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20113 + movl $__per_cpu_end - 1,%eax
20114 + subl $__per_cpu_start,%eax
20115 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20116 +#endif
20117 +
20118 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20119 + movl $NR_CPUS,%ecx
20120 + movl $pa(cpu_gdt_table),%edi
20121 +1:
20122 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20123 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20124 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20125 + addl $PAGE_SIZE_asm,%edi
20126 + loop 1b
20127 +#endif
20128 +
20129 +#ifdef CONFIG_PAX_KERNEXEC
20130 + movl $pa(boot_gdt),%edi
20131 + movl $__LOAD_PHYSICAL_ADDR,%eax
20132 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20133 + rorl $16,%eax
20134 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20135 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20136 + rorl $16,%eax
20137 +
20138 + ljmp $(__BOOT_CS),$1f
20139 +1:
20140 +
20141 + movl $NR_CPUS,%ecx
20142 + movl $pa(cpu_gdt_table),%edi
20143 + addl $__PAGE_OFFSET,%eax
20144 +1:
20145 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20146 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20147 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20148 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20149 + rorl $16,%eax
20150 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20151 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20152 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20153 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20154 + rorl $16,%eax
20155 + addl $PAGE_SIZE_asm,%edi
20156 + loop 1b
20157 +#endif
20158 +
20159 /*
20160 * Clear BSS first so that there are no surprises...
20161 */
20162 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20163 movl %eax, pa(max_pfn_mapped)
20164
20165 /* Do early initialization of the fixmap area */
20166 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20167 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20168 +#ifdef CONFIG_COMPAT_VDSO
20169 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20170 +#else
20171 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20172 +#endif
20173 #else /* Not PAE */
20174
20175 page_pde_offset = (__PAGE_OFFSET >> 20);
20176 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20177 movl %eax, pa(max_pfn_mapped)
20178
20179 /* Do early initialization of the fixmap area */
20180 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20181 - movl %eax,pa(initial_page_table+0xffc)
20182 +#ifdef CONFIG_COMPAT_VDSO
20183 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20184 +#else
20185 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20186 +#endif
20187 #endif
20188
20189 #ifdef CONFIG_PARAVIRT
20190 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20191 cmpl $num_subarch_entries, %eax
20192 jae bad_subarch
20193
20194 - movl pa(subarch_entries)(,%eax,4), %eax
20195 - subl $__PAGE_OFFSET, %eax
20196 - jmp *%eax
20197 + jmp *pa(subarch_entries)(,%eax,4)
20198
20199 bad_subarch:
20200 WEAK(lguest_entry)
20201 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20202 __INITDATA
20203
20204 subarch_entries:
20205 - .long default_entry /* normal x86/PC */
20206 - .long lguest_entry /* lguest hypervisor */
20207 - .long xen_entry /* Xen hypervisor */
20208 - .long default_entry /* Moorestown MID */
20209 + .long ta(default_entry) /* normal x86/PC */
20210 + .long ta(lguest_entry) /* lguest hypervisor */
20211 + .long ta(xen_entry) /* Xen hypervisor */
20212 + .long ta(default_entry) /* Moorestown MID */
20213 num_subarch_entries = (. - subarch_entries) / 4
20214 .previous
20215 #else
20216 @@ -355,6 +427,7 @@ default_entry:
20217 movl pa(mmu_cr4_features),%eax
20218 movl %eax,%cr4
20219
20220 +#ifdef CONFIG_X86_PAE
20221 testb $X86_CR4_PAE, %al # check if PAE is enabled
20222 jz enable_paging
20223
20224 @@ -383,6 +456,9 @@ default_entry:
20225 /* Make changes effective */
20226 wrmsr
20227
20228 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20229 +#endif
20230 +
20231 enable_paging:
20232
20233 /*
20234 @@ -451,14 +527,20 @@ is486:
20235 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20236 movl %eax,%ss # after changing gdt.
20237
20238 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20239 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20240 movl %eax,%ds
20241 movl %eax,%es
20242
20243 movl $(__KERNEL_PERCPU), %eax
20244 movl %eax,%fs # set this cpu's percpu
20245
20246 +#ifdef CONFIG_CC_STACKPROTECTOR
20247 movl $(__KERNEL_STACK_CANARY),%eax
20248 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20249 + movl $(__USER_DS),%eax
20250 +#else
20251 + xorl %eax,%eax
20252 +#endif
20253 movl %eax,%gs
20254
20255 xorl %eax,%eax # Clear LDT
20256 @@ -534,8 +616,11 @@ setup_once:
20257 * relocation. Manually set base address in stack canary
20258 * segment descriptor.
20259 */
20260 - movl $gdt_page,%eax
20261 + movl $cpu_gdt_table,%eax
20262 movl $stack_canary,%ecx
20263 +#ifdef CONFIG_SMP
20264 + addl $__per_cpu_load,%ecx
20265 +#endif
20266 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20267 shrl $16, %ecx
20268 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20269 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20270 /* This is global to keep gas from relaxing the jumps */
20271 ENTRY(early_idt_handler)
20272 cld
20273 - cmpl $2,%ss:early_recursion_flag
20274 + cmpl $1,%ss:early_recursion_flag
20275 je hlt_loop
20276 incl %ss:early_recursion_flag
20277
20278 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20279 pushl (20+6*4)(%esp) /* trapno */
20280 pushl $fault_msg
20281 call printk
20282 -#endif
20283 call dump_stack
20284 +#endif
20285 hlt_loop:
20286 hlt
20287 jmp hlt_loop
20288 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20289 /* This is the default interrupt "handler" :-) */
20290 ALIGN
20291 ignore_int:
20292 - cld
20293 #ifdef CONFIG_PRINTK
20294 + cmpl $2,%ss:early_recursion_flag
20295 + je hlt_loop
20296 + incl %ss:early_recursion_flag
20297 + cld
20298 pushl %eax
20299 pushl %ecx
20300 pushl %edx
20301 @@ -634,9 +722,6 @@ ignore_int:
20302 movl $(__KERNEL_DS),%eax
20303 movl %eax,%ds
20304 movl %eax,%es
20305 - cmpl $2,early_recursion_flag
20306 - je hlt_loop
20307 - incl early_recursion_flag
20308 pushl 16(%esp)
20309 pushl 24(%esp)
20310 pushl 32(%esp)
20311 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20312 /*
20313 * BSS section
20314 */
20315 -__PAGE_ALIGNED_BSS
20316 - .align PAGE_SIZE
20317 #ifdef CONFIG_X86_PAE
20318 +.section .initial_pg_pmd,"a",@progbits
20319 initial_pg_pmd:
20320 .fill 1024*KPMDS,4,0
20321 #else
20322 +.section .initial_page_table,"a",@progbits
20323 ENTRY(initial_page_table)
20324 .fill 1024,4,0
20325 #endif
20326 +.section .initial_pg_fixmap,"a",@progbits
20327 initial_pg_fixmap:
20328 .fill 1024,4,0
20329 +.section .empty_zero_page,"a",@progbits
20330 ENTRY(empty_zero_page)
20331 .fill 4096,1,0
20332 +.section .swapper_pg_dir,"a",@progbits
20333 ENTRY(swapper_pg_dir)
20334 +#ifdef CONFIG_X86_PAE
20335 + .fill 4,8,0
20336 +#else
20337 .fill 1024,4,0
20338 +#endif
20339 +
20340 +/*
20341 + * The IDT has to be page-aligned to simplify the Pentium
20342 + * F0 0F bug workaround.. We have a special link segment
20343 + * for this.
20344 + */
20345 +.section .idt,"a",@progbits
20346 +ENTRY(idt_table)
20347 + .fill 256,8,0
20348
20349 /*
20350 * This starts the data section.
20351 */
20352 #ifdef CONFIG_X86_PAE
20353 -__PAGE_ALIGNED_DATA
20354 - /* Page-aligned for the benefit of paravirt? */
20355 - .align PAGE_SIZE
20356 +.section .initial_page_table,"a",@progbits
20357 ENTRY(initial_page_table)
20358 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20359 # if KPMDS == 3
20360 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20361 # error "Kernel PMDs should be 1, 2 or 3"
20362 # endif
20363 .align PAGE_SIZE /* needs to be page-sized too */
20364 +
20365 +#ifdef CONFIG_PAX_PER_CPU_PGD
20366 +ENTRY(cpu_pgd)
20367 + .rept NR_CPUS
20368 + .fill 4,8,0
20369 + .endr
20370 +#endif
20371 +
20372 #endif
20373
20374 .data
20375 .balign 4
20376 ENTRY(stack_start)
20377 - .long init_thread_union+THREAD_SIZE
20378 + .long init_thread_union+THREAD_SIZE-8
20379
20380 __INITRODATA
20381 int_msg:
20382 @@ -744,7 +851,7 @@ fault_msg:
20383 * segment size, and 32-bit linear address value:
20384 */
20385
20386 - .data
20387 +.section .rodata,"a",@progbits
20388 .globl boot_gdt_descr
20389 .globl idt_descr
20390
20391 @@ -753,7 +860,7 @@ fault_msg:
20392 .word 0 # 32 bit align gdt_desc.address
20393 boot_gdt_descr:
20394 .word __BOOT_DS+7
20395 - .long boot_gdt - __PAGE_OFFSET
20396 + .long pa(boot_gdt)
20397
20398 .word 0 # 32-bit align idt_desc.address
20399 idt_descr:
20400 @@ -764,7 +871,7 @@ idt_descr:
20401 .word 0 # 32 bit align gdt_desc.address
20402 ENTRY(early_gdt_descr)
20403 .word GDT_ENTRIES*8-1
20404 - .long gdt_page /* Overwritten for secondary CPUs */
20405 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20406
20407 /*
20408 * The boot_gdt must mirror the equivalent in setup.S and is
20409 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20410 .align L1_CACHE_BYTES
20411 ENTRY(boot_gdt)
20412 .fill GDT_ENTRY_BOOT_CS,8,0
20413 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20414 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20415 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20416 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20417 +
20418 + .align PAGE_SIZE_asm
20419 +ENTRY(cpu_gdt_table)
20420 + .rept NR_CPUS
20421 + .quad 0x0000000000000000 /* NULL descriptor */
20422 + .quad 0x0000000000000000 /* 0x0b reserved */
20423 + .quad 0x0000000000000000 /* 0x13 reserved */
20424 + .quad 0x0000000000000000 /* 0x1b reserved */
20425 +
20426 +#ifdef CONFIG_PAX_KERNEXEC
20427 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20428 +#else
20429 + .quad 0x0000000000000000 /* 0x20 unused */
20430 +#endif
20431 +
20432 + .quad 0x0000000000000000 /* 0x28 unused */
20433 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20434 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20435 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20436 + .quad 0x0000000000000000 /* 0x4b reserved */
20437 + .quad 0x0000000000000000 /* 0x53 reserved */
20438 + .quad 0x0000000000000000 /* 0x5b reserved */
20439 +
20440 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20441 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20442 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20443 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20444 +
20445 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20446 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20447 +
20448 + /*
20449 + * Segments used for calling PnP BIOS have byte granularity.
20450 + * The code segments and data segments have fixed 64k limits,
20451 + * the transfer segment sizes are set at run time.
20452 + */
20453 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20454 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20455 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20456 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20457 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20458 +
20459 + /*
20460 + * The APM segments have byte granularity and their bases
20461 + * are set at run time. All have 64k limits.
20462 + */
20463 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20464 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20465 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20466 +
20467 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20468 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20469 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20470 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20471 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20472 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20473 +
20474 + /* Be sure this is zeroed to avoid false validations in Xen */
20475 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20476 + .endr
20477 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20478 index 08f7e80..40cbed5 100644
20479 --- a/arch/x86/kernel/head_64.S
20480 +++ b/arch/x86/kernel/head_64.S
20481 @@ -20,6 +20,8 @@
20482 #include <asm/processor-flags.h>
20483 #include <asm/percpu.h>
20484 #include <asm/nops.h>
20485 +#include <asm/cpufeature.h>
20486 +#include <asm/alternative-asm.h>
20487
20488 #ifdef CONFIG_PARAVIRT
20489 #include <asm/asm-offsets.h>
20490 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20491 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20492 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20493 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20494 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20495 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20496 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20497 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20498 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20499 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20500
20501 .text
20502 __HEAD
20503 @@ -89,11 +97,15 @@ startup_64:
20504 * Fixup the physical addresses in the page table
20505 */
20506 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20507 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20508 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20509 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20510
20511 addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20512 addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20513
20514 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20515 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20516
20517 /*
20518 * Set up the identity mapping for the switchover. These
20519 @@ -175,8 +187,8 @@ ENTRY(secondary_startup_64)
20520 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20521 1:
20522
20523 - /* Enable PAE mode and PGE */
20524 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20525 + /* Enable PAE mode and PSE/PGE */
20526 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20527 movq %rcx, %cr4
20528
20529 /* Setup early boot stage 4 level pagetables. */
20530 @@ -197,10 +209,18 @@ ENTRY(secondary_startup_64)
20531 movl $MSR_EFER, %ecx
20532 rdmsr
20533 btsl $_EFER_SCE, %eax /* Enable System Call */
20534 - btl $20,%edi /* No Execute supported? */
20535 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20536 jnc 1f
20537 btsl $_EFER_NX, %eax
20538 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20539 + leaq init_level4_pgt(%rip), %rdi
20540 +#ifndef CONFIG_EFI
20541 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20542 +#endif
20543 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20544 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20545 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20546 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20547 1: wrmsr /* Make changes effective */
20548
20549 /* Setup cr0 */
20550 @@ -280,6 +300,7 @@ ENTRY(secondary_startup_64)
20551 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20552 * address given in m16:64.
20553 */
20554 + pax_set_fptr_mask
20555 movq initial_code(%rip),%rax
20556 pushq $0 # fake return address to stop unwinder
20557 pushq $__KERNEL_CS # set correct cs
20558 @@ -386,7 +407,7 @@ ENTRY(early_idt_handler)
20559 call dump_stack
20560 #ifdef CONFIG_KALLSYMS
20561 leaq early_idt_ripmsg(%rip),%rdi
20562 - movq 40(%rsp),%rsi # %rip again
20563 + movq 88(%rsp),%rsi # %rip again
20564 call __print_symbol
20565 #endif
20566 #endif /* EARLY_PRINTK */
20567 @@ -414,6 +435,7 @@ ENDPROC(early_idt_handler)
20568 early_recursion_flag:
20569 .long 0
20570
20571 + .section .rodata,"a",@progbits
20572 #ifdef CONFIG_EARLY_PRINTK
20573 early_idt_msg:
20574 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20575 @@ -443,27 +465,50 @@ NEXT_PAGE(early_dynamic_pgts)
20576
20577 .data
20578
20579 -#ifndef CONFIG_XEN
20580 NEXT_PAGE(init_level4_pgt)
20581 - .fill 512,8,0
20582 -#else
20583 -NEXT_PAGE(init_level4_pgt)
20584 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20585 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20586 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20587 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20588 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20589 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20590 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20591 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20592 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20593 .org init_level4_pgt + L4_START_KERNEL*8, 0
20594 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20595 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20596
20597 +#ifdef CONFIG_PAX_PER_CPU_PGD
20598 +NEXT_PAGE(cpu_pgd)
20599 + .rept NR_CPUS
20600 + .fill 512,8,0
20601 + .endr
20602 +#endif
20603 +
20604 NEXT_PAGE(level3_ident_pgt)
20605 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20606 +#ifdef CONFIG_XEN
20607 .fill 511, 8, 0
20608 +#else
20609 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20610 + .fill 510,8,0
20611 +#endif
20612 +
20613 +NEXT_PAGE(level3_vmalloc_start_pgt)
20614 + .fill 512,8,0
20615 +
20616 +NEXT_PAGE(level3_vmalloc_end_pgt)
20617 + .fill 512,8,0
20618 +
20619 +NEXT_PAGE(level3_vmemmap_pgt)
20620 + .fill L3_VMEMMAP_START,8,0
20621 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20622 +
20623 NEXT_PAGE(level2_ident_pgt)
20624 - /* Since I easily can, map the first 1G.
20625 + /* Since I easily can, map the first 2G.
20626 * Don't set NX because code runs from these pages.
20627 */
20628 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20629 -#endif
20630 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20631
20632 NEXT_PAGE(level3_kernel_pgt)
20633 .fill L3_START_KERNEL,8,0
20634 @@ -471,6 +516,9 @@ NEXT_PAGE(level3_kernel_pgt)
20635 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20636 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20637
20638 +NEXT_PAGE(level2_vmemmap_pgt)
20639 + .fill 512,8,0
20640 +
20641 NEXT_PAGE(level2_kernel_pgt)
20642 /*
20643 * 512 MB kernel mapping. We spend a full page on this pagetable
20644 @@ -486,38 +534,64 @@ NEXT_PAGE(level2_kernel_pgt)
20645 KERNEL_IMAGE_SIZE/PMD_SIZE)
20646
20647 NEXT_PAGE(level2_fixmap_pgt)
20648 - .fill 506,8,0
20649 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20650 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20651 - .fill 5,8,0
20652 + .fill 507,8,0
20653 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20654 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20655 + .fill 4,8,0
20656
20657 -NEXT_PAGE(level1_fixmap_pgt)
20658 +NEXT_PAGE(level1_vsyscall_pgt)
20659 .fill 512,8,0
20660
20661 #undef PMDS
20662
20663 - .data
20664 + .align PAGE_SIZE
20665 +ENTRY(cpu_gdt_table)
20666 + .rept NR_CPUS
20667 + .quad 0x0000000000000000 /* NULL descriptor */
20668 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20669 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20670 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20671 + .quad 0x00cffb000000ffff /* __USER32_CS */
20672 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20673 + .quad 0x00affb000000ffff /* __USER_CS */
20674 +
20675 +#ifdef CONFIG_PAX_KERNEXEC
20676 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20677 +#else
20678 + .quad 0x0 /* unused */
20679 +#endif
20680 +
20681 + .quad 0,0 /* TSS */
20682 + .quad 0,0 /* LDT */
20683 + .quad 0,0,0 /* three TLS descriptors */
20684 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20685 + /* asm/segment.h:GDT_ENTRIES must match this */
20686 +
20687 + /* zero the remaining page */
20688 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20689 + .endr
20690 +
20691 .align 16
20692 .globl early_gdt_descr
20693 early_gdt_descr:
20694 .word GDT_ENTRIES*8-1
20695 early_gdt_descr_base:
20696 - .quad INIT_PER_CPU_VAR(gdt_page)
20697 + .quad cpu_gdt_table
20698
20699 ENTRY(phys_base)
20700 /* This must match the first entry in level2_kernel_pgt */
20701 .quad 0x0000000000000000
20702
20703 #include "../../x86/xen/xen-head.S"
20704 -
20705 - .section .bss, "aw", @nobits
20706 +
20707 + .section .rodata,"a",@progbits
20708 .align L1_CACHE_BYTES
20709 ENTRY(idt_table)
20710 - .skip IDT_ENTRIES * 16
20711 + .fill 512,8,0
20712
20713 .align L1_CACHE_BYTES
20714 ENTRY(nmi_idt_table)
20715 - .skip IDT_ENTRIES * 16
20716 + .fill 512,8,0
20717
20718 __PAGE_ALIGNED_BSS
20719 NEXT_PAGE(empty_zero_page)
20720 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20721 index 0fa6912..37fce70 100644
20722 --- a/arch/x86/kernel/i386_ksyms_32.c
20723 +++ b/arch/x86/kernel/i386_ksyms_32.c
20724 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20725 EXPORT_SYMBOL(cmpxchg8b_emu);
20726 #endif
20727
20728 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20729 +
20730 /* Networking helper routines. */
20731 EXPORT_SYMBOL(csum_partial_copy_generic);
20732 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20733 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20734
20735 EXPORT_SYMBOL(__get_user_1);
20736 EXPORT_SYMBOL(__get_user_2);
20737 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20738
20739 EXPORT_SYMBOL(csum_partial);
20740 EXPORT_SYMBOL(empty_zero_page);
20741 +
20742 +#ifdef CONFIG_PAX_KERNEXEC
20743 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20744 +#endif
20745 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20746 index 245a71d..89d9ce4 100644
20747 --- a/arch/x86/kernel/i387.c
20748 +++ b/arch/x86/kernel/i387.c
20749 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20750 static inline bool interrupted_user_mode(void)
20751 {
20752 struct pt_regs *regs = get_irq_regs();
20753 - return regs && user_mode_vm(regs);
20754 + return regs && user_mode(regs);
20755 }
20756
20757 /*
20758 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20759 index 9a5c460..84868423 100644
20760 --- a/arch/x86/kernel/i8259.c
20761 +++ b/arch/x86/kernel/i8259.c
20762 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20763 static void make_8259A_irq(unsigned int irq)
20764 {
20765 disable_irq_nosync(irq);
20766 - io_apic_irqs &= ~(1<<irq);
20767 + io_apic_irqs &= ~(1UL<<irq);
20768 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20769 i8259A_chip.name);
20770 enable_irq(irq);
20771 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20772 "spurious 8259A interrupt: IRQ%d.\n", irq);
20773 spurious_irq_mask |= irqmask;
20774 }
20775 - atomic_inc(&irq_err_count);
20776 + atomic_inc_unchecked(&irq_err_count);
20777 /*
20778 * Theoretically we do not have to handle this IRQ,
20779 * but in Linux this does not cause problems and is
20780 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20781 /* (slave's support for AEOI in flat mode is to be investigated) */
20782 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20783
20784 + pax_open_kernel();
20785 if (auto_eoi)
20786 /*
20787 * In AEOI mode we just have to mask the interrupt
20788 * when acking.
20789 */
20790 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20791 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20792 else
20793 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20794 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20795 + pax_close_kernel();
20796
20797 udelay(100); /* wait for 8259A to initialize */
20798
20799 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20800 index a979b5b..1d6db75 100644
20801 --- a/arch/x86/kernel/io_delay.c
20802 +++ b/arch/x86/kernel/io_delay.c
20803 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20804 * Quirk table for systems that misbehave (lock up, etc.) if port
20805 * 0x80 is used:
20806 */
20807 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20808 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20809 {
20810 .callback = dmi_io_delay_0xed_port,
20811 .ident = "Compaq Presario V6000",
20812 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20813 index 4ddaf66..6292f4e 100644
20814 --- a/arch/x86/kernel/ioport.c
20815 +++ b/arch/x86/kernel/ioport.c
20816 @@ -6,6 +6,7 @@
20817 #include <linux/sched.h>
20818 #include <linux/kernel.h>
20819 #include <linux/capability.h>
20820 +#include <linux/security.h>
20821 #include <linux/errno.h>
20822 #include <linux/types.h>
20823 #include <linux/ioport.h>
20824 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20825
20826 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20827 return -EINVAL;
20828 +#ifdef CONFIG_GRKERNSEC_IO
20829 + if (turn_on && grsec_disable_privio) {
20830 + gr_handle_ioperm();
20831 + return -EPERM;
20832 + }
20833 +#endif
20834 if (turn_on && !capable(CAP_SYS_RAWIO))
20835 return -EPERM;
20836
20837 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20838 * because the ->io_bitmap_max value must match the bitmap
20839 * contents:
20840 */
20841 - tss = &per_cpu(init_tss, get_cpu());
20842 + tss = init_tss + get_cpu();
20843
20844 if (turn_on)
20845 bitmap_clear(t->io_bitmap_ptr, from, num);
20846 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
20847 return -EINVAL;
20848 /* Trying to gain more privileges? */
20849 if (level > old) {
20850 +#ifdef CONFIG_GRKERNSEC_IO
20851 + if (grsec_disable_privio) {
20852 + gr_handle_iopl();
20853 + return -EPERM;
20854 + }
20855 +#endif
20856 if (!capable(CAP_SYS_RAWIO))
20857 return -EPERM;
20858 }
20859 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20860 index 84b7789..e65e8be 100644
20861 --- a/arch/x86/kernel/irq.c
20862 +++ b/arch/x86/kernel/irq.c
20863 @@ -18,7 +18,7 @@
20864 #include <asm/mce.h>
20865 #include <asm/hw_irq.h>
20866
20867 -atomic_t irq_err_count;
20868 +atomic_unchecked_t irq_err_count;
20869
20870 /* Function pointer for generic interrupt vector handling */
20871 void (*x86_platform_ipi_callback)(void) = NULL;
20872 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20873 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20874 seq_printf(p, " Machine check polls\n");
20875 #endif
20876 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
20877 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
20878 #if defined(CONFIG_X86_IO_APIC)
20879 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
20880 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
20881 #endif
20882 return 0;
20883 }
20884 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
20885
20886 u64 arch_irq_stat(void)
20887 {
20888 - u64 sum = atomic_read(&irq_err_count);
20889 + u64 sum = atomic_read_unchecked(&irq_err_count);
20890 return sum;
20891 }
20892
20893 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
20894 index 344faf8..355f60d 100644
20895 --- a/arch/x86/kernel/irq_32.c
20896 +++ b/arch/x86/kernel/irq_32.c
20897 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
20898 __asm__ __volatile__("andl %%esp,%0" :
20899 "=r" (sp) : "0" (THREAD_SIZE - 1));
20900
20901 - return sp < (sizeof(struct thread_info) + STACK_WARN);
20902 + return sp < STACK_WARN;
20903 }
20904
20905 static void print_stack_overflow(void)
20906 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
20907 * per-CPU IRQ handling contexts (thread information and stack)
20908 */
20909 union irq_ctx {
20910 - struct thread_info tinfo;
20911 - u32 stack[THREAD_SIZE/sizeof(u32)];
20912 + unsigned long previous_esp;
20913 + u32 stack[THREAD_SIZE/sizeof(u32)];
20914 } __attribute__((aligned(THREAD_SIZE)));
20915
20916 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
20917 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
20918 static inline int
20919 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20920 {
20921 - union irq_ctx *curctx, *irqctx;
20922 + union irq_ctx *irqctx;
20923 u32 *isp, arg1, arg2;
20924
20925 - curctx = (union irq_ctx *) current_thread_info();
20926 irqctx = __this_cpu_read(hardirq_ctx);
20927
20928 /*
20929 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20930 * handler) we can't do that and just have to keep using the
20931 * current stack (which is the irq stack already after all)
20932 */
20933 - if (unlikely(curctx == irqctx))
20934 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
20935 return 0;
20936
20937 /* build the stack frame on the IRQ stack */
20938 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20939 - irqctx->tinfo.task = curctx->tinfo.task;
20940 - irqctx->tinfo.previous_esp = current_stack_pointer;
20941 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20942 + irqctx->previous_esp = current_stack_pointer;
20943
20944 - /* Copy the preempt_count so that the [soft]irq checks work. */
20945 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
20946 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20947 + __set_fs(MAKE_MM_SEG(0));
20948 +#endif
20949
20950 if (unlikely(overflow))
20951 call_on_stack(print_stack_overflow, isp);
20952 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20953 : "0" (irq), "1" (desc), "2" (isp),
20954 "D" (desc->handle_irq)
20955 : "memory", "cc", "ecx");
20956 +
20957 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20958 + __set_fs(current_thread_info()->addr_limit);
20959 +#endif
20960 +
20961 return 1;
20962 }
20963
20964 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20965 */
20966 void __cpuinit irq_ctx_init(int cpu)
20967 {
20968 - union irq_ctx *irqctx;
20969 -
20970 if (per_cpu(hardirq_ctx, cpu))
20971 return;
20972
20973 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20974 - THREADINFO_GFP,
20975 - THREAD_SIZE_ORDER));
20976 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20977 - irqctx->tinfo.cpu = cpu;
20978 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
20979 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20980 -
20981 - per_cpu(hardirq_ctx, cpu) = irqctx;
20982 -
20983 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20984 - THREADINFO_GFP,
20985 - THREAD_SIZE_ORDER));
20986 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20987 - irqctx->tinfo.cpu = cpu;
20988 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20989 -
20990 - per_cpu(softirq_ctx, cpu) = irqctx;
20991 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20992 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20993 +
20994 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20995 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20996
20997 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20998 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20999 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21000 asmlinkage void do_softirq(void)
21001 {
21002 unsigned long flags;
21003 - struct thread_info *curctx;
21004 union irq_ctx *irqctx;
21005 u32 *isp;
21006
21007 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21008 local_irq_save(flags);
21009
21010 if (local_softirq_pending()) {
21011 - curctx = current_thread_info();
21012 irqctx = __this_cpu_read(softirq_ctx);
21013 - irqctx->tinfo.task = curctx->task;
21014 - irqctx->tinfo.previous_esp = current_stack_pointer;
21015 + irqctx->previous_esp = current_stack_pointer;
21016
21017 /* build the stack frame on the softirq stack */
21018 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21019 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21020 +
21021 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21022 + __set_fs(MAKE_MM_SEG(0));
21023 +#endif
21024
21025 call_on_stack(__do_softirq, isp);
21026 +
21027 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21028 + __set_fs(current_thread_info()->addr_limit);
21029 +#endif
21030 +
21031 /*
21032 * Shouldn't happen, we returned above if in_interrupt():
21033 */
21034 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21035 if (unlikely(!desc))
21036 return false;
21037
21038 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21039 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21040 if (unlikely(overflow))
21041 print_stack_overflow();
21042 desc->handle_irq(irq, desc);
21043 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21044 index d04d3ec..ea4b374 100644
21045 --- a/arch/x86/kernel/irq_64.c
21046 +++ b/arch/x86/kernel/irq_64.c
21047 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21048 u64 estack_top, estack_bottom;
21049 u64 curbase = (u64)task_stack_page(current);
21050
21051 - if (user_mode_vm(regs))
21052 + if (user_mode(regs))
21053 return;
21054
21055 if (regs->sp >= curbase + sizeof(struct thread_info) +
21056 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21057 index dc1404b..bbc43e7 100644
21058 --- a/arch/x86/kernel/kdebugfs.c
21059 +++ b/arch/x86/kernel/kdebugfs.c
21060 @@ -27,7 +27,7 @@ struct setup_data_node {
21061 u32 len;
21062 };
21063
21064 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21065 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21066 size_t count, loff_t *ppos)
21067 {
21068 struct setup_data_node *node = file->private_data;
21069 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21070 index 836f832..a8bda67 100644
21071 --- a/arch/x86/kernel/kgdb.c
21072 +++ b/arch/x86/kernel/kgdb.c
21073 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21074 #ifdef CONFIG_X86_32
21075 switch (regno) {
21076 case GDB_SS:
21077 - if (!user_mode_vm(regs))
21078 + if (!user_mode(regs))
21079 *(unsigned long *)mem = __KERNEL_DS;
21080 break;
21081 case GDB_SP:
21082 - if (!user_mode_vm(regs))
21083 + if (!user_mode(regs))
21084 *(unsigned long *)mem = kernel_stack_pointer(regs);
21085 break;
21086 case GDB_GS:
21087 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21088 bp->attr.bp_addr = breakinfo[breakno].addr;
21089 bp->attr.bp_len = breakinfo[breakno].len;
21090 bp->attr.bp_type = breakinfo[breakno].type;
21091 - info->address = breakinfo[breakno].addr;
21092 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21093 + info->address = ktla_ktva(breakinfo[breakno].addr);
21094 + else
21095 + info->address = breakinfo[breakno].addr;
21096 info->len = breakinfo[breakno].len;
21097 info->type = breakinfo[breakno].type;
21098 val = arch_install_hw_breakpoint(bp);
21099 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21100 case 'k':
21101 /* clear the trace bit */
21102 linux_regs->flags &= ~X86_EFLAGS_TF;
21103 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21104 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21105
21106 /* set the trace bit if we're stepping */
21107 if (remcomInBuffer[0] == 's') {
21108 linux_regs->flags |= X86_EFLAGS_TF;
21109 - atomic_set(&kgdb_cpu_doing_single_step,
21110 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21111 raw_smp_processor_id());
21112 }
21113
21114 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21115
21116 switch (cmd) {
21117 case DIE_DEBUG:
21118 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21119 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21120 if (user_mode(regs))
21121 return single_step_cont(regs, args);
21122 break;
21123 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21124 #endif /* CONFIG_DEBUG_RODATA */
21125
21126 bpt->type = BP_BREAKPOINT;
21127 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21128 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21129 BREAK_INSTR_SIZE);
21130 if (err)
21131 return err;
21132 - err = probe_kernel_write((char *)bpt->bpt_addr,
21133 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21134 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21135 #ifdef CONFIG_DEBUG_RODATA
21136 if (!err)
21137 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21138 return -EBUSY;
21139 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21140 BREAK_INSTR_SIZE);
21141 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21142 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21143 if (err)
21144 return err;
21145 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21146 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21147 if (mutex_is_locked(&text_mutex))
21148 goto knl_write;
21149 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21150 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21151 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21152 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21153 goto knl_write;
21154 return err;
21155 knl_write:
21156 #endif /* CONFIG_DEBUG_RODATA */
21157 - return probe_kernel_write((char *)bpt->bpt_addr,
21158 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21159 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21160 }
21161
21162 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21163 index 7bfe318..383d238 100644
21164 --- a/arch/x86/kernel/kprobes/core.c
21165 +++ b/arch/x86/kernel/kprobes/core.c
21166 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21167 s32 raddr;
21168 } __packed *insn;
21169
21170 - insn = (struct __arch_relative_insn *)from;
21171 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21172 +
21173 + pax_open_kernel();
21174 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21175 insn->op = op;
21176 + pax_close_kernel();
21177 }
21178
21179 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21180 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21181 kprobe_opcode_t opcode;
21182 kprobe_opcode_t *orig_opcodes = opcodes;
21183
21184 - if (search_exception_tables((unsigned long)opcodes))
21185 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21186 return 0; /* Page fault may occur on this address. */
21187
21188 retry:
21189 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21190 * for the first byte, we can recover the original instruction
21191 * from it and kp->opcode.
21192 */
21193 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21194 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21195 buf[0] = kp->opcode;
21196 - return (unsigned long)buf;
21197 + return ktva_ktla((unsigned long)buf);
21198 }
21199
21200 /*
21201 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21202 /* Another subsystem puts a breakpoint, failed to recover */
21203 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21204 return 0;
21205 + pax_open_kernel();
21206 memcpy(dest, insn.kaddr, insn.length);
21207 + pax_close_kernel();
21208
21209 #ifdef CONFIG_X86_64
21210 if (insn_rip_relative(&insn)) {
21211 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21212 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21213 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21214 disp = (u8 *) dest + insn_offset_displacement(&insn);
21215 + pax_open_kernel();
21216 *(s32 *) disp = (s32) newdisp;
21217 + pax_close_kernel();
21218 }
21219 #endif
21220 return insn.length;
21221 @@ -488,7 +495,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21222 * nor set current_kprobe, because it doesn't use single
21223 * stepping.
21224 */
21225 - regs->ip = (unsigned long)p->ainsn.insn;
21226 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21227 preempt_enable_no_resched();
21228 return;
21229 }
21230 @@ -505,9 +512,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21231 regs->flags &= ~X86_EFLAGS_IF;
21232 /* single step inline if the instruction is an int3 */
21233 if (p->opcode == BREAKPOINT_INSTRUCTION)
21234 - regs->ip = (unsigned long)p->addr;
21235 + regs->ip = ktla_ktva((unsigned long)p->addr);
21236 else
21237 - regs->ip = (unsigned long)p->ainsn.insn;
21238 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21239 }
21240
21241 /*
21242 @@ -586,7 +593,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21243 setup_singlestep(p, regs, kcb, 0);
21244 return 1;
21245 }
21246 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21247 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21248 /*
21249 * The breakpoint instruction was removed right
21250 * after we hit it. Another cpu has removed
21251 @@ -632,6 +639,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21252 " movq %rax, 152(%rsp)\n"
21253 RESTORE_REGS_STRING
21254 " popfq\n"
21255 +#ifdef KERNEXEC_PLUGIN
21256 + " btsq $63,(%rsp)\n"
21257 +#endif
21258 #else
21259 " pushf\n"
21260 SAVE_REGS_STRING
21261 @@ -769,7 +779,7 @@ static void __kprobes
21262 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21263 {
21264 unsigned long *tos = stack_addr(regs);
21265 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21266 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21267 unsigned long orig_ip = (unsigned long)p->addr;
21268 kprobe_opcode_t *insn = p->ainsn.insn;
21269
21270 @@ -951,7 +961,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21271 struct die_args *args = data;
21272 int ret = NOTIFY_DONE;
21273
21274 - if (args->regs && user_mode_vm(args->regs))
21275 + if (args->regs && user_mode(args->regs))
21276 return ret;
21277
21278 switch (val) {
21279 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21280 index 76dc6f0..66bdfc3 100644
21281 --- a/arch/x86/kernel/kprobes/opt.c
21282 +++ b/arch/x86/kernel/kprobes/opt.c
21283 @@ -79,6 +79,7 @@ found:
21284 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21285 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21286 {
21287 + pax_open_kernel();
21288 #ifdef CONFIG_X86_64
21289 *addr++ = 0x48;
21290 *addr++ = 0xbf;
21291 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21292 *addr++ = 0xb8;
21293 #endif
21294 *(unsigned long *)addr = val;
21295 + pax_close_kernel();
21296 }
21297
21298 static void __used __kprobes kprobes_optinsn_template_holder(void)
21299 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21300 * Verify if the address gap is in 2GB range, because this uses
21301 * a relative jump.
21302 */
21303 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21304 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21305 if (abs(rel) > 0x7fffffff)
21306 return -ERANGE;
21307
21308 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21309 op->optinsn.size = ret;
21310
21311 /* Copy arch-dep-instance from template */
21312 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21313 + pax_open_kernel();
21314 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21315 + pax_close_kernel();
21316
21317 /* Set probe information */
21318 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21319
21320 /* Set probe function call */
21321 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21322 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21323
21324 /* Set returning jmp instruction at the tail of out-of-line buffer */
21325 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21326 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21327 (u8 *)op->kp.addr + op->optinsn.size);
21328
21329 flush_icache_range((unsigned long) buf,
21330 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21331 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21332
21333 /* Backup instructions which will be replaced by jump address */
21334 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21335 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21336 RELATIVE_ADDR_SIZE);
21337
21338 insn_buf[0] = RELATIVEJUMP_OPCODE;
21339 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21340 /* This kprobe is really able to run optimized path. */
21341 op = container_of(p, struct optimized_kprobe, kp);
21342 /* Detour through copied instructions */
21343 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21344 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21345 if (!reenter)
21346 reset_current_kprobe();
21347 preempt_enable_no_resched();
21348 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21349 index b686a90..60d36fb 100644
21350 --- a/arch/x86/kernel/kvm.c
21351 +++ b/arch/x86/kernel/kvm.c
21352 @@ -453,7 +453,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21353 return NOTIFY_OK;
21354 }
21355
21356 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21357 +static struct notifier_block kvm_cpu_notifier = {
21358 .notifier_call = kvm_cpu_notify,
21359 };
21360 #endif
21361 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21362 index ebc9873..1b9724b 100644
21363 --- a/arch/x86/kernel/ldt.c
21364 +++ b/arch/x86/kernel/ldt.c
21365 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21366 if (reload) {
21367 #ifdef CONFIG_SMP
21368 preempt_disable();
21369 - load_LDT(pc);
21370 + load_LDT_nolock(pc);
21371 if (!cpumask_equal(mm_cpumask(current->mm),
21372 cpumask_of(smp_processor_id())))
21373 smp_call_function(flush_ldt, current->mm, 1);
21374 preempt_enable();
21375 #else
21376 - load_LDT(pc);
21377 + load_LDT_nolock(pc);
21378 #endif
21379 }
21380 if (oldsize) {
21381 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21382 return err;
21383
21384 for (i = 0; i < old->size; i++)
21385 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21386 + write_ldt_entry(new->ldt, i, old->ldt + i);
21387 return 0;
21388 }
21389
21390 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21391 retval = copy_ldt(&mm->context, &old_mm->context);
21392 mutex_unlock(&old_mm->context.lock);
21393 }
21394 +
21395 + if (tsk == current) {
21396 + mm->context.vdso = 0;
21397 +
21398 +#ifdef CONFIG_X86_32
21399 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21400 + mm->context.user_cs_base = 0UL;
21401 + mm->context.user_cs_limit = ~0UL;
21402 +
21403 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21404 + cpus_clear(mm->context.cpu_user_cs_mask);
21405 +#endif
21406 +
21407 +#endif
21408 +#endif
21409 +
21410 + }
21411 +
21412 return retval;
21413 }
21414
21415 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21416 }
21417 }
21418
21419 +#ifdef CONFIG_PAX_SEGMEXEC
21420 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21421 + error = -EINVAL;
21422 + goto out_unlock;
21423 + }
21424 +#endif
21425 +
21426 fill_ldt(&ldt, &ldt_info);
21427 if (oldmode)
21428 ldt.avl = 0;
21429 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21430 index 5b19e4d..6476a76 100644
21431 --- a/arch/x86/kernel/machine_kexec_32.c
21432 +++ b/arch/x86/kernel/machine_kexec_32.c
21433 @@ -26,7 +26,7 @@
21434 #include <asm/cacheflush.h>
21435 #include <asm/debugreg.h>
21436
21437 -static void set_idt(void *newidt, __u16 limit)
21438 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21439 {
21440 struct desc_ptr curidt;
21441
21442 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21443 }
21444
21445
21446 -static void set_gdt(void *newgdt, __u16 limit)
21447 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21448 {
21449 struct desc_ptr curgdt;
21450
21451 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21452 }
21453
21454 control_page = page_address(image->control_code_page);
21455 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21456 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21457
21458 relocate_kernel_ptr = control_page;
21459 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21460 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21461 index 22db92b..d546bec 100644
21462 --- a/arch/x86/kernel/microcode_core.c
21463 +++ b/arch/x86/kernel/microcode_core.c
21464 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21465 return NOTIFY_OK;
21466 }
21467
21468 -static struct notifier_block __refdata mc_cpu_notifier = {
21469 +static struct notifier_block mc_cpu_notifier = {
21470 .notifier_call = mc_cpu_callback,
21471 };
21472
21473 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21474 index 5fb2ceb..3ae90bb 100644
21475 --- a/arch/x86/kernel/microcode_intel.c
21476 +++ b/arch/x86/kernel/microcode_intel.c
21477 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21478
21479 static int get_ucode_user(void *to, const void *from, size_t n)
21480 {
21481 - return copy_from_user(to, from, n);
21482 + return copy_from_user(to, (const void __force_user *)from, n);
21483 }
21484
21485 static enum ucode_state
21486 request_microcode_user(int cpu, const void __user *buf, size_t size)
21487 {
21488 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21489 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21490 }
21491
21492 static void microcode_fini_cpu(int cpu)
21493 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21494 index 216a4d7..228255a 100644
21495 --- a/arch/x86/kernel/module.c
21496 +++ b/arch/x86/kernel/module.c
21497 @@ -43,15 +43,60 @@ do { \
21498 } while (0)
21499 #endif
21500
21501 -void *module_alloc(unsigned long size)
21502 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21503 {
21504 - if (PAGE_ALIGN(size) > MODULES_LEN)
21505 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21506 return NULL;
21507 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21508 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21509 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21510 -1, __builtin_return_address(0));
21511 }
21512
21513 +void *module_alloc(unsigned long size)
21514 +{
21515 +
21516 +#ifdef CONFIG_PAX_KERNEXEC
21517 + return __module_alloc(size, PAGE_KERNEL);
21518 +#else
21519 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21520 +#endif
21521 +
21522 +}
21523 +
21524 +#ifdef CONFIG_PAX_KERNEXEC
21525 +#ifdef CONFIG_X86_32
21526 +void *module_alloc_exec(unsigned long size)
21527 +{
21528 + struct vm_struct *area;
21529 +
21530 + if (size == 0)
21531 + return NULL;
21532 +
21533 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21534 + return area ? area->addr : NULL;
21535 +}
21536 +EXPORT_SYMBOL(module_alloc_exec);
21537 +
21538 +void module_free_exec(struct module *mod, void *module_region)
21539 +{
21540 + vunmap(module_region);
21541 +}
21542 +EXPORT_SYMBOL(module_free_exec);
21543 +#else
21544 +void module_free_exec(struct module *mod, void *module_region)
21545 +{
21546 + module_free(mod, module_region);
21547 +}
21548 +EXPORT_SYMBOL(module_free_exec);
21549 +
21550 +void *module_alloc_exec(unsigned long size)
21551 +{
21552 + return __module_alloc(size, PAGE_KERNEL_RX);
21553 +}
21554 +EXPORT_SYMBOL(module_alloc_exec);
21555 +#endif
21556 +#endif
21557 +
21558 #ifdef CONFIG_X86_32
21559 int apply_relocate(Elf32_Shdr *sechdrs,
21560 const char *strtab,
21561 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21562 unsigned int i;
21563 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21564 Elf32_Sym *sym;
21565 - uint32_t *location;
21566 + uint32_t *plocation, location;
21567
21568 DEBUGP("Applying relocate section %u to %u\n",
21569 relsec, sechdrs[relsec].sh_info);
21570 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21571 /* This is where to make the change */
21572 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21573 - + rel[i].r_offset;
21574 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21575 + location = (uint32_t)plocation;
21576 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21577 + plocation = ktla_ktva((void *)plocation);
21578 /* This is the symbol it is referring to. Note that all
21579 undefined symbols have been resolved. */
21580 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21581 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21582 switch (ELF32_R_TYPE(rel[i].r_info)) {
21583 case R_386_32:
21584 /* We add the value into the location given */
21585 - *location += sym->st_value;
21586 + pax_open_kernel();
21587 + *plocation += sym->st_value;
21588 + pax_close_kernel();
21589 break;
21590 case R_386_PC32:
21591 /* Add the value, subtract its position */
21592 - *location += sym->st_value - (uint32_t)location;
21593 + pax_open_kernel();
21594 + *plocation += sym->st_value - location;
21595 + pax_close_kernel();
21596 break;
21597 default:
21598 pr_err("%s: Unknown relocation: %u\n",
21599 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21600 case R_X86_64_NONE:
21601 break;
21602 case R_X86_64_64:
21603 + pax_open_kernel();
21604 *(u64 *)loc = val;
21605 + pax_close_kernel();
21606 break;
21607 case R_X86_64_32:
21608 + pax_open_kernel();
21609 *(u32 *)loc = val;
21610 + pax_close_kernel();
21611 if (val != *(u32 *)loc)
21612 goto overflow;
21613 break;
21614 case R_X86_64_32S:
21615 + pax_open_kernel();
21616 *(s32 *)loc = val;
21617 + pax_close_kernel();
21618 if ((s64)val != *(s32 *)loc)
21619 goto overflow;
21620 break;
21621 case R_X86_64_PC32:
21622 val -= (u64)loc;
21623 + pax_open_kernel();
21624 *(u32 *)loc = val;
21625 + pax_close_kernel();
21626 +
21627 #if 0
21628 if ((s64)val != *(s32 *)loc)
21629 goto overflow;
21630 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21631 index ce13049..e2e9c3c 100644
21632 --- a/arch/x86/kernel/msr.c
21633 +++ b/arch/x86/kernel/msr.c
21634 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21635 return notifier_from_errno(err);
21636 }
21637
21638 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21639 +static struct notifier_block msr_class_cpu_notifier = {
21640 .notifier_call = msr_class_cpu_callback,
21641 };
21642
21643 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21644 index 6030805..2d33f21 100644
21645 --- a/arch/x86/kernel/nmi.c
21646 +++ b/arch/x86/kernel/nmi.c
21647 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21648 return handled;
21649 }
21650
21651 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21652 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21653 {
21654 struct nmi_desc *desc = nmi_to_desc(type);
21655 unsigned long flags;
21656 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21657 * event confuses some handlers (kdump uses this flag)
21658 */
21659 if (action->flags & NMI_FLAG_FIRST)
21660 - list_add_rcu(&action->list, &desc->head);
21661 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21662 else
21663 - list_add_tail_rcu(&action->list, &desc->head);
21664 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21665
21666 spin_unlock_irqrestore(&desc->lock, flags);
21667 return 0;
21668 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21669 if (!strcmp(n->name, name)) {
21670 WARN(in_nmi(),
21671 "Trying to free NMI (%s) from NMI context!\n", n->name);
21672 - list_del_rcu(&n->list);
21673 + pax_list_del_rcu((struct list_head *)&n->list);
21674 break;
21675 }
21676 }
21677 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21678 dotraplinkage notrace __kprobes void
21679 do_nmi(struct pt_regs *regs, long error_code)
21680 {
21681 +
21682 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21683 + if (!user_mode(regs)) {
21684 + unsigned long cs = regs->cs & 0xFFFF;
21685 + unsigned long ip = ktva_ktla(regs->ip);
21686 +
21687 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21688 + regs->ip = ip;
21689 + }
21690 +#endif
21691 +
21692 nmi_nesting_preprocess(regs);
21693
21694 nmi_enter();
21695 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21696 index 6d9582e..f746287 100644
21697 --- a/arch/x86/kernel/nmi_selftest.c
21698 +++ b/arch/x86/kernel/nmi_selftest.c
21699 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21700 {
21701 /* trap all the unknown NMIs we may generate */
21702 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21703 - __initdata);
21704 + __initconst);
21705 }
21706
21707 static void __init cleanup_nmi_testsuite(void)
21708 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21709 unsigned long timeout;
21710
21711 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21712 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21713 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21714 nmi_fail = FAILURE;
21715 return;
21716 }
21717 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21718 index 676b8c7..870ba04 100644
21719 --- a/arch/x86/kernel/paravirt-spinlocks.c
21720 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21721 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21722 arch_spin_lock(lock);
21723 }
21724
21725 -struct pv_lock_ops pv_lock_ops = {
21726 +struct pv_lock_ops pv_lock_ops __read_only = {
21727 #ifdef CONFIG_SMP
21728 .spin_is_locked = __ticket_spin_is_locked,
21729 .spin_is_contended = __ticket_spin_is_contended,
21730 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21731 index 8bfb335..c1463c6 100644
21732 --- a/arch/x86/kernel/paravirt.c
21733 +++ b/arch/x86/kernel/paravirt.c
21734 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21735 {
21736 return x;
21737 }
21738 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21739 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21740 +#endif
21741
21742 void __init default_banner(void)
21743 {
21744 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21745 if (opfunc == NULL)
21746 /* If there's no function, patch it with a ud2a (BUG) */
21747 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21748 - else if (opfunc == _paravirt_nop)
21749 + else if (opfunc == (void *)_paravirt_nop)
21750 /* If the operation is a nop, then nop the callsite */
21751 ret = paravirt_patch_nop();
21752
21753 /* identity functions just return their single argument */
21754 - else if (opfunc == _paravirt_ident_32)
21755 + else if (opfunc == (void *)_paravirt_ident_32)
21756 ret = paravirt_patch_ident_32(insnbuf, len);
21757 - else if (opfunc == _paravirt_ident_64)
21758 + else if (opfunc == (void *)_paravirt_ident_64)
21759 ret = paravirt_patch_ident_64(insnbuf, len);
21760 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21761 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21762 + ret = paravirt_patch_ident_64(insnbuf, len);
21763 +#endif
21764
21765 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21766 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21767 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21768 if (insn_len > len || start == NULL)
21769 insn_len = len;
21770 else
21771 - memcpy(insnbuf, start, insn_len);
21772 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21773
21774 return insn_len;
21775 }
21776 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21777 return this_cpu_read(paravirt_lazy_mode);
21778 }
21779
21780 -struct pv_info pv_info = {
21781 +struct pv_info pv_info __read_only = {
21782 .name = "bare hardware",
21783 .paravirt_enabled = 0,
21784 .kernel_rpl = 0,
21785 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21786 #endif
21787 };
21788
21789 -struct pv_init_ops pv_init_ops = {
21790 +struct pv_init_ops pv_init_ops __read_only = {
21791 .patch = native_patch,
21792 };
21793
21794 -struct pv_time_ops pv_time_ops = {
21795 +struct pv_time_ops pv_time_ops __read_only = {
21796 .sched_clock = native_sched_clock,
21797 .steal_clock = native_steal_clock,
21798 };
21799
21800 -struct pv_irq_ops pv_irq_ops = {
21801 +struct pv_irq_ops pv_irq_ops __read_only = {
21802 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21803 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21804 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21805 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21806 #endif
21807 };
21808
21809 -struct pv_cpu_ops pv_cpu_ops = {
21810 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21811 .cpuid = native_cpuid,
21812 .get_debugreg = native_get_debugreg,
21813 .set_debugreg = native_set_debugreg,
21814 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21815 .end_context_switch = paravirt_nop,
21816 };
21817
21818 -struct pv_apic_ops pv_apic_ops = {
21819 +struct pv_apic_ops pv_apic_ops __read_only= {
21820 #ifdef CONFIG_X86_LOCAL_APIC
21821 .startup_ipi_hook = paravirt_nop,
21822 #endif
21823 };
21824
21825 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21826 +#ifdef CONFIG_X86_32
21827 +#ifdef CONFIG_X86_PAE
21828 +/* 64-bit pagetable entries */
21829 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21830 +#else
21831 /* 32-bit pagetable entries */
21832 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21833 +#endif
21834 #else
21835 /* 64-bit pagetable entries */
21836 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21837 #endif
21838
21839 -struct pv_mmu_ops pv_mmu_ops = {
21840 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21841
21842 .read_cr2 = native_read_cr2,
21843 .write_cr2 = native_write_cr2,
21844 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21845 .make_pud = PTE_IDENT,
21846
21847 .set_pgd = native_set_pgd,
21848 + .set_pgd_batched = native_set_pgd_batched,
21849 #endif
21850 #endif /* PAGETABLE_LEVELS >= 3 */
21851
21852 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21853 },
21854
21855 .set_fixmap = native_set_fixmap,
21856 +
21857 +#ifdef CONFIG_PAX_KERNEXEC
21858 + .pax_open_kernel = native_pax_open_kernel,
21859 + .pax_close_kernel = native_pax_close_kernel,
21860 +#endif
21861 +
21862 };
21863
21864 EXPORT_SYMBOL_GPL(pv_time_ops);
21865 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
21866 index 299d493..2ccb0ee 100644
21867 --- a/arch/x86/kernel/pci-calgary_64.c
21868 +++ b/arch/x86/kernel/pci-calgary_64.c
21869 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
21870 tce_space = be64_to_cpu(readq(target));
21871 tce_space = tce_space & TAR_SW_BITS;
21872
21873 - tce_space = tce_space & (~specified_table_size);
21874 + tce_space = tce_space & (~(unsigned long)specified_table_size);
21875 info->tce_space = (u64 *)__va(tce_space);
21876 }
21877 }
21878 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
21879 index 35ccf75..7a15747 100644
21880 --- a/arch/x86/kernel/pci-iommu_table.c
21881 +++ b/arch/x86/kernel/pci-iommu_table.c
21882 @@ -2,7 +2,7 @@
21883 #include <asm/iommu_table.h>
21884 #include <linux/string.h>
21885 #include <linux/kallsyms.h>
21886 -
21887 +#include <linux/sched.h>
21888
21889 #define DEBUG 1
21890
21891 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
21892 index 6c483ba..d10ce2f 100644
21893 --- a/arch/x86/kernel/pci-swiotlb.c
21894 +++ b/arch/x86/kernel/pci-swiotlb.c
21895 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
21896 void *vaddr, dma_addr_t dma_addr,
21897 struct dma_attrs *attrs)
21898 {
21899 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
21900 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
21901 }
21902
21903 static struct dma_map_ops swiotlb_dma_ops = {
21904 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
21905 index 14ae100..752a4f6 100644
21906 --- a/arch/x86/kernel/process.c
21907 +++ b/arch/x86/kernel/process.c
21908 @@ -36,7 +36,8 @@
21909 * section. Since TSS's are completely CPU-local, we want them
21910 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
21911 */
21912 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
21913 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
21914 +EXPORT_SYMBOL(init_tss);
21915
21916 #ifdef CONFIG_X86_64
21917 static DEFINE_PER_CPU(unsigned char, is_idle);
21918 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
21919 task_xstate_cachep =
21920 kmem_cache_create("task_xstate", xstate_size,
21921 __alignof__(union thread_xstate),
21922 - SLAB_PANIC | SLAB_NOTRACK, NULL);
21923 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
21924 }
21925
21926 /*
21927 @@ -105,7 +106,7 @@ void exit_thread(void)
21928 unsigned long *bp = t->io_bitmap_ptr;
21929
21930 if (bp) {
21931 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
21932 + struct tss_struct *tss = init_tss + get_cpu();
21933
21934 t->io_bitmap_ptr = NULL;
21935 clear_thread_flag(TIF_IO_BITMAP);
21936 @@ -136,7 +137,7 @@ void show_regs_common(void)
21937 board = dmi_get_system_info(DMI_BOARD_NAME);
21938
21939 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
21940 - current->pid, current->comm, print_tainted(),
21941 + task_pid_nr(current), current->comm, print_tainted(),
21942 init_utsname()->release,
21943 (int)strcspn(init_utsname()->version, " "),
21944 init_utsname()->version,
21945 @@ -149,6 +150,9 @@ void flush_thread(void)
21946 {
21947 struct task_struct *tsk = current;
21948
21949 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
21950 + loadsegment(gs, 0);
21951 +#endif
21952 flush_ptrace_hw_breakpoint(tsk);
21953 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
21954 drop_init_fpu(tsk);
21955 @@ -295,7 +299,7 @@ static void __exit_idle(void)
21956 void exit_idle(void)
21957 {
21958 /* idle loop has pid 0 */
21959 - if (current->pid)
21960 + if (task_pid_nr(current))
21961 return;
21962 __exit_idle();
21963 }
21964 @@ -398,7 +402,7 @@ bool xen_set_default_idle(void)
21965 return ret;
21966 }
21967 #endif
21968 -void stop_this_cpu(void *dummy)
21969 +__noreturn void stop_this_cpu(void *dummy)
21970 {
21971 local_irq_disable();
21972 /*
21973 @@ -544,16 +548,37 @@ static int __init idle_setup(char *str)
21974 }
21975 early_param("idle", idle_setup);
21976
21977 -unsigned long arch_align_stack(unsigned long sp)
21978 +#ifdef CONFIG_PAX_RANDKSTACK
21979 +void pax_randomize_kstack(struct pt_regs *regs)
21980 {
21981 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
21982 - sp -= get_random_int() % 8192;
21983 - return sp & ~0xf;
21984 -}
21985 + struct thread_struct *thread = &current->thread;
21986 + unsigned long time;
21987
21988 -unsigned long arch_randomize_brk(struct mm_struct *mm)
21989 -{
21990 - unsigned long range_end = mm->brk + 0x02000000;
21991 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
21992 -}
21993 + if (!randomize_va_space)
21994 + return;
21995 +
21996 + if (v8086_mode(regs))
21997 + return;
21998
21999 + rdtscl(time);
22000 +
22001 + /* P4 seems to return a 0 LSB, ignore it */
22002 +#ifdef CONFIG_MPENTIUM4
22003 + time &= 0x3EUL;
22004 + time <<= 2;
22005 +#elif defined(CONFIG_X86_64)
22006 + time &= 0xFUL;
22007 + time <<= 4;
22008 +#else
22009 + time &= 0x1FUL;
22010 + time <<= 3;
22011 +#endif
22012 +
22013 + thread->sp0 ^= time;
22014 + load_sp0(init_tss + smp_processor_id(), thread);
22015 +
22016 +#ifdef CONFIG_X86_64
22017 + this_cpu_write(kernel_stack, thread->sp0);
22018 +#endif
22019 +}
22020 +#endif
22021 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22022 index b5a8905..d9cacac 100644
22023 --- a/arch/x86/kernel/process_32.c
22024 +++ b/arch/x86/kernel/process_32.c
22025 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22026 unsigned long thread_saved_pc(struct task_struct *tsk)
22027 {
22028 return ((unsigned long *)tsk->thread.sp)[3];
22029 +//XXX return tsk->thread.eip;
22030 }
22031
22032 void __show_regs(struct pt_regs *regs, int all)
22033 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22034 unsigned long sp;
22035 unsigned short ss, gs;
22036
22037 - if (user_mode_vm(regs)) {
22038 + if (user_mode(regs)) {
22039 sp = regs->sp;
22040 ss = regs->ss & 0xffff;
22041 - gs = get_user_gs(regs);
22042 } else {
22043 sp = kernel_stack_pointer(regs);
22044 savesegment(ss, ss);
22045 - savesegment(gs, gs);
22046 }
22047 + gs = get_user_gs(regs);
22048
22049 show_regs_common();
22050
22051 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22052 (u16)regs->cs, regs->ip, regs->flags,
22053 - smp_processor_id());
22054 + raw_smp_processor_id());
22055 print_symbol("EIP is at %s\n", regs->ip);
22056
22057 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22058 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22059 int copy_thread(unsigned long clone_flags, unsigned long sp,
22060 unsigned long arg, struct task_struct *p)
22061 {
22062 - struct pt_regs *childregs = task_pt_regs(p);
22063 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22064 struct task_struct *tsk;
22065 int err;
22066
22067 p->thread.sp = (unsigned long) childregs;
22068 p->thread.sp0 = (unsigned long) (childregs+1);
22069 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22070
22071 if (unlikely(p->flags & PF_KTHREAD)) {
22072 /* kernel thread */
22073 memset(childregs, 0, sizeof(struct pt_regs));
22074 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22075 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22076 - childregs->ds = __USER_DS;
22077 - childregs->es = __USER_DS;
22078 + savesegment(gs, childregs->gs);
22079 + childregs->ds = __KERNEL_DS;
22080 + childregs->es = __KERNEL_DS;
22081 childregs->fs = __KERNEL_PERCPU;
22082 childregs->bx = sp; /* function */
22083 childregs->bp = arg;
22084 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22085 struct thread_struct *prev = &prev_p->thread,
22086 *next = &next_p->thread;
22087 int cpu = smp_processor_id();
22088 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22089 + struct tss_struct *tss = init_tss + cpu;
22090 fpu_switch_t fpu;
22091
22092 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22093 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22094 */
22095 lazy_save_gs(prev->gs);
22096
22097 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22098 + __set_fs(task_thread_info(next_p)->addr_limit);
22099 +#endif
22100 +
22101 /*
22102 * Load the per-thread Thread-Local Storage descriptor.
22103 */
22104 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22105 */
22106 arch_end_context_switch(next_p);
22107
22108 + this_cpu_write(current_task, next_p);
22109 + this_cpu_write(current_tinfo, &next_p->tinfo);
22110 +
22111 /*
22112 * Restore %gs if needed (which is common)
22113 */
22114 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22115
22116 switch_fpu_finish(next_p, fpu);
22117
22118 - this_cpu_write(current_task, next_p);
22119 -
22120 return prev_p;
22121 }
22122
22123 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22124 } while (count++ < 16);
22125 return 0;
22126 }
22127 -
22128 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22129 index 0f49677..fcbf88c 100644
22130 --- a/arch/x86/kernel/process_64.c
22131 +++ b/arch/x86/kernel/process_64.c
22132 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22133 struct pt_regs *childregs;
22134 struct task_struct *me = current;
22135
22136 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22137 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22138 childregs = task_pt_regs(p);
22139 p->thread.sp = (unsigned long) childregs;
22140 p->thread.usersp = me->thread.usersp;
22141 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22142 set_tsk_thread_flag(p, TIF_FORK);
22143 p->fpu_counter = 0;
22144 p->thread.io_bitmap_ptr = NULL;
22145 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22146 struct thread_struct *prev = &prev_p->thread;
22147 struct thread_struct *next = &next_p->thread;
22148 int cpu = smp_processor_id();
22149 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22150 + struct tss_struct *tss = init_tss + cpu;
22151 unsigned fsindex, gsindex;
22152 fpu_switch_t fpu;
22153
22154 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22155 prev->usersp = this_cpu_read(old_rsp);
22156 this_cpu_write(old_rsp, next->usersp);
22157 this_cpu_write(current_task, next_p);
22158 + this_cpu_write(current_tinfo, &next_p->tinfo);
22159
22160 - this_cpu_write(kernel_stack,
22161 - (unsigned long)task_stack_page(next_p) +
22162 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22163 + this_cpu_write(kernel_stack, next->sp0);
22164
22165 /*
22166 * Now maybe reload the debug registers and handle I/O bitmaps
22167 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22168 if (!p || p == current || p->state == TASK_RUNNING)
22169 return 0;
22170 stack = (unsigned long)task_stack_page(p);
22171 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22172 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22173 return 0;
22174 fp = *(u64 *)(p->thread.sp);
22175 do {
22176 - if (fp < (unsigned long)stack ||
22177 - fp >= (unsigned long)stack+THREAD_SIZE)
22178 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22179 return 0;
22180 ip = *(u64 *)(fp+8);
22181 if (!in_sched_functions(ip))
22182 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22183 index 29a8120..a50b5ee 100644
22184 --- a/arch/x86/kernel/ptrace.c
22185 +++ b/arch/x86/kernel/ptrace.c
22186 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22187 {
22188 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22189 unsigned long sp = (unsigned long)&regs->sp;
22190 - struct thread_info *tinfo;
22191
22192 - if (context == (sp & ~(THREAD_SIZE - 1)))
22193 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22194 return sp;
22195
22196 - tinfo = (struct thread_info *)context;
22197 - if (tinfo->previous_esp)
22198 - return tinfo->previous_esp;
22199 + sp = *(unsigned long *)context;
22200 + if (sp)
22201 + return sp;
22202
22203 return (unsigned long)regs;
22204 }
22205 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22206 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22207 {
22208 int i;
22209 - int dr7 = 0;
22210 + unsigned long dr7 = 0;
22211 struct arch_hw_breakpoint *info;
22212
22213 for (i = 0; i < HBP_NUM; i++) {
22214 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22215 unsigned long addr, unsigned long data)
22216 {
22217 int ret;
22218 - unsigned long __user *datap = (unsigned long __user *)data;
22219 + unsigned long __user *datap = (__force unsigned long __user *)data;
22220
22221 switch (request) {
22222 /* read the word at location addr in the USER area. */
22223 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22224 if ((int) addr < 0)
22225 return -EIO;
22226 ret = do_get_thread_area(child, addr,
22227 - (struct user_desc __user *)data);
22228 + (__force struct user_desc __user *) data);
22229 break;
22230
22231 case PTRACE_SET_THREAD_AREA:
22232 if ((int) addr < 0)
22233 return -EIO;
22234 ret = do_set_thread_area(child, addr,
22235 - (struct user_desc __user *)data, 0);
22236 + (__force struct user_desc __user *) data, 0);
22237 break;
22238 #endif
22239
22240 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22241
22242 #ifdef CONFIG_X86_64
22243
22244 -static struct user_regset x86_64_regsets[] __read_mostly = {
22245 +static user_regset_no_const x86_64_regsets[] __read_only = {
22246 [REGSET_GENERAL] = {
22247 .core_note_type = NT_PRSTATUS,
22248 .n = sizeof(struct user_regs_struct) / sizeof(long),
22249 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22250 #endif /* CONFIG_X86_64 */
22251
22252 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22253 -static struct user_regset x86_32_regsets[] __read_mostly = {
22254 +static user_regset_no_const x86_32_regsets[] __read_only = {
22255 [REGSET_GENERAL] = {
22256 .core_note_type = NT_PRSTATUS,
22257 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22258 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22259 */
22260 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22261
22262 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22263 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22264 {
22265 #ifdef CONFIG_X86_64
22266 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22267 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22268 memset(info, 0, sizeof(*info));
22269 info->si_signo = SIGTRAP;
22270 info->si_code = si_code;
22271 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22272 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22273 }
22274
22275 void user_single_step_siginfo(struct task_struct *tsk,
22276 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22277 # define IS_IA32 0
22278 #endif
22279
22280 +#ifdef CONFIG_GRKERNSEC_SETXID
22281 +extern void gr_delayed_cred_worker(void);
22282 +#endif
22283 +
22284 /*
22285 * We must return the syscall number to actually look up in the table.
22286 * This can be -1L to skip running any syscall at all.
22287 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22288
22289 user_exit();
22290
22291 +#ifdef CONFIG_GRKERNSEC_SETXID
22292 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22293 + gr_delayed_cred_worker();
22294 +#endif
22295 +
22296 /*
22297 * If we stepped into a sysenter/syscall insn, it trapped in
22298 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22299 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22300 */
22301 user_exit();
22302
22303 +#ifdef CONFIG_GRKERNSEC_SETXID
22304 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22305 + gr_delayed_cred_worker();
22306 +#endif
22307 +
22308 audit_syscall_exit(regs);
22309
22310 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22311 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22312 index 2cb9470..ff1fd80 100644
22313 --- a/arch/x86/kernel/pvclock.c
22314 +++ b/arch/x86/kernel/pvclock.c
22315 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22316 return pv_tsc_khz;
22317 }
22318
22319 -static atomic64_t last_value = ATOMIC64_INIT(0);
22320 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22321
22322 void pvclock_resume(void)
22323 {
22324 - atomic64_set(&last_value, 0);
22325 + atomic64_set_unchecked(&last_value, 0);
22326 }
22327
22328 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22329 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22330 * updating at the same time, and one of them could be slightly behind,
22331 * making the assumption that last_value always go forward fail to hold.
22332 */
22333 - last = atomic64_read(&last_value);
22334 + last = atomic64_read_unchecked(&last_value);
22335 do {
22336 if (ret < last)
22337 return last;
22338 - last = atomic64_cmpxchg(&last_value, last, ret);
22339 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22340 } while (unlikely(last != ret));
22341
22342 return ret;
22343 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22344 index 76fa1e9..abf09ea 100644
22345 --- a/arch/x86/kernel/reboot.c
22346 +++ b/arch/x86/kernel/reboot.c
22347 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22348 EXPORT_SYMBOL(pm_power_off);
22349
22350 static const struct desc_ptr no_idt = {};
22351 -static int reboot_mode;
22352 +static unsigned short reboot_mode;
22353 enum reboot_type reboot_type = BOOT_ACPI;
22354 int reboot_force;
22355
22356 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22357
22358 void __noreturn machine_real_restart(unsigned int type)
22359 {
22360 +
22361 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22362 + struct desc_struct *gdt;
22363 +#endif
22364 +
22365 local_irq_disable();
22366
22367 /*
22368 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22369
22370 /* Jump to the identity-mapped low memory code */
22371 #ifdef CONFIG_X86_32
22372 - asm volatile("jmpl *%0" : :
22373 +
22374 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22375 + gdt = get_cpu_gdt_table(smp_processor_id());
22376 + pax_open_kernel();
22377 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22378 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22379 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22380 + loadsegment(ds, __KERNEL_DS);
22381 + loadsegment(es, __KERNEL_DS);
22382 + loadsegment(ss, __KERNEL_DS);
22383 +#endif
22384 +#ifdef CONFIG_PAX_KERNEXEC
22385 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22386 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22387 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22388 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22389 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22390 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22391 +#endif
22392 + pax_close_kernel();
22393 +#endif
22394 +
22395 + asm volatile("ljmpl *%0" : :
22396 "rm" (real_mode_header->machine_real_restart_asm),
22397 "a" (type));
22398 #else
22399 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22400 * try to force a triple fault and then cycle between hitting the keyboard
22401 * controller and doing that
22402 */
22403 -static void native_machine_emergency_restart(void)
22404 +static void __noreturn native_machine_emergency_restart(void)
22405 {
22406 int i;
22407 int attempt = 0;
22408 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22409 #endif
22410 }
22411
22412 -static void __machine_emergency_restart(int emergency)
22413 +static void __noreturn __machine_emergency_restart(int emergency)
22414 {
22415 reboot_emergency = emergency;
22416 machine_ops.emergency_restart();
22417 }
22418
22419 -static void native_machine_restart(char *__unused)
22420 +static void __noreturn native_machine_restart(char *__unused)
22421 {
22422 pr_notice("machine restart\n");
22423
22424 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22425 __machine_emergency_restart(0);
22426 }
22427
22428 -static void native_machine_halt(void)
22429 +static void __noreturn native_machine_halt(void)
22430 {
22431 /* Stop other cpus and apics */
22432 machine_shutdown();
22433 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22434 stop_this_cpu(NULL);
22435 }
22436
22437 -static void native_machine_power_off(void)
22438 +static void __noreturn native_machine_power_off(void)
22439 {
22440 if (pm_power_off) {
22441 if (!reboot_force)
22442 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22443 }
22444 /* A fallback in case there is no PM info available */
22445 tboot_shutdown(TB_SHUTDOWN_HALT);
22446 + unreachable();
22447 }
22448
22449 -struct machine_ops machine_ops = {
22450 +struct machine_ops machine_ops __read_only = {
22451 .power_off = native_machine_power_off,
22452 .shutdown = native_machine_shutdown,
22453 .emergency_restart = native_machine_emergency_restart,
22454 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22455 index 7a6f3b3..bed145d7 100644
22456 --- a/arch/x86/kernel/relocate_kernel_64.S
22457 +++ b/arch/x86/kernel/relocate_kernel_64.S
22458 @@ -11,6 +11,7 @@
22459 #include <asm/kexec.h>
22460 #include <asm/processor-flags.h>
22461 #include <asm/pgtable_types.h>
22462 +#include <asm/alternative-asm.h>
22463
22464 /*
22465 * Must be relocatable PIC code callable as a C function
22466 @@ -160,13 +161,14 @@ identity_mapped:
22467 xorq %rbp, %rbp
22468 xorq %r8, %r8
22469 xorq %r9, %r9
22470 - xorq %r10, %r9
22471 + xorq %r10, %r10
22472 xorq %r11, %r11
22473 xorq %r12, %r12
22474 xorq %r13, %r13
22475 xorq %r14, %r14
22476 xorq %r15, %r15
22477
22478 + pax_force_retaddr 0, 1
22479 ret
22480
22481 1:
22482 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22483 index fae9134..b7d4a57 100644
22484 --- a/arch/x86/kernel/setup.c
22485 +++ b/arch/x86/kernel/setup.c
22486 @@ -111,6 +111,7 @@
22487 #include <asm/mce.h>
22488 #include <asm/alternative.h>
22489 #include <asm/prom.h>
22490 +#include <asm/boot.h>
22491
22492 /*
22493 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22494 @@ -447,7 +448,7 @@ static void __init parse_setup_data(void)
22495
22496 switch (data->type) {
22497 case SETUP_E820_EXT:
22498 - parse_e820_ext(data);
22499 + parse_e820_ext((struct setup_data __force_kernel *)data);
22500 break;
22501 case SETUP_DTB:
22502 add_dtb(pa_data);
22503 @@ -774,7 +775,7 @@ static void __init trim_bios_range(void)
22504 * area (640->1Mb) as ram even though it is not.
22505 * take them out.
22506 */
22507 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22508 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22509
22510 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22511 }
22512 @@ -844,8 +845,12 @@ static void __init trim_low_memory_range(void)
22513
22514 void __init setup_arch(char **cmdline_p)
22515 {
22516 +#ifdef CONFIG_X86_32
22517 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - ____LOAD_PHYSICAL_ADDR);
22518 +#else
22519 memblock_reserve(__pa_symbol(_text),
22520 (unsigned long)__bss_stop - (unsigned long)_text);
22521 +#endif
22522
22523 early_reserve_initrd();
22524
22525 @@ -937,14 +942,14 @@ void __init setup_arch(char **cmdline_p)
22526
22527 if (!boot_params.hdr.root_flags)
22528 root_mountflags &= ~MS_RDONLY;
22529 - init_mm.start_code = (unsigned long) _text;
22530 - init_mm.end_code = (unsigned long) _etext;
22531 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22532 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22533 init_mm.end_data = (unsigned long) _edata;
22534 init_mm.brk = _brk_end;
22535
22536 - code_resource.start = __pa_symbol(_text);
22537 - code_resource.end = __pa_symbol(_etext)-1;
22538 - data_resource.start = __pa_symbol(_etext);
22539 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22540 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22541 + data_resource.start = __pa_symbol(_sdata);
22542 data_resource.end = __pa_symbol(_edata)-1;
22543 bss_resource.start = __pa_symbol(__bss_start);
22544 bss_resource.end = __pa_symbol(__bss_stop)-1;
22545 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22546 index 5cdff03..80fa283 100644
22547 --- a/arch/x86/kernel/setup_percpu.c
22548 +++ b/arch/x86/kernel/setup_percpu.c
22549 @@ -21,19 +21,17 @@
22550 #include <asm/cpu.h>
22551 #include <asm/stackprotector.h>
22552
22553 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22554 +#ifdef CONFIG_SMP
22555 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22556 EXPORT_PER_CPU_SYMBOL(cpu_number);
22557 +#endif
22558
22559 -#ifdef CONFIG_X86_64
22560 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22561 -#else
22562 -#define BOOT_PERCPU_OFFSET 0
22563 -#endif
22564
22565 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22566 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22567
22568 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22569 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22570 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22571 };
22572 EXPORT_SYMBOL(__per_cpu_offset);
22573 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22574 {
22575 #ifdef CONFIG_NEED_MULTIPLE_NODES
22576 pg_data_t *last = NULL;
22577 - unsigned int cpu;
22578 + int cpu;
22579
22580 for_each_possible_cpu(cpu) {
22581 int node = early_cpu_to_node(cpu);
22582 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22583 {
22584 #ifdef CONFIG_X86_32
22585 struct desc_struct gdt;
22586 + unsigned long base = per_cpu_offset(cpu);
22587
22588 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22589 - 0x2 | DESCTYPE_S, 0x8);
22590 - gdt.s = 1;
22591 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22592 + 0x83 | DESCTYPE_S, 0xC);
22593 write_gdt_entry(get_cpu_gdt_table(cpu),
22594 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22595 #endif
22596 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22597 /* alrighty, percpu areas up and running */
22598 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22599 for_each_possible_cpu(cpu) {
22600 +#ifdef CONFIG_CC_STACKPROTECTOR
22601 +#ifdef CONFIG_X86_32
22602 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22603 +#endif
22604 +#endif
22605 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22606 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22607 per_cpu(cpu_number, cpu) = cpu;
22608 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22609 */
22610 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22611 #endif
22612 +#ifdef CONFIG_CC_STACKPROTECTOR
22613 +#ifdef CONFIG_X86_32
22614 + if (!cpu)
22615 + per_cpu(stack_canary.canary, cpu) = canary;
22616 +#endif
22617 +#endif
22618 /*
22619 * Up to this point, the boot CPU has been using .init.data
22620 * area. Reload any changed state for the boot CPU.
22621 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22622 index 6956299..f20beae 100644
22623 --- a/arch/x86/kernel/signal.c
22624 +++ b/arch/x86/kernel/signal.c
22625 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22626 * Align the stack pointer according to the i386 ABI,
22627 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22628 */
22629 - sp = ((sp + 4) & -16ul) - 4;
22630 + sp = ((sp - 12) & -16ul) - 4;
22631 #else /* !CONFIG_X86_32 */
22632 sp = round_down(sp, 16) - 8;
22633 #endif
22634 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22635 }
22636
22637 if (current->mm->context.vdso)
22638 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22639 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22640 else
22641 - restorer = &frame->retcode;
22642 + restorer = (void __user *)&frame->retcode;
22643 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22644 restorer = ksig->ka.sa.sa_restorer;
22645
22646 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22647 * reasons and because gdb uses it as a signature to notice
22648 * signal handler stack frames.
22649 */
22650 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22651 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22652
22653 if (err)
22654 return -EFAULT;
22655 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22656 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22657
22658 /* Set up to return from userspace. */
22659 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22660 + if (current->mm->context.vdso)
22661 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22662 + else
22663 + restorer = (void __user *)&frame->retcode;
22664 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22665 restorer = ksig->ka.sa.sa_restorer;
22666 put_user_ex(restorer, &frame->pretcode);
22667 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22668 * reasons and because gdb uses it as a signature to notice
22669 * signal handler stack frames.
22670 */
22671 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22672 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22673 } put_user_catch(err);
22674
22675 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22676 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22677 {
22678 int usig = signr_convert(ksig->sig);
22679 sigset_t *set = sigmask_to_save();
22680 - compat_sigset_t *cset = (compat_sigset_t *) set;
22681 + sigset_t sigcopy;
22682 + compat_sigset_t *cset;
22683 +
22684 + sigcopy = *set;
22685 +
22686 + cset = (compat_sigset_t *) &sigcopy;
22687
22688 /* Set up the stack frame */
22689 if (is_ia32_frame()) {
22690 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22691 } else if (is_x32_frame()) {
22692 return x32_setup_rt_frame(ksig, cset, regs);
22693 } else {
22694 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
22695 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
22696 }
22697 }
22698
22699 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22700 index 48d2b7d..90d328a 100644
22701 --- a/arch/x86/kernel/smp.c
22702 +++ b/arch/x86/kernel/smp.c
22703 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22704
22705 __setup("nonmi_ipi", nonmi_ipi_setup);
22706
22707 -struct smp_ops smp_ops = {
22708 +struct smp_ops smp_ops __read_only = {
22709 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22710 .smp_prepare_cpus = native_smp_prepare_cpus,
22711 .smp_cpus_done = native_smp_cpus_done,
22712 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22713 index 9f190a2..90a0688 100644
22714 --- a/arch/x86/kernel/smpboot.c
22715 +++ b/arch/x86/kernel/smpboot.c
22716 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22717 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22718 (THREAD_SIZE + task_stack_page(idle))) - 1);
22719 per_cpu(current_task, cpu) = idle;
22720 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22721
22722 #ifdef CONFIG_X86_32
22723 /* Stack for startup_32 can be just as for start_secondary onwards */
22724 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22725 #else
22726 clear_tsk_thread_flag(idle, TIF_FORK);
22727 initial_gs = per_cpu_offset(cpu);
22728 - per_cpu(kernel_stack, cpu) =
22729 - (unsigned long)task_stack_page(idle) -
22730 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22731 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22732 #endif
22733 +
22734 + pax_open_kernel();
22735 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22736 + pax_close_kernel();
22737 +
22738 initial_code = (unsigned long)start_secondary;
22739 stack_start = idle->thread.sp;
22740
22741 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22742 /* the FPU context is blank, nobody can own it */
22743 __cpu_disable_lazy_restore(cpu);
22744
22745 +#ifdef CONFIG_PAX_PER_CPU_PGD
22746 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22747 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22748 + KERNEL_PGD_PTRS);
22749 +#endif
22750 +
22751 + /* the FPU context is blank, nobody can own it */
22752 + __cpu_disable_lazy_restore(cpu);
22753 +
22754 err = do_boot_cpu(apicid, cpu, tidle);
22755 if (err) {
22756 pr_debug("do_boot_cpu failed %d\n", err);
22757 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22758 index 9b4d51d..5d28b58 100644
22759 --- a/arch/x86/kernel/step.c
22760 +++ b/arch/x86/kernel/step.c
22761 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22762 struct desc_struct *desc;
22763 unsigned long base;
22764
22765 - seg &= ~7UL;
22766 + seg >>= 3;
22767
22768 mutex_lock(&child->mm->context.lock);
22769 - if (unlikely((seg >> 3) >= child->mm->context.size))
22770 + if (unlikely(seg >= child->mm->context.size))
22771 addr = -1L; /* bogus selector, access would fault */
22772 else {
22773 desc = child->mm->context.ldt + seg;
22774 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22775 addr += base;
22776 }
22777 mutex_unlock(&child->mm->context.lock);
22778 - }
22779 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22780 + addr = ktla_ktva(addr);
22781
22782 return addr;
22783 }
22784 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22785 unsigned char opcode[15];
22786 unsigned long addr = convert_ip_to_linear(child, regs);
22787
22788 + if (addr == -EINVAL)
22789 + return 0;
22790 +
22791 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22792 for (i = 0; i < copied; i++) {
22793 switch (opcode[i]) {
22794 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22795 new file mode 100644
22796 index 0000000..207bec6
22797 --- /dev/null
22798 +++ b/arch/x86/kernel/sys_i386_32.c
22799 @@ -0,0 +1,250 @@
22800 +/*
22801 + * This file contains various random system calls that
22802 + * have a non-standard calling sequence on the Linux/i386
22803 + * platform.
22804 + */
22805 +
22806 +#include <linux/errno.h>
22807 +#include <linux/sched.h>
22808 +#include <linux/mm.h>
22809 +#include <linux/fs.h>
22810 +#include <linux/smp.h>
22811 +#include <linux/sem.h>
22812 +#include <linux/msg.h>
22813 +#include <linux/shm.h>
22814 +#include <linux/stat.h>
22815 +#include <linux/syscalls.h>
22816 +#include <linux/mman.h>
22817 +#include <linux/file.h>
22818 +#include <linux/utsname.h>
22819 +#include <linux/ipc.h>
22820 +
22821 +#include <linux/uaccess.h>
22822 +#include <linux/unistd.h>
22823 +
22824 +#include <asm/syscalls.h>
22825 +
22826 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22827 +{
22828 + unsigned long pax_task_size = TASK_SIZE;
22829 +
22830 +#ifdef CONFIG_PAX_SEGMEXEC
22831 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22832 + pax_task_size = SEGMEXEC_TASK_SIZE;
22833 +#endif
22834 +
22835 + if (flags & MAP_FIXED)
22836 + if (len > pax_task_size || addr > pax_task_size - len)
22837 + return -EINVAL;
22838 +
22839 + return 0;
22840 +}
22841 +
22842 +unsigned long
22843 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22844 + unsigned long len, unsigned long pgoff, unsigned long flags)
22845 +{
22846 + struct mm_struct *mm = current->mm;
22847 + struct vm_area_struct *vma;
22848 + unsigned long start_addr, pax_task_size = TASK_SIZE;
22849 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22850 +
22851 +#ifdef CONFIG_PAX_SEGMEXEC
22852 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22853 + pax_task_size = SEGMEXEC_TASK_SIZE;
22854 +#endif
22855 +
22856 + pax_task_size -= PAGE_SIZE;
22857 +
22858 + if (len > pax_task_size)
22859 + return -ENOMEM;
22860 +
22861 + if (flags & MAP_FIXED)
22862 + return addr;
22863 +
22864 +#ifdef CONFIG_PAX_RANDMMAP
22865 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22866 +#endif
22867 +
22868 + if (addr) {
22869 + addr = PAGE_ALIGN(addr);
22870 + if (pax_task_size - len >= addr) {
22871 + vma = find_vma(mm, addr);
22872 + if (check_heap_stack_gap(vma, addr, len, offset))
22873 + return addr;
22874 + }
22875 + }
22876 + if (len > mm->cached_hole_size) {
22877 + start_addr = addr = mm->free_area_cache;
22878 + } else {
22879 + start_addr = addr = mm->mmap_base;
22880 + mm->cached_hole_size = 0;
22881 + }
22882 +
22883 +#ifdef CONFIG_PAX_PAGEEXEC
22884 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
22885 + start_addr = 0x00110000UL;
22886 +
22887 +#ifdef CONFIG_PAX_RANDMMAP
22888 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22889 + start_addr += mm->delta_mmap & 0x03FFF000UL;
22890 +#endif
22891 +
22892 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
22893 + start_addr = addr = mm->mmap_base;
22894 + else
22895 + addr = start_addr;
22896 + }
22897 +#endif
22898 +
22899 +full_search:
22900 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
22901 + /* At this point: (!vma || addr < vma->vm_end). */
22902 + if (pax_task_size - len < addr) {
22903 + /*
22904 + * Start a new search - just in case we missed
22905 + * some holes.
22906 + */
22907 + if (start_addr != mm->mmap_base) {
22908 + start_addr = addr = mm->mmap_base;
22909 + mm->cached_hole_size = 0;
22910 + goto full_search;
22911 + }
22912 + return -ENOMEM;
22913 + }
22914 + if (check_heap_stack_gap(vma, addr, len, offset))
22915 + break;
22916 + if (addr + mm->cached_hole_size < vma->vm_start)
22917 + mm->cached_hole_size = vma->vm_start - addr;
22918 + addr = vma->vm_end;
22919 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
22920 + start_addr = addr = mm->mmap_base;
22921 + mm->cached_hole_size = 0;
22922 + goto full_search;
22923 + }
22924 + }
22925 +
22926 + /*
22927 + * Remember the place where we stopped the search:
22928 + */
22929 + mm->free_area_cache = addr + len;
22930 + return addr;
22931 +}
22932 +
22933 +unsigned long
22934 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
22935 + const unsigned long len, const unsigned long pgoff,
22936 + const unsigned long flags)
22937 +{
22938 + struct vm_area_struct *vma;
22939 + struct mm_struct *mm = current->mm;
22940 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
22941 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22942 +
22943 +#ifdef CONFIG_PAX_SEGMEXEC
22944 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22945 + pax_task_size = SEGMEXEC_TASK_SIZE;
22946 +#endif
22947 +
22948 + pax_task_size -= PAGE_SIZE;
22949 +
22950 + /* requested length too big for entire address space */
22951 + if (len > pax_task_size)
22952 + return -ENOMEM;
22953 +
22954 + if (flags & MAP_FIXED)
22955 + return addr;
22956 +
22957 +#ifdef CONFIG_PAX_PAGEEXEC
22958 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
22959 + goto bottomup;
22960 +#endif
22961 +
22962 +#ifdef CONFIG_PAX_RANDMMAP
22963 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22964 +#endif
22965 +
22966 + /* requesting a specific address */
22967 + if (addr) {
22968 + addr = PAGE_ALIGN(addr);
22969 + if (pax_task_size - len >= addr) {
22970 + vma = find_vma(mm, addr);
22971 + if (check_heap_stack_gap(vma, addr, len, offset))
22972 + return addr;
22973 + }
22974 + }
22975 +
22976 + /* check if free_area_cache is useful for us */
22977 + if (len <= mm->cached_hole_size) {
22978 + mm->cached_hole_size = 0;
22979 + mm->free_area_cache = mm->mmap_base;
22980 + }
22981 +
22982 + /* either no address requested or can't fit in requested address hole */
22983 + addr = mm->free_area_cache;
22984 +
22985 + /* make sure it can fit in the remaining address space */
22986 + if (addr > len) {
22987 + vma = find_vma(mm, addr-len);
22988 + if (check_heap_stack_gap(vma, addr - len, len, offset))
22989 + /* remember the address as a hint for next time */
22990 + return (mm->free_area_cache = addr-len);
22991 + }
22992 +
22993 + if (mm->mmap_base < len)
22994 + goto bottomup;
22995 +
22996 + addr = mm->mmap_base-len;
22997 +
22998 + do {
22999 + /*
23000 + * Lookup failure means no vma is above this address,
23001 + * else if new region fits below vma->vm_start,
23002 + * return with success:
23003 + */
23004 + vma = find_vma(mm, addr);
23005 + if (check_heap_stack_gap(vma, addr, len, offset))
23006 + /* remember the address as a hint for next time */
23007 + return (mm->free_area_cache = addr);
23008 +
23009 + /* remember the largest hole we saw so far */
23010 + if (addr + mm->cached_hole_size < vma->vm_start)
23011 + mm->cached_hole_size = vma->vm_start - addr;
23012 +
23013 + /* try just below the current vma->vm_start */
23014 + addr = skip_heap_stack_gap(vma, len, offset);
23015 + } while (!IS_ERR_VALUE(addr));
23016 +
23017 +bottomup:
23018 + /*
23019 + * A failed mmap() very likely causes application failure,
23020 + * so fall back to the bottom-up function here. This scenario
23021 + * can happen with large stack limits and large mmap()
23022 + * allocations.
23023 + */
23024 +
23025 +#ifdef CONFIG_PAX_SEGMEXEC
23026 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23027 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23028 + else
23029 +#endif
23030 +
23031 + mm->mmap_base = TASK_UNMAPPED_BASE;
23032 +
23033 +#ifdef CONFIG_PAX_RANDMMAP
23034 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23035 + mm->mmap_base += mm->delta_mmap;
23036 +#endif
23037 +
23038 + mm->free_area_cache = mm->mmap_base;
23039 + mm->cached_hole_size = ~0UL;
23040 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23041 + /*
23042 + * Restore the topdown base:
23043 + */
23044 + mm->mmap_base = base;
23045 + mm->free_area_cache = base;
23046 + mm->cached_hole_size = ~0UL;
23047 +
23048 + return addr;
23049 +}
23050 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23051 index dbded5a..ace2781 100644
23052 --- a/arch/x86/kernel/sys_x86_64.c
23053 +++ b/arch/x86/kernel/sys_x86_64.c
23054 @@ -81,8 +81,8 @@ out:
23055 return error;
23056 }
23057
23058 -static void find_start_end(unsigned long flags, unsigned long *begin,
23059 - unsigned long *end)
23060 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23061 + unsigned long *begin, unsigned long *end)
23062 {
23063 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23064 unsigned long new_begin;
23065 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23066 *begin = new_begin;
23067 }
23068 } else {
23069 - *begin = TASK_UNMAPPED_BASE;
23070 + *begin = mm->mmap_base;
23071 *end = TASK_SIZE;
23072 }
23073 }
23074 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23075 struct vm_area_struct *vma;
23076 struct vm_unmapped_area_info info;
23077 unsigned long begin, end;
23078 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23079
23080 if (flags & MAP_FIXED)
23081 return addr;
23082
23083 - find_start_end(flags, &begin, &end);
23084 + find_start_end(mm, flags, &begin, &end);
23085
23086 if (len > end)
23087 return -ENOMEM;
23088
23089 +#ifdef CONFIG_PAX_RANDMMAP
23090 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23091 +#endif
23092 +
23093 if (addr) {
23094 addr = PAGE_ALIGN(addr);
23095 vma = find_vma(mm, addr);
23096 - if (end - len >= addr &&
23097 - (!vma || addr + len <= vma->vm_start))
23098 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23099 return addr;
23100 }
23101
23102 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23103 info.high_limit = end;
23104 info.align_mask = filp ? get_align_mask() : 0;
23105 info.align_offset = pgoff << PAGE_SHIFT;
23106 + info.threadstack_offset = offset;
23107 return vm_unmapped_area(&info);
23108 }
23109
23110 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23111 struct mm_struct *mm = current->mm;
23112 unsigned long addr = addr0;
23113 struct vm_unmapped_area_info info;
23114 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23115
23116 /* requested length too big for entire address space */
23117 if (len > TASK_SIZE)
23118 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23119 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23120 goto bottomup;
23121
23122 +#ifdef CONFIG_PAX_RANDMMAP
23123 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23124 +#endif
23125 +
23126 /* requesting a specific address */
23127 if (addr) {
23128 addr = PAGE_ALIGN(addr);
23129 vma = find_vma(mm, addr);
23130 - if (TASK_SIZE - len >= addr &&
23131 - (!vma || addr + len <= vma->vm_start))
23132 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23133 return addr;
23134 }
23135
23136 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23137 info.high_limit = mm->mmap_base;
23138 info.align_mask = filp ? get_align_mask() : 0;
23139 info.align_offset = pgoff << PAGE_SHIFT;
23140 + info.threadstack_offset = offset;
23141 addr = vm_unmapped_area(&info);
23142 if (!(addr & ~PAGE_MASK))
23143 return addr;
23144 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23145 index f84fe00..f41d9f1 100644
23146 --- a/arch/x86/kernel/tboot.c
23147 +++ b/arch/x86/kernel/tboot.c
23148 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23149
23150 void tboot_shutdown(u32 shutdown_type)
23151 {
23152 - void (*shutdown)(void);
23153 + void (* __noreturn shutdown)(void);
23154
23155 if (!tboot_enabled())
23156 return;
23157 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23158
23159 switch_to_tboot_pt();
23160
23161 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23162 + shutdown = (void *)tboot->shutdown_entry;
23163 shutdown();
23164
23165 /* should not reach here */
23166 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23167 return 0;
23168 }
23169
23170 -static atomic_t ap_wfs_count;
23171 +static atomic_unchecked_t ap_wfs_count;
23172
23173 static int tboot_wait_for_aps(int num_aps)
23174 {
23175 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23176 {
23177 switch (action) {
23178 case CPU_DYING:
23179 - atomic_inc(&ap_wfs_count);
23180 + atomic_inc_unchecked(&ap_wfs_count);
23181 if (num_online_cpus() == 1)
23182 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23183 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23184 return NOTIFY_BAD;
23185 break;
23186 }
23187 return NOTIFY_OK;
23188 }
23189
23190 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23191 +static struct notifier_block tboot_cpu_notifier =
23192 {
23193 .notifier_call = tboot_cpu_callback,
23194 };
23195 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23196
23197 tboot_create_trampoline();
23198
23199 - atomic_set(&ap_wfs_count, 0);
23200 + atomic_set_unchecked(&ap_wfs_count, 0);
23201 register_hotcpu_notifier(&tboot_cpu_notifier);
23202
23203 acpi_os_set_prepare_sleep(&tboot_sleep);
23204 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23205 index 24d3c91..d06b473 100644
23206 --- a/arch/x86/kernel/time.c
23207 +++ b/arch/x86/kernel/time.c
23208 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23209 {
23210 unsigned long pc = instruction_pointer(regs);
23211
23212 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23213 + if (!user_mode(regs) && in_lock_functions(pc)) {
23214 #ifdef CONFIG_FRAME_POINTER
23215 - return *(unsigned long *)(regs->bp + sizeof(long));
23216 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23217 #else
23218 unsigned long *sp =
23219 (unsigned long *)kernel_stack_pointer(regs);
23220 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23221 * or above a saved flags. Eflags has bits 22-31 zero,
23222 * kernel addresses don't.
23223 */
23224 +
23225 +#ifdef CONFIG_PAX_KERNEXEC
23226 + return ktla_ktva(sp[0]);
23227 +#else
23228 if (sp[0] >> 22)
23229 return sp[0];
23230 if (sp[1] >> 22)
23231 return sp[1];
23232 #endif
23233 +
23234 +#endif
23235 }
23236 return pc;
23237 }
23238 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23239 index 9d9d2f9..cad418a 100644
23240 --- a/arch/x86/kernel/tls.c
23241 +++ b/arch/x86/kernel/tls.c
23242 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23243 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23244 return -EINVAL;
23245
23246 +#ifdef CONFIG_PAX_SEGMEXEC
23247 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23248 + return -EINVAL;
23249 +#endif
23250 +
23251 set_tls_desc(p, idx, &info, 1);
23252
23253 return 0;
23254 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23255
23256 if (kbuf)
23257 info = kbuf;
23258 - else if (__copy_from_user(infobuf, ubuf, count))
23259 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23260 return -EFAULT;
23261 else
23262 info = infobuf;
23263 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23264 index 68bda7a..3ec7bb7 100644
23265 --- a/arch/x86/kernel/traps.c
23266 +++ b/arch/x86/kernel/traps.c
23267 @@ -68,12 +68,6 @@
23268 #include <asm/setup.h>
23269
23270 asmlinkage int system_call(void);
23271 -
23272 -/*
23273 - * The IDT has to be page-aligned to simplify the Pentium
23274 - * F0 0F bug workaround.
23275 - */
23276 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23277 #endif
23278
23279 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23280 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23281 }
23282
23283 static int __kprobes
23284 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23285 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23286 struct pt_regs *regs, long error_code)
23287 {
23288 #ifdef CONFIG_X86_32
23289 - if (regs->flags & X86_VM_MASK) {
23290 + if (v8086_mode(regs)) {
23291 /*
23292 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23293 * On nmi (interrupt 2), do_trap should not be called.
23294 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23295 return -1;
23296 }
23297 #endif
23298 - if (!user_mode(regs)) {
23299 + if (!user_mode_novm(regs)) {
23300 if (!fixup_exception(regs)) {
23301 tsk->thread.error_code = error_code;
23302 tsk->thread.trap_nr = trapnr;
23303 +
23304 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23305 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23306 + str = "PAX: suspicious stack segment fault";
23307 +#endif
23308 +
23309 die(str, regs, error_code);
23310 }
23311 +
23312 +#ifdef CONFIG_PAX_REFCOUNT
23313 + if (trapnr == 4)
23314 + pax_report_refcount_overflow(regs);
23315 +#endif
23316 +
23317 return 0;
23318 }
23319
23320 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23321 }
23322
23323 static void __kprobes
23324 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23325 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23326 long error_code, siginfo_t *info)
23327 {
23328 struct task_struct *tsk = current;
23329 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23330 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23331 printk_ratelimit()) {
23332 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23333 - tsk->comm, tsk->pid, str,
23334 + tsk->comm, task_pid_nr(tsk), str,
23335 regs->ip, regs->sp, error_code);
23336 print_vma_addr(" in ", regs->ip);
23337 pr_cont("\n");
23338 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23339 conditional_sti(regs);
23340
23341 #ifdef CONFIG_X86_32
23342 - if (regs->flags & X86_VM_MASK) {
23343 + if (v8086_mode(regs)) {
23344 local_irq_enable();
23345 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23346 goto exit;
23347 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23348 #endif
23349
23350 tsk = current;
23351 - if (!user_mode(regs)) {
23352 + if (!user_mode_novm(regs)) {
23353 if (fixup_exception(regs))
23354 goto exit;
23355
23356 tsk->thread.error_code = error_code;
23357 tsk->thread.trap_nr = X86_TRAP_GP;
23358 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23359 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23360 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23361 +
23362 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23363 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23364 + die("PAX: suspicious general protection fault", regs, error_code);
23365 + else
23366 +#endif
23367 +
23368 die("general protection fault", regs, error_code);
23369 + }
23370 goto exit;
23371 }
23372
23373 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23374 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23375 + struct mm_struct *mm = tsk->mm;
23376 + unsigned long limit;
23377 +
23378 + down_write(&mm->mmap_sem);
23379 + limit = mm->context.user_cs_limit;
23380 + if (limit < TASK_SIZE) {
23381 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23382 + up_write(&mm->mmap_sem);
23383 + return;
23384 + }
23385 + up_write(&mm->mmap_sem);
23386 + }
23387 +#endif
23388 +
23389 tsk->thread.error_code = error_code;
23390 tsk->thread.trap_nr = X86_TRAP_GP;
23391
23392 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23393 /* It's safe to allow irq's after DR6 has been saved */
23394 preempt_conditional_sti(regs);
23395
23396 - if (regs->flags & X86_VM_MASK) {
23397 + if (v8086_mode(regs)) {
23398 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23399 X86_TRAP_DB);
23400 preempt_conditional_cli(regs);
23401 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23402 * We already checked v86 mode above, so we can check for kernel mode
23403 * by just checking the CPL of CS.
23404 */
23405 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23406 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23407 tsk->thread.debugreg6 &= ~DR_STEP;
23408 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23409 regs->flags &= ~X86_EFLAGS_TF;
23410 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23411 return;
23412 conditional_sti(regs);
23413
23414 - if (!user_mode_vm(regs))
23415 + if (!user_mode(regs))
23416 {
23417 if (!fixup_exception(regs)) {
23418 task->thread.error_code = error_code;
23419 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23420 index 0ba4cfb..4596bec 100644
23421 --- a/arch/x86/kernel/uprobes.c
23422 +++ b/arch/x86/kernel/uprobes.c
23423 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23424 int ret = NOTIFY_DONE;
23425
23426 /* We are only interested in userspace traps */
23427 - if (regs && !user_mode_vm(regs))
23428 + if (regs && !user_mode(regs))
23429 return NOTIFY_DONE;
23430
23431 switch (val) {
23432 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23433 index b9242ba..50c5edd 100644
23434 --- a/arch/x86/kernel/verify_cpu.S
23435 +++ b/arch/x86/kernel/verify_cpu.S
23436 @@ -20,6 +20,7 @@
23437 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23438 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23439 * arch/x86/kernel/head_32.S: processor startup
23440 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23441 *
23442 * verify_cpu, returns the status of longmode and SSE in register %eax.
23443 * 0: Success 1: Failure
23444 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23445 index 3dbdd9c..888b14e 100644
23446 --- a/arch/x86/kernel/vm86_32.c
23447 +++ b/arch/x86/kernel/vm86_32.c
23448 @@ -44,6 +44,7 @@
23449 #include <linux/ptrace.h>
23450 #include <linux/audit.h>
23451 #include <linux/stddef.h>
23452 +#include <linux/grsecurity.h>
23453
23454 #include <asm/uaccess.h>
23455 #include <asm/io.h>
23456 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23457 do_exit(SIGSEGV);
23458 }
23459
23460 - tss = &per_cpu(init_tss, get_cpu());
23461 + tss = init_tss + get_cpu();
23462 current->thread.sp0 = current->thread.saved_sp0;
23463 current->thread.sysenter_cs = __KERNEL_CS;
23464 load_sp0(tss, &current->thread);
23465 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
23466
23467 if (tsk->thread.saved_sp0)
23468 goto out;
23469 +
23470 +#ifdef CONFIG_GRKERNSEC_VM86
23471 + if (!capable(CAP_SYS_RAWIO)) {
23472 + gr_handle_vm86();
23473 + goto out;
23474 + }
23475 +#endif
23476 +
23477 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
23478 offsetof(struct kernel_vm86_struct, vm86plus) -
23479 sizeof(info.regs));
23480 @@ -242,6 +251,14 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
23481 int tmp, ret;
23482 struct vm86plus_struct __user *v86;
23483
23484 +#ifdef CONFIG_GRKERNSEC_VM86
23485 + if (!capable(CAP_SYS_RAWIO)) {
23486 + gr_handle_vm86();
23487 + ret = -EPERM;
23488 + goto out;
23489 + }
23490 +#endif
23491 +
23492 tsk = current;
23493 switch (cmd) {
23494 case VM86_REQUEST_IRQ:
23495 @@ -329,7 +346,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23496 tsk->thread.saved_fs = info->regs32->fs;
23497 tsk->thread.saved_gs = get_user_gs(info->regs32);
23498
23499 - tss = &per_cpu(init_tss, get_cpu());
23500 + tss = init_tss + get_cpu();
23501 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23502 if (cpu_has_sep)
23503 tsk->thread.sysenter_cs = 0;
23504 @@ -536,7 +553,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23505 goto cannot_handle;
23506 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23507 goto cannot_handle;
23508 - intr_ptr = (unsigned long __user *) (i << 2);
23509 + intr_ptr = (__force unsigned long __user *) (i << 2);
23510 if (get_user(segoffs, intr_ptr))
23511 goto cannot_handle;
23512 if ((segoffs >> 16) == BIOSSEG)
23513 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23514 index 22a1530..8fbaaad 100644
23515 --- a/arch/x86/kernel/vmlinux.lds.S
23516 +++ b/arch/x86/kernel/vmlinux.lds.S
23517 @@ -26,6 +26,13 @@
23518 #include <asm/page_types.h>
23519 #include <asm/cache.h>
23520 #include <asm/boot.h>
23521 +#include <asm/segment.h>
23522 +
23523 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23524 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23525 +#else
23526 +#define __KERNEL_TEXT_OFFSET 0
23527 +#endif
23528
23529 #undef i386 /* in case the preprocessor is a 32bit one */
23530
23531 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23532
23533 PHDRS {
23534 text PT_LOAD FLAGS(5); /* R_E */
23535 +#ifdef CONFIG_X86_32
23536 + module PT_LOAD FLAGS(5); /* R_E */
23537 +#endif
23538 +#ifdef CONFIG_XEN
23539 + rodata PT_LOAD FLAGS(5); /* R_E */
23540 +#else
23541 + rodata PT_LOAD FLAGS(4); /* R__ */
23542 +#endif
23543 data PT_LOAD FLAGS(6); /* RW_ */
23544 -#ifdef CONFIG_X86_64
23545 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23546 #ifdef CONFIG_SMP
23547 percpu PT_LOAD FLAGS(6); /* RW_ */
23548 #endif
23549 + text.init PT_LOAD FLAGS(5); /* R_E */
23550 + text.exit PT_LOAD FLAGS(5); /* R_E */
23551 init PT_LOAD FLAGS(7); /* RWE */
23552 -#endif
23553 note PT_NOTE FLAGS(0); /* ___ */
23554 }
23555
23556 SECTIONS
23557 {
23558 #ifdef CONFIG_X86_32
23559 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23560 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23561 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23562 #else
23563 - . = __START_KERNEL;
23564 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23565 + . = __START_KERNEL;
23566 #endif
23567
23568 /* Text and read-only data */
23569 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23570 - _text = .;
23571 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23572 /* bootstrapping code */
23573 +#ifdef CONFIG_X86_32
23574 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23575 +#else
23576 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23577 +#endif
23578 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23579 + _text = .;
23580 HEAD_TEXT
23581 #ifdef CONFIG_X86_32
23582 . = ALIGN(PAGE_SIZE);
23583 @@ -108,13 +128,48 @@ SECTIONS
23584 IRQENTRY_TEXT
23585 *(.fixup)
23586 *(.gnu.warning)
23587 - /* End of text section */
23588 - _etext = .;
23589 } :text = 0x9090
23590
23591 - NOTES :text :note
23592 + . += __KERNEL_TEXT_OFFSET;
23593
23594 - EXCEPTION_TABLE(16) :text = 0x9090
23595 +#ifdef CONFIG_X86_32
23596 + . = ALIGN(PAGE_SIZE);
23597 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23598 +
23599 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23600 + MODULES_EXEC_VADDR = .;
23601 + BYTE(0)
23602 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23603 + . = ALIGN(HPAGE_SIZE) - 1;
23604 + MODULES_EXEC_END = .;
23605 +#endif
23606 +
23607 + } :module
23608 +#endif
23609 +
23610 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23611 + /* End of text section */
23612 + BYTE(0)
23613 + _etext = . - __KERNEL_TEXT_OFFSET;
23614 + }
23615 +
23616 +#ifdef CONFIG_X86_32
23617 + . = ALIGN(PAGE_SIZE);
23618 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23619 + *(.idt)
23620 + . = ALIGN(PAGE_SIZE);
23621 + *(.empty_zero_page)
23622 + *(.initial_pg_fixmap)
23623 + *(.initial_pg_pmd)
23624 + *(.initial_page_table)
23625 + *(.swapper_pg_dir)
23626 + } :rodata
23627 +#endif
23628 +
23629 + . = ALIGN(PAGE_SIZE);
23630 + NOTES :rodata :note
23631 +
23632 + EXCEPTION_TABLE(16) :rodata
23633
23634 #if defined(CONFIG_DEBUG_RODATA)
23635 /* .text should occupy whole number of pages */
23636 @@ -126,16 +181,20 @@ SECTIONS
23637
23638 /* Data */
23639 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23640 +
23641 +#ifdef CONFIG_PAX_KERNEXEC
23642 + . = ALIGN(HPAGE_SIZE);
23643 +#else
23644 + . = ALIGN(PAGE_SIZE);
23645 +#endif
23646 +
23647 /* Start of data section */
23648 _sdata = .;
23649
23650 /* init_task */
23651 INIT_TASK_DATA(THREAD_SIZE)
23652
23653 -#ifdef CONFIG_X86_32
23654 - /* 32 bit has nosave before _edata */
23655 NOSAVE_DATA
23656 -#endif
23657
23658 PAGE_ALIGNED_DATA(PAGE_SIZE)
23659
23660 @@ -176,12 +235,19 @@ SECTIONS
23661 #endif /* CONFIG_X86_64 */
23662
23663 /* Init code and data - will be freed after init */
23664 - . = ALIGN(PAGE_SIZE);
23665 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23666 + BYTE(0)
23667 +
23668 +#ifdef CONFIG_PAX_KERNEXEC
23669 + . = ALIGN(HPAGE_SIZE);
23670 +#else
23671 + . = ALIGN(PAGE_SIZE);
23672 +#endif
23673 +
23674 __init_begin = .; /* paired with __init_end */
23675 - }
23676 + } :init.begin
23677
23678 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23679 +#ifdef CONFIG_SMP
23680 /*
23681 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23682 * output PHDR, so the next output section - .init.text - should
23683 @@ -190,12 +256,27 @@ SECTIONS
23684 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23685 #endif
23686
23687 - INIT_TEXT_SECTION(PAGE_SIZE)
23688 -#ifdef CONFIG_X86_64
23689 - :init
23690 -#endif
23691 + . = ALIGN(PAGE_SIZE);
23692 + init_begin = .;
23693 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23694 + VMLINUX_SYMBOL(_sinittext) = .;
23695 + INIT_TEXT
23696 + VMLINUX_SYMBOL(_einittext) = .;
23697 + . = ALIGN(PAGE_SIZE);
23698 + } :text.init
23699
23700 - INIT_DATA_SECTION(16)
23701 + /*
23702 + * .exit.text is discard at runtime, not link time, to deal with
23703 + * references from .altinstructions and .eh_frame
23704 + */
23705 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23706 + EXIT_TEXT
23707 + . = ALIGN(16);
23708 + } :text.exit
23709 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23710 +
23711 + . = ALIGN(PAGE_SIZE);
23712 + INIT_DATA_SECTION(16) :init
23713
23714 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23715 __x86_cpu_dev_start = .;
23716 @@ -257,19 +338,12 @@ SECTIONS
23717 }
23718
23719 . = ALIGN(8);
23720 - /*
23721 - * .exit.text is discard at runtime, not link time, to deal with
23722 - * references from .altinstructions and .eh_frame
23723 - */
23724 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23725 - EXIT_TEXT
23726 - }
23727
23728 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23729 EXIT_DATA
23730 }
23731
23732 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23733 +#ifndef CONFIG_SMP
23734 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23735 #endif
23736
23737 @@ -288,16 +362,10 @@ SECTIONS
23738 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23739 __smp_locks = .;
23740 *(.smp_locks)
23741 - . = ALIGN(PAGE_SIZE);
23742 __smp_locks_end = .;
23743 + . = ALIGN(PAGE_SIZE);
23744 }
23745
23746 -#ifdef CONFIG_X86_64
23747 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23748 - NOSAVE_DATA
23749 - }
23750 -#endif
23751 -
23752 /* BSS */
23753 . = ALIGN(PAGE_SIZE);
23754 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23755 @@ -313,6 +381,7 @@ SECTIONS
23756 __brk_base = .;
23757 . += 64 * 1024; /* 64k alignment slop space */
23758 *(.brk_reservation) /* areas brk users have reserved */
23759 + . = ALIGN(HPAGE_SIZE);
23760 __brk_limit = .;
23761 }
23762
23763 @@ -339,13 +408,12 @@ SECTIONS
23764 * for the boot processor.
23765 */
23766 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23767 -INIT_PER_CPU(gdt_page);
23768 INIT_PER_CPU(irq_stack_union);
23769
23770 /*
23771 * Build-time check on the image size:
23772 */
23773 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23774 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23775 "kernel image bigger than KERNEL_IMAGE_SIZE");
23776
23777 #ifdef CONFIG_SMP
23778 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23779 index 9a907a6..f83f921 100644
23780 --- a/arch/x86/kernel/vsyscall_64.c
23781 +++ b/arch/x86/kernel/vsyscall_64.c
23782 @@ -56,15 +56,13 @@
23783 DEFINE_VVAR(int, vgetcpu_mode);
23784 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23785
23786 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23787 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23788
23789 static int __init vsyscall_setup(char *str)
23790 {
23791 if (str) {
23792 if (!strcmp("emulate", str))
23793 vsyscall_mode = EMULATE;
23794 - else if (!strcmp("native", str))
23795 - vsyscall_mode = NATIVE;
23796 else if (!strcmp("none", str))
23797 vsyscall_mode = NONE;
23798 else
23799 @@ -323,8 +321,7 @@ do_ret:
23800 return true;
23801
23802 sigsegv:
23803 - force_sig(SIGSEGV, current);
23804 - return true;
23805 + do_group_exit(SIGKILL);
23806 }
23807
23808 /*
23809 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23810 extern char __vvar_page;
23811 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23812
23813 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23814 - vsyscall_mode == NATIVE
23815 - ? PAGE_KERNEL_VSYSCALL
23816 - : PAGE_KERNEL_VVAR);
23817 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23818 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23819 (unsigned long)VSYSCALL_START);
23820
23821 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23822 index b014d94..6d6ca7b 100644
23823 --- a/arch/x86/kernel/x8664_ksyms_64.c
23824 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23825 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23826 EXPORT_SYMBOL(copy_user_generic_unrolled);
23827 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23828 EXPORT_SYMBOL(__copy_user_nocache);
23829 -EXPORT_SYMBOL(_copy_from_user);
23830 -EXPORT_SYMBOL(_copy_to_user);
23831
23832 EXPORT_SYMBOL(copy_page);
23833 EXPORT_SYMBOL(clear_page);
23834 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23835 index 45a14db..075bb9b 100644
23836 --- a/arch/x86/kernel/x86_init.c
23837 +++ b/arch/x86/kernel/x86_init.c
23838 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23839 },
23840 };
23841
23842 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23843 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23844 .early_percpu_clock_init = x86_init_noop,
23845 .setup_percpu_clockev = setup_secondary_APIC_clock,
23846 };
23847 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23848 static void default_nmi_init(void) { };
23849 static int default_i8042_detect(void) { return 1; };
23850
23851 -struct x86_platform_ops x86_platform = {
23852 +struct x86_platform_ops x86_platform __read_only = {
23853 .calibrate_tsc = native_calibrate_tsc,
23854 .get_wallclock = mach_get_cmos_time,
23855 .set_wallclock = mach_set_rtc_mmss,
23856 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23857 };
23858
23859 EXPORT_SYMBOL_GPL(x86_platform);
23860 -struct x86_msi_ops x86_msi = {
23861 +struct x86_msi_ops x86_msi __read_only = {
23862 .setup_msi_irqs = native_setup_msi_irqs,
23863 .compose_msi_msg = native_compose_msi_msg,
23864 .teardown_msi_irq = native_teardown_msi_irq,
23865 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23866 .setup_hpet_msi = default_setup_hpet_msi,
23867 };
23868
23869 -struct x86_io_apic_ops x86_io_apic_ops = {
23870 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23871 .init = native_io_apic_init_mappings,
23872 .read = native_io_apic_read,
23873 .write = native_io_apic_write,
23874 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23875 index ada87a3..afea76d 100644
23876 --- a/arch/x86/kernel/xsave.c
23877 +++ b/arch/x86/kernel/xsave.c
23878 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23879 {
23880 int err;
23881
23882 + buf = (struct xsave_struct __user *)____m(buf);
23883 if (use_xsave())
23884 err = xsave_user(buf);
23885 else if (use_fxsr())
23886 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23887 */
23888 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23889 {
23890 + buf = (void __user *)____m(buf);
23891 if (use_xsave()) {
23892 if ((unsigned long)buf % 64 || fx_only) {
23893 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23894 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23895 index a20ecb5..d0e2194 100644
23896 --- a/arch/x86/kvm/cpuid.c
23897 +++ b/arch/x86/kvm/cpuid.c
23898 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23899 struct kvm_cpuid2 *cpuid,
23900 struct kvm_cpuid_entry2 __user *entries)
23901 {
23902 - int r;
23903 + int r, i;
23904
23905 r = -E2BIG;
23906 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23907 goto out;
23908 r = -EFAULT;
23909 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23910 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23911 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23912 goto out;
23913 + for (i = 0; i < cpuid->nent; ++i) {
23914 + struct kvm_cpuid_entry2 cpuid_entry;
23915 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23916 + goto out;
23917 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23918 + }
23919 vcpu->arch.cpuid_nent = cpuid->nent;
23920 kvm_apic_set_version(vcpu);
23921 kvm_x86_ops->cpuid_update(vcpu);
23922 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23923 struct kvm_cpuid2 *cpuid,
23924 struct kvm_cpuid_entry2 __user *entries)
23925 {
23926 - int r;
23927 + int r, i;
23928
23929 r = -E2BIG;
23930 if (cpuid->nent < vcpu->arch.cpuid_nent)
23931 goto out;
23932 r = -EFAULT;
23933 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23934 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23935 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23936 goto out;
23937 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
23938 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
23939 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
23940 + goto out;
23941 + }
23942 return 0;
23943
23944 out:
23945 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
23946 index 59622c9..f338414 100644
23947 --- a/arch/x86/kvm/emulate.c
23948 +++ b/arch/x86/kvm/emulate.c
23949 @@ -328,6 +328,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23950
23951 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
23952 do { \
23953 + unsigned long _tmp; \
23954 __asm__ __volatile__ ( \
23955 _PRE_EFLAGS("0", "4", "2") \
23956 _op _suffix " %"_x"3,%1; " \
23957 @@ -342,8 +343,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23958 /* Raw emulation: instruction has two explicit operands. */
23959 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
23960 do { \
23961 - unsigned long _tmp; \
23962 - \
23963 switch ((ctxt)->dst.bytes) { \
23964 case 2: \
23965 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
23966 @@ -359,7 +358,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23967
23968 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
23969 do { \
23970 - unsigned long _tmp; \
23971 switch ((ctxt)->dst.bytes) { \
23972 case 1: \
23973 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
23974 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
23975 index f77df1c..6f20690 100644
23976 --- a/arch/x86/kvm/lapic.c
23977 +++ b/arch/x86/kvm/lapic.c
23978 @@ -55,7 +55,7 @@
23979 #define APIC_BUS_CYCLE_NS 1
23980
23981 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
23982 -#define apic_debug(fmt, arg...)
23983 +#define apic_debug(fmt, arg...) do {} while (0)
23984
23985 #define APIC_LVT_NUM 6
23986 /* 14 is the version for Xeon and Pentium 8.4.8*/
23987 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
23988 index 105dd5b..1b0ccc2 100644
23989 --- a/arch/x86/kvm/paging_tmpl.h
23990 +++ b/arch/x86/kvm/paging_tmpl.h
23991 @@ -208,7 +208,7 @@ retry_walk:
23992 if (unlikely(kvm_is_error_hva(host_addr)))
23993 goto error;
23994
23995 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
23996 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
23997 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
23998 goto error;
23999 walker->ptep_user[walker->level - 1] = ptep_user;
24000 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24001 index e1b1ce2..f7b4b43 100644
24002 --- a/arch/x86/kvm/svm.c
24003 +++ b/arch/x86/kvm/svm.c
24004 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24005 int cpu = raw_smp_processor_id();
24006
24007 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24008 +
24009 + pax_open_kernel();
24010 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24011 + pax_close_kernel();
24012 +
24013 load_TR_desc();
24014 }
24015
24016 @@ -3901,6 +3905,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24017 #endif
24018 #endif
24019
24020 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24021 + __set_fs(current_thread_info()->addr_limit);
24022 +#endif
24023 +
24024 reload_tss(vcpu);
24025
24026 local_irq_disable();
24027 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24028 index 0af1807..06912bb 100644
24029 --- a/arch/x86/kvm/vmx.c
24030 +++ b/arch/x86/kvm/vmx.c
24031 @@ -1184,12 +1184,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24032 #endif
24033 }
24034
24035 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24036 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24037 {
24038 vmcs_writel(field, vmcs_readl(field) & ~mask);
24039 }
24040
24041 -static void vmcs_set_bits(unsigned long field, u32 mask)
24042 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24043 {
24044 vmcs_writel(field, vmcs_readl(field) | mask);
24045 }
24046 @@ -1390,7 +1390,11 @@ static void reload_tss(void)
24047 struct desc_struct *descs;
24048
24049 descs = (void *)gdt->address;
24050 +
24051 + pax_open_kernel();
24052 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24053 + pax_close_kernel();
24054 +
24055 load_TR_desc();
24056 }
24057
24058 @@ -1614,6 +1618,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24059 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24060 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24061
24062 +#ifdef CONFIG_PAX_PER_CPU_PGD
24063 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24064 +#endif
24065 +
24066 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24067 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24068 vmx->loaded_vmcs->cpu = cpu;
24069 @@ -2779,8 +2787,11 @@ static __init int hardware_setup(void)
24070 if (!cpu_has_vmx_flexpriority())
24071 flexpriority_enabled = 0;
24072
24073 - if (!cpu_has_vmx_tpr_shadow())
24074 - kvm_x86_ops->update_cr8_intercept = NULL;
24075 + if (!cpu_has_vmx_tpr_shadow()) {
24076 + pax_open_kernel();
24077 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24078 + pax_close_kernel();
24079 + }
24080
24081 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24082 kvm_disable_largepages();
24083 @@ -2792,10 +2803,12 @@ static __init int hardware_setup(void)
24084 !cpu_has_vmx_virtual_intr_delivery())
24085 enable_apicv_reg_vid = 0;
24086
24087 + pax_open_kernel();
24088 if (enable_apicv_reg_vid)
24089 - kvm_x86_ops->update_cr8_intercept = NULL;
24090 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24091 else
24092 - kvm_x86_ops->hwapic_irr_update = NULL;
24093 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
24094 + pax_close_kernel();
24095
24096 if (nested)
24097 nested_vmx_setup_ctls_msrs();
24098 @@ -3883,7 +3896,10 @@ static void vmx_set_constant_host_state(void)
24099
24100 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24101 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24102 +
24103 +#ifndef CONFIG_PAX_PER_CPU_PGD
24104 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24105 +#endif
24106
24107 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24108 #ifdef CONFIG_X86_64
24109 @@ -3904,7 +3920,7 @@ static void vmx_set_constant_host_state(void)
24110 native_store_idt(&dt);
24111 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24112
24113 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24114 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24115
24116 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24117 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24118 @@ -6580,6 +6596,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24119 "jmp 2f \n\t"
24120 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24121 "2: "
24122 +
24123 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24124 + "ljmp %[cs],$3f\n\t"
24125 + "3: "
24126 +#endif
24127 +
24128 /* Save guest registers, load host registers, keep flags */
24129 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24130 "pop %0 \n\t"
24131 @@ -6632,6 +6654,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24132 #endif
24133 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24134 [wordsize]"i"(sizeof(ulong))
24135 +
24136 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24137 + ,[cs]"i"(__KERNEL_CS)
24138 +#endif
24139 +
24140 : "cc", "memory"
24141 #ifdef CONFIG_X86_64
24142 , "rax", "rbx", "rdi", "rsi"
24143 @@ -6645,7 +6672,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24144 if (debugctlmsr)
24145 update_debugctlmsr(debugctlmsr);
24146
24147 -#ifndef CONFIG_X86_64
24148 +#ifdef CONFIG_X86_32
24149 /*
24150 * The sysexit path does not restore ds/es, so we must set them to
24151 * a reasonable value ourselves.
24152 @@ -6654,8 +6681,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24153 * may be executed in interrupt context, which saves and restore segments
24154 * around it, nullifying its effect.
24155 */
24156 - loadsegment(ds, __USER_DS);
24157 - loadsegment(es, __USER_DS);
24158 + loadsegment(ds, __KERNEL_DS);
24159 + loadsegment(es, __KERNEL_DS);
24160 + loadsegment(ss, __KERNEL_DS);
24161 +
24162 +#ifdef CONFIG_PAX_KERNEXEC
24163 + loadsegment(fs, __KERNEL_PERCPU);
24164 +#endif
24165 +
24166 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24167 + __set_fs(current_thread_info()->addr_limit);
24168 +#endif
24169 +
24170 #endif
24171
24172 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24173 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24174 index e172132..c3d3e27 100644
24175 --- a/arch/x86/kvm/x86.c
24176 +++ b/arch/x86/kvm/x86.c
24177 @@ -1686,8 +1686,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24178 {
24179 struct kvm *kvm = vcpu->kvm;
24180 int lm = is_long_mode(vcpu);
24181 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24182 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24183 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24184 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24185 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24186 : kvm->arch.xen_hvm_config.blob_size_32;
24187 u32 page_num = data & ~PAGE_MASK;
24188 @@ -2567,6 +2567,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24189 if (n < msr_list.nmsrs)
24190 goto out;
24191 r = -EFAULT;
24192 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24193 + goto out;
24194 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24195 num_msrs_to_save * sizeof(u32)))
24196 goto out;
24197 @@ -2696,7 +2698,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24198 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24199 struct kvm_interrupt *irq)
24200 {
24201 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24202 + if (irq->irq >= KVM_NR_INTERRUPTS)
24203 return -EINVAL;
24204 if (irqchip_in_kernel(vcpu->kvm))
24205 return -ENXIO;
24206 @@ -5247,7 +5249,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24207 };
24208 #endif
24209
24210 -int kvm_arch_init(void *opaque)
24211 +int kvm_arch_init(const void *opaque)
24212 {
24213 int r;
24214 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24215 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24216 index 7114c63..a1018fc 100644
24217 --- a/arch/x86/lguest/boot.c
24218 +++ b/arch/x86/lguest/boot.c
24219 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24220 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24221 * Launcher to reboot us.
24222 */
24223 -static void lguest_restart(char *reason)
24224 +static __noreturn void lguest_restart(char *reason)
24225 {
24226 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24227 + BUG();
24228 }
24229
24230 /*G:050
24231 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24232 index 00933d5..3a64af9 100644
24233 --- a/arch/x86/lib/atomic64_386_32.S
24234 +++ b/arch/x86/lib/atomic64_386_32.S
24235 @@ -48,6 +48,10 @@ BEGIN(read)
24236 movl (v), %eax
24237 movl 4(v), %edx
24238 RET_ENDP
24239 +BEGIN(read_unchecked)
24240 + movl (v), %eax
24241 + movl 4(v), %edx
24242 +RET_ENDP
24243 #undef v
24244
24245 #define v %esi
24246 @@ -55,6 +59,10 @@ BEGIN(set)
24247 movl %ebx, (v)
24248 movl %ecx, 4(v)
24249 RET_ENDP
24250 +BEGIN(set_unchecked)
24251 + movl %ebx, (v)
24252 + movl %ecx, 4(v)
24253 +RET_ENDP
24254 #undef v
24255
24256 #define v %esi
24257 @@ -70,6 +78,20 @@ RET_ENDP
24258 BEGIN(add)
24259 addl %eax, (v)
24260 adcl %edx, 4(v)
24261 +
24262 +#ifdef CONFIG_PAX_REFCOUNT
24263 + jno 0f
24264 + subl %eax, (v)
24265 + sbbl %edx, 4(v)
24266 + int $4
24267 +0:
24268 + _ASM_EXTABLE(0b, 0b)
24269 +#endif
24270 +
24271 +RET_ENDP
24272 +BEGIN(add_unchecked)
24273 + addl %eax, (v)
24274 + adcl %edx, 4(v)
24275 RET_ENDP
24276 #undef v
24277
24278 @@ -77,6 +99,24 @@ RET_ENDP
24279 BEGIN(add_return)
24280 addl (v), %eax
24281 adcl 4(v), %edx
24282 +
24283 +#ifdef CONFIG_PAX_REFCOUNT
24284 + into
24285 +1234:
24286 + _ASM_EXTABLE(1234b, 2f)
24287 +#endif
24288 +
24289 + movl %eax, (v)
24290 + movl %edx, 4(v)
24291 +
24292 +#ifdef CONFIG_PAX_REFCOUNT
24293 +2:
24294 +#endif
24295 +
24296 +RET_ENDP
24297 +BEGIN(add_return_unchecked)
24298 + addl (v), %eax
24299 + adcl 4(v), %edx
24300 movl %eax, (v)
24301 movl %edx, 4(v)
24302 RET_ENDP
24303 @@ -86,6 +126,20 @@ RET_ENDP
24304 BEGIN(sub)
24305 subl %eax, (v)
24306 sbbl %edx, 4(v)
24307 +
24308 +#ifdef CONFIG_PAX_REFCOUNT
24309 + jno 0f
24310 + addl %eax, (v)
24311 + adcl %edx, 4(v)
24312 + int $4
24313 +0:
24314 + _ASM_EXTABLE(0b, 0b)
24315 +#endif
24316 +
24317 +RET_ENDP
24318 +BEGIN(sub_unchecked)
24319 + subl %eax, (v)
24320 + sbbl %edx, 4(v)
24321 RET_ENDP
24322 #undef v
24323
24324 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24325 sbbl $0, %edx
24326 addl (v), %eax
24327 adcl 4(v), %edx
24328 +
24329 +#ifdef CONFIG_PAX_REFCOUNT
24330 + into
24331 +1234:
24332 + _ASM_EXTABLE(1234b, 2f)
24333 +#endif
24334 +
24335 + movl %eax, (v)
24336 + movl %edx, 4(v)
24337 +
24338 +#ifdef CONFIG_PAX_REFCOUNT
24339 +2:
24340 +#endif
24341 +
24342 +RET_ENDP
24343 +BEGIN(sub_return_unchecked)
24344 + negl %edx
24345 + negl %eax
24346 + sbbl $0, %edx
24347 + addl (v), %eax
24348 + adcl 4(v), %edx
24349 movl %eax, (v)
24350 movl %edx, 4(v)
24351 RET_ENDP
24352 @@ -105,6 +180,20 @@ RET_ENDP
24353 BEGIN(inc)
24354 addl $1, (v)
24355 adcl $0, 4(v)
24356 +
24357 +#ifdef CONFIG_PAX_REFCOUNT
24358 + jno 0f
24359 + subl $1, (v)
24360 + sbbl $0, 4(v)
24361 + int $4
24362 +0:
24363 + _ASM_EXTABLE(0b, 0b)
24364 +#endif
24365 +
24366 +RET_ENDP
24367 +BEGIN(inc_unchecked)
24368 + addl $1, (v)
24369 + adcl $0, 4(v)
24370 RET_ENDP
24371 #undef v
24372
24373 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24374 movl 4(v), %edx
24375 addl $1, %eax
24376 adcl $0, %edx
24377 +
24378 +#ifdef CONFIG_PAX_REFCOUNT
24379 + into
24380 +1234:
24381 + _ASM_EXTABLE(1234b, 2f)
24382 +#endif
24383 +
24384 + movl %eax, (v)
24385 + movl %edx, 4(v)
24386 +
24387 +#ifdef CONFIG_PAX_REFCOUNT
24388 +2:
24389 +#endif
24390 +
24391 +RET_ENDP
24392 +BEGIN(inc_return_unchecked)
24393 + movl (v), %eax
24394 + movl 4(v), %edx
24395 + addl $1, %eax
24396 + adcl $0, %edx
24397 movl %eax, (v)
24398 movl %edx, 4(v)
24399 RET_ENDP
24400 @@ -123,6 +232,20 @@ RET_ENDP
24401 BEGIN(dec)
24402 subl $1, (v)
24403 sbbl $0, 4(v)
24404 +
24405 +#ifdef CONFIG_PAX_REFCOUNT
24406 + jno 0f
24407 + addl $1, (v)
24408 + adcl $0, 4(v)
24409 + int $4
24410 +0:
24411 + _ASM_EXTABLE(0b, 0b)
24412 +#endif
24413 +
24414 +RET_ENDP
24415 +BEGIN(dec_unchecked)
24416 + subl $1, (v)
24417 + sbbl $0, 4(v)
24418 RET_ENDP
24419 #undef v
24420
24421 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24422 movl 4(v), %edx
24423 subl $1, %eax
24424 sbbl $0, %edx
24425 +
24426 +#ifdef CONFIG_PAX_REFCOUNT
24427 + into
24428 +1234:
24429 + _ASM_EXTABLE(1234b, 2f)
24430 +#endif
24431 +
24432 + movl %eax, (v)
24433 + movl %edx, 4(v)
24434 +
24435 +#ifdef CONFIG_PAX_REFCOUNT
24436 +2:
24437 +#endif
24438 +
24439 +RET_ENDP
24440 +BEGIN(dec_return_unchecked)
24441 + movl (v), %eax
24442 + movl 4(v), %edx
24443 + subl $1, %eax
24444 + sbbl $0, %edx
24445 movl %eax, (v)
24446 movl %edx, 4(v)
24447 RET_ENDP
24448 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24449 adcl %edx, %edi
24450 addl (v), %eax
24451 adcl 4(v), %edx
24452 +
24453 +#ifdef CONFIG_PAX_REFCOUNT
24454 + into
24455 +1234:
24456 + _ASM_EXTABLE(1234b, 2f)
24457 +#endif
24458 +
24459 cmpl %eax, %ecx
24460 je 3f
24461 1:
24462 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24463 1:
24464 addl $1, %eax
24465 adcl $0, %edx
24466 +
24467 +#ifdef CONFIG_PAX_REFCOUNT
24468 + into
24469 +1234:
24470 + _ASM_EXTABLE(1234b, 2f)
24471 +#endif
24472 +
24473 movl %eax, (v)
24474 movl %edx, 4(v)
24475 movl $1, %eax
24476 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24477 movl 4(v), %edx
24478 subl $1, %eax
24479 sbbl $0, %edx
24480 +
24481 +#ifdef CONFIG_PAX_REFCOUNT
24482 + into
24483 +1234:
24484 + _ASM_EXTABLE(1234b, 1f)
24485 +#endif
24486 +
24487 js 1f
24488 movl %eax, (v)
24489 movl %edx, 4(v)
24490 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24491 index f5cc9eb..51fa319 100644
24492 --- a/arch/x86/lib/atomic64_cx8_32.S
24493 +++ b/arch/x86/lib/atomic64_cx8_32.S
24494 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24495 CFI_STARTPROC
24496
24497 read64 %ecx
24498 + pax_force_retaddr
24499 ret
24500 CFI_ENDPROC
24501 ENDPROC(atomic64_read_cx8)
24502
24503 +ENTRY(atomic64_read_unchecked_cx8)
24504 + CFI_STARTPROC
24505 +
24506 + read64 %ecx
24507 + pax_force_retaddr
24508 + ret
24509 + CFI_ENDPROC
24510 +ENDPROC(atomic64_read_unchecked_cx8)
24511 +
24512 ENTRY(atomic64_set_cx8)
24513 CFI_STARTPROC
24514
24515 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24516 cmpxchg8b (%esi)
24517 jne 1b
24518
24519 + pax_force_retaddr
24520 ret
24521 CFI_ENDPROC
24522 ENDPROC(atomic64_set_cx8)
24523
24524 +ENTRY(atomic64_set_unchecked_cx8)
24525 + CFI_STARTPROC
24526 +
24527 +1:
24528 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24529 + * are atomic on 586 and newer */
24530 + cmpxchg8b (%esi)
24531 + jne 1b
24532 +
24533 + pax_force_retaddr
24534 + ret
24535 + CFI_ENDPROC
24536 +ENDPROC(atomic64_set_unchecked_cx8)
24537 +
24538 ENTRY(atomic64_xchg_cx8)
24539 CFI_STARTPROC
24540
24541 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24542 cmpxchg8b (%esi)
24543 jne 1b
24544
24545 + pax_force_retaddr
24546 ret
24547 CFI_ENDPROC
24548 ENDPROC(atomic64_xchg_cx8)
24549
24550 -.macro addsub_return func ins insc
24551 -ENTRY(atomic64_\func\()_return_cx8)
24552 +.macro addsub_return func ins insc unchecked=""
24553 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24554 CFI_STARTPROC
24555 SAVE ebp
24556 SAVE ebx
24557 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24558 movl %edx, %ecx
24559 \ins\()l %esi, %ebx
24560 \insc\()l %edi, %ecx
24561 +
24562 +.ifb \unchecked
24563 +#ifdef CONFIG_PAX_REFCOUNT
24564 + into
24565 +2:
24566 + _ASM_EXTABLE(2b, 3f)
24567 +#endif
24568 +.endif
24569 +
24570 LOCK_PREFIX
24571 cmpxchg8b (%ebp)
24572 jne 1b
24573 -
24574 -10:
24575 movl %ebx, %eax
24576 movl %ecx, %edx
24577 +
24578 +.ifb \unchecked
24579 +#ifdef CONFIG_PAX_REFCOUNT
24580 +3:
24581 +#endif
24582 +.endif
24583 +
24584 RESTORE edi
24585 RESTORE esi
24586 RESTORE ebx
24587 RESTORE ebp
24588 + pax_force_retaddr
24589 ret
24590 CFI_ENDPROC
24591 -ENDPROC(atomic64_\func\()_return_cx8)
24592 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24593 .endm
24594
24595 addsub_return add add adc
24596 addsub_return sub sub sbb
24597 +addsub_return add add adc _unchecked
24598 +addsub_return sub sub sbb _unchecked
24599
24600 -.macro incdec_return func ins insc
24601 -ENTRY(atomic64_\func\()_return_cx8)
24602 +.macro incdec_return func ins insc unchecked=""
24603 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24604 CFI_STARTPROC
24605 SAVE ebx
24606
24607 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24608 movl %edx, %ecx
24609 \ins\()l $1, %ebx
24610 \insc\()l $0, %ecx
24611 +
24612 +.ifb \unchecked
24613 +#ifdef CONFIG_PAX_REFCOUNT
24614 + into
24615 +2:
24616 + _ASM_EXTABLE(2b, 3f)
24617 +#endif
24618 +.endif
24619 +
24620 LOCK_PREFIX
24621 cmpxchg8b (%esi)
24622 jne 1b
24623
24624 -10:
24625 movl %ebx, %eax
24626 movl %ecx, %edx
24627 +
24628 +.ifb \unchecked
24629 +#ifdef CONFIG_PAX_REFCOUNT
24630 +3:
24631 +#endif
24632 +.endif
24633 +
24634 RESTORE ebx
24635 + pax_force_retaddr
24636 ret
24637 CFI_ENDPROC
24638 -ENDPROC(atomic64_\func\()_return_cx8)
24639 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24640 .endm
24641
24642 incdec_return inc add adc
24643 incdec_return dec sub sbb
24644 +incdec_return inc add adc _unchecked
24645 +incdec_return dec sub sbb _unchecked
24646
24647 ENTRY(atomic64_dec_if_positive_cx8)
24648 CFI_STARTPROC
24649 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24650 movl %edx, %ecx
24651 subl $1, %ebx
24652 sbb $0, %ecx
24653 +
24654 +#ifdef CONFIG_PAX_REFCOUNT
24655 + into
24656 +1234:
24657 + _ASM_EXTABLE(1234b, 2f)
24658 +#endif
24659 +
24660 js 2f
24661 LOCK_PREFIX
24662 cmpxchg8b (%esi)
24663 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24664 movl %ebx, %eax
24665 movl %ecx, %edx
24666 RESTORE ebx
24667 + pax_force_retaddr
24668 ret
24669 CFI_ENDPROC
24670 ENDPROC(atomic64_dec_if_positive_cx8)
24671 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24672 movl %edx, %ecx
24673 addl %ebp, %ebx
24674 adcl %edi, %ecx
24675 +
24676 +#ifdef CONFIG_PAX_REFCOUNT
24677 + into
24678 +1234:
24679 + _ASM_EXTABLE(1234b, 3f)
24680 +#endif
24681 +
24682 LOCK_PREFIX
24683 cmpxchg8b (%esi)
24684 jne 1b
24685 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24686 CFI_ADJUST_CFA_OFFSET -8
24687 RESTORE ebx
24688 RESTORE ebp
24689 + pax_force_retaddr
24690 ret
24691 4:
24692 cmpl %edx, 4(%esp)
24693 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24694 xorl %ecx, %ecx
24695 addl $1, %ebx
24696 adcl %edx, %ecx
24697 +
24698 +#ifdef CONFIG_PAX_REFCOUNT
24699 + into
24700 +1234:
24701 + _ASM_EXTABLE(1234b, 3f)
24702 +#endif
24703 +
24704 LOCK_PREFIX
24705 cmpxchg8b (%esi)
24706 jne 1b
24707 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24708 movl $1, %eax
24709 3:
24710 RESTORE ebx
24711 + pax_force_retaddr
24712 ret
24713 CFI_ENDPROC
24714 ENDPROC(atomic64_inc_not_zero_cx8)
24715 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24716 index 2af5df3..62b1a5a 100644
24717 --- a/arch/x86/lib/checksum_32.S
24718 +++ b/arch/x86/lib/checksum_32.S
24719 @@ -29,7 +29,8 @@
24720 #include <asm/dwarf2.h>
24721 #include <asm/errno.h>
24722 #include <asm/asm.h>
24723 -
24724 +#include <asm/segment.h>
24725 +
24726 /*
24727 * computes a partial checksum, e.g. for TCP/UDP fragments
24728 */
24729 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24730
24731 #define ARGBASE 16
24732 #define FP 12
24733 -
24734 -ENTRY(csum_partial_copy_generic)
24735 +
24736 +ENTRY(csum_partial_copy_generic_to_user)
24737 CFI_STARTPROC
24738 +
24739 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24740 + pushl_cfi %gs
24741 + popl_cfi %es
24742 + jmp csum_partial_copy_generic
24743 +#endif
24744 +
24745 +ENTRY(csum_partial_copy_generic_from_user)
24746 +
24747 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24748 + pushl_cfi %gs
24749 + popl_cfi %ds
24750 +#endif
24751 +
24752 +ENTRY(csum_partial_copy_generic)
24753 subl $4,%esp
24754 CFI_ADJUST_CFA_OFFSET 4
24755 pushl_cfi %edi
24756 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24757 jmp 4f
24758 SRC(1: movw (%esi), %bx )
24759 addl $2, %esi
24760 -DST( movw %bx, (%edi) )
24761 +DST( movw %bx, %es:(%edi) )
24762 addl $2, %edi
24763 addw %bx, %ax
24764 adcl $0, %eax
24765 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24766 SRC(1: movl (%esi), %ebx )
24767 SRC( movl 4(%esi), %edx )
24768 adcl %ebx, %eax
24769 -DST( movl %ebx, (%edi) )
24770 +DST( movl %ebx, %es:(%edi) )
24771 adcl %edx, %eax
24772 -DST( movl %edx, 4(%edi) )
24773 +DST( movl %edx, %es:4(%edi) )
24774
24775 SRC( movl 8(%esi), %ebx )
24776 SRC( movl 12(%esi), %edx )
24777 adcl %ebx, %eax
24778 -DST( movl %ebx, 8(%edi) )
24779 +DST( movl %ebx, %es:8(%edi) )
24780 adcl %edx, %eax
24781 -DST( movl %edx, 12(%edi) )
24782 +DST( movl %edx, %es:12(%edi) )
24783
24784 SRC( movl 16(%esi), %ebx )
24785 SRC( movl 20(%esi), %edx )
24786 adcl %ebx, %eax
24787 -DST( movl %ebx, 16(%edi) )
24788 +DST( movl %ebx, %es:16(%edi) )
24789 adcl %edx, %eax
24790 -DST( movl %edx, 20(%edi) )
24791 +DST( movl %edx, %es:20(%edi) )
24792
24793 SRC( movl 24(%esi), %ebx )
24794 SRC( movl 28(%esi), %edx )
24795 adcl %ebx, %eax
24796 -DST( movl %ebx, 24(%edi) )
24797 +DST( movl %ebx, %es:24(%edi) )
24798 adcl %edx, %eax
24799 -DST( movl %edx, 28(%edi) )
24800 +DST( movl %edx, %es:28(%edi) )
24801
24802 lea 32(%esi), %esi
24803 lea 32(%edi), %edi
24804 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24805 shrl $2, %edx # This clears CF
24806 SRC(3: movl (%esi), %ebx )
24807 adcl %ebx, %eax
24808 -DST( movl %ebx, (%edi) )
24809 +DST( movl %ebx, %es:(%edi) )
24810 lea 4(%esi), %esi
24811 lea 4(%edi), %edi
24812 dec %edx
24813 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24814 jb 5f
24815 SRC( movw (%esi), %cx )
24816 leal 2(%esi), %esi
24817 -DST( movw %cx, (%edi) )
24818 +DST( movw %cx, %es:(%edi) )
24819 leal 2(%edi), %edi
24820 je 6f
24821 shll $16,%ecx
24822 SRC(5: movb (%esi), %cl )
24823 -DST( movb %cl, (%edi) )
24824 +DST( movb %cl, %es:(%edi) )
24825 6: addl %ecx, %eax
24826 adcl $0, %eax
24827 7:
24828 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24829
24830 6001:
24831 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24832 - movl $-EFAULT, (%ebx)
24833 + movl $-EFAULT, %ss:(%ebx)
24834
24835 # zero the complete destination - computing the rest
24836 # is too much work
24837 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24838
24839 6002:
24840 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24841 - movl $-EFAULT,(%ebx)
24842 + movl $-EFAULT,%ss:(%ebx)
24843 jmp 5000b
24844
24845 .previous
24846
24847 + pushl_cfi %ss
24848 + popl_cfi %ds
24849 + pushl_cfi %ss
24850 + popl_cfi %es
24851 popl_cfi %ebx
24852 CFI_RESTORE ebx
24853 popl_cfi %esi
24854 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24855 popl_cfi %ecx # equivalent to addl $4,%esp
24856 ret
24857 CFI_ENDPROC
24858 -ENDPROC(csum_partial_copy_generic)
24859 +ENDPROC(csum_partial_copy_generic_to_user)
24860
24861 #else
24862
24863 /* Version for PentiumII/PPro */
24864
24865 #define ROUND1(x) \
24866 + nop; nop; nop; \
24867 SRC(movl x(%esi), %ebx ) ; \
24868 addl %ebx, %eax ; \
24869 - DST(movl %ebx, x(%edi) ) ;
24870 + DST(movl %ebx, %es:x(%edi)) ;
24871
24872 #define ROUND(x) \
24873 + nop; nop; nop; \
24874 SRC(movl x(%esi), %ebx ) ; \
24875 adcl %ebx, %eax ; \
24876 - DST(movl %ebx, x(%edi) ) ;
24877 + DST(movl %ebx, %es:x(%edi)) ;
24878
24879 #define ARGBASE 12
24880 -
24881 -ENTRY(csum_partial_copy_generic)
24882 +
24883 +ENTRY(csum_partial_copy_generic_to_user)
24884 CFI_STARTPROC
24885 +
24886 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24887 + pushl_cfi %gs
24888 + popl_cfi %es
24889 + jmp csum_partial_copy_generic
24890 +#endif
24891 +
24892 +ENTRY(csum_partial_copy_generic_from_user)
24893 +
24894 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24895 + pushl_cfi %gs
24896 + popl_cfi %ds
24897 +#endif
24898 +
24899 +ENTRY(csum_partial_copy_generic)
24900 pushl_cfi %ebx
24901 CFI_REL_OFFSET ebx, 0
24902 pushl_cfi %edi
24903 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24904 subl %ebx, %edi
24905 lea -1(%esi),%edx
24906 andl $-32,%edx
24907 - lea 3f(%ebx,%ebx), %ebx
24908 + lea 3f(%ebx,%ebx,2), %ebx
24909 testl %esi, %esi
24910 jmp *%ebx
24911 1: addl $64,%esi
24912 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24913 jb 5f
24914 SRC( movw (%esi), %dx )
24915 leal 2(%esi), %esi
24916 -DST( movw %dx, (%edi) )
24917 +DST( movw %dx, %es:(%edi) )
24918 leal 2(%edi), %edi
24919 je 6f
24920 shll $16,%edx
24921 5:
24922 SRC( movb (%esi), %dl )
24923 -DST( movb %dl, (%edi) )
24924 +DST( movb %dl, %es:(%edi) )
24925 6: addl %edx, %eax
24926 adcl $0, %eax
24927 7:
24928 .section .fixup, "ax"
24929 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24930 - movl $-EFAULT, (%ebx)
24931 + movl $-EFAULT, %ss:(%ebx)
24932 # zero the complete destination (computing the rest is too much work)
24933 movl ARGBASE+8(%esp),%edi # dst
24934 movl ARGBASE+12(%esp),%ecx # len
24935 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24936 rep; stosb
24937 jmp 7b
24938 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24939 - movl $-EFAULT, (%ebx)
24940 + movl $-EFAULT, %ss:(%ebx)
24941 jmp 7b
24942 .previous
24943
24944 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24945 + pushl_cfi %ss
24946 + popl_cfi %ds
24947 + pushl_cfi %ss
24948 + popl_cfi %es
24949 +#endif
24950 +
24951 popl_cfi %esi
24952 CFI_RESTORE esi
24953 popl_cfi %edi
24954 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
24955 CFI_RESTORE ebx
24956 ret
24957 CFI_ENDPROC
24958 -ENDPROC(csum_partial_copy_generic)
24959 +ENDPROC(csum_partial_copy_generic_to_user)
24960
24961 #undef ROUND
24962 #undef ROUND1
24963 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
24964 index f2145cf..cea889d 100644
24965 --- a/arch/x86/lib/clear_page_64.S
24966 +++ b/arch/x86/lib/clear_page_64.S
24967 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
24968 movl $4096/8,%ecx
24969 xorl %eax,%eax
24970 rep stosq
24971 + pax_force_retaddr
24972 ret
24973 CFI_ENDPROC
24974 ENDPROC(clear_page_c)
24975 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
24976 movl $4096,%ecx
24977 xorl %eax,%eax
24978 rep stosb
24979 + pax_force_retaddr
24980 ret
24981 CFI_ENDPROC
24982 ENDPROC(clear_page_c_e)
24983 @@ -43,6 +45,7 @@ ENTRY(clear_page)
24984 leaq 64(%rdi),%rdi
24985 jnz .Lloop
24986 nop
24987 + pax_force_retaddr
24988 ret
24989 CFI_ENDPROC
24990 .Lclear_page_end:
24991 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
24992
24993 #include <asm/cpufeature.h>
24994
24995 - .section .altinstr_replacement,"ax"
24996 + .section .altinstr_replacement,"a"
24997 1: .byte 0xeb /* jmp <disp8> */
24998 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
24999 2: .byte 0xeb /* jmp <disp8> */
25000 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25001 index 1e572c5..2a162cd 100644
25002 --- a/arch/x86/lib/cmpxchg16b_emu.S
25003 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25004 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25005
25006 popf
25007 mov $1, %al
25008 + pax_force_retaddr
25009 ret
25010
25011 not_same:
25012 popf
25013 xor %al,%al
25014 + pax_force_retaddr
25015 ret
25016
25017 CFI_ENDPROC
25018 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25019 index 176cca6..1166c50 100644
25020 --- a/arch/x86/lib/copy_page_64.S
25021 +++ b/arch/x86/lib/copy_page_64.S
25022 @@ -9,6 +9,7 @@ copy_page_rep:
25023 CFI_STARTPROC
25024 movl $4096/8, %ecx
25025 rep movsq
25026 + pax_force_retaddr
25027 ret
25028 CFI_ENDPROC
25029 ENDPROC(copy_page_rep)
25030 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25031
25032 ENTRY(copy_page)
25033 CFI_STARTPROC
25034 - subq $2*8, %rsp
25035 - CFI_ADJUST_CFA_OFFSET 2*8
25036 + subq $3*8, %rsp
25037 + CFI_ADJUST_CFA_OFFSET 3*8
25038 movq %rbx, (%rsp)
25039 CFI_REL_OFFSET rbx, 0
25040 movq %r12, 1*8(%rsp)
25041 CFI_REL_OFFSET r12, 1*8
25042 + movq %r13, 2*8(%rsp)
25043 + CFI_REL_OFFSET r13, 2*8
25044
25045 movl $(4096/64)-5, %ecx
25046 .p2align 4
25047 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25048 movq 0x8*2(%rsi), %rdx
25049 movq 0x8*3(%rsi), %r8
25050 movq 0x8*4(%rsi), %r9
25051 - movq 0x8*5(%rsi), %r10
25052 + movq 0x8*5(%rsi), %r13
25053 movq 0x8*6(%rsi), %r11
25054 movq 0x8*7(%rsi), %r12
25055
25056 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25057 movq %rdx, 0x8*2(%rdi)
25058 movq %r8, 0x8*3(%rdi)
25059 movq %r9, 0x8*4(%rdi)
25060 - movq %r10, 0x8*5(%rdi)
25061 + movq %r13, 0x8*5(%rdi)
25062 movq %r11, 0x8*6(%rdi)
25063 movq %r12, 0x8*7(%rdi)
25064
25065 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25066 movq 0x8*2(%rsi), %rdx
25067 movq 0x8*3(%rsi), %r8
25068 movq 0x8*4(%rsi), %r9
25069 - movq 0x8*5(%rsi), %r10
25070 + movq 0x8*5(%rsi), %r13
25071 movq 0x8*6(%rsi), %r11
25072 movq 0x8*7(%rsi), %r12
25073
25074 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25075 movq %rdx, 0x8*2(%rdi)
25076 movq %r8, 0x8*3(%rdi)
25077 movq %r9, 0x8*4(%rdi)
25078 - movq %r10, 0x8*5(%rdi)
25079 + movq %r13, 0x8*5(%rdi)
25080 movq %r11, 0x8*6(%rdi)
25081 movq %r12, 0x8*7(%rdi)
25082
25083 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25084 CFI_RESTORE rbx
25085 movq 1*8(%rsp), %r12
25086 CFI_RESTORE r12
25087 - addq $2*8, %rsp
25088 - CFI_ADJUST_CFA_OFFSET -2*8
25089 + movq 2*8(%rsp), %r13
25090 + CFI_RESTORE r13
25091 + addq $3*8, %rsp
25092 + CFI_ADJUST_CFA_OFFSET -3*8
25093 + pax_force_retaddr
25094 ret
25095 .Lcopy_page_end:
25096 CFI_ENDPROC
25097 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25098
25099 #include <asm/cpufeature.h>
25100
25101 - .section .altinstr_replacement,"ax"
25102 + .section .altinstr_replacement,"a"
25103 1: .byte 0xeb /* jmp <disp8> */
25104 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25105 2:
25106 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25107 index a30ca15..d25fab6 100644
25108 --- a/arch/x86/lib/copy_user_64.S
25109 +++ b/arch/x86/lib/copy_user_64.S
25110 @@ -18,6 +18,7 @@
25111 #include <asm/alternative-asm.h>
25112 #include <asm/asm.h>
25113 #include <asm/smap.h>
25114 +#include <asm/pgtable.h>
25115
25116 /*
25117 * By placing feature2 after feature1 in altinstructions section, we logically
25118 @@ -31,7 +32,7 @@
25119 .byte 0xe9 /* 32bit jump */
25120 .long \orig-1f /* by default jump to orig */
25121 1:
25122 - .section .altinstr_replacement,"ax"
25123 + .section .altinstr_replacement,"a"
25124 2: .byte 0xe9 /* near jump with 32bit immediate */
25125 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25126 3: .byte 0xe9 /* near jump with 32bit immediate */
25127 @@ -70,47 +71,20 @@
25128 #endif
25129 .endm
25130
25131 -/* Standard copy_to_user with segment limit checking */
25132 -ENTRY(_copy_to_user)
25133 - CFI_STARTPROC
25134 - GET_THREAD_INFO(%rax)
25135 - movq %rdi,%rcx
25136 - addq %rdx,%rcx
25137 - jc bad_to_user
25138 - cmpq TI_addr_limit(%rax),%rcx
25139 - ja bad_to_user
25140 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25141 - copy_user_generic_unrolled,copy_user_generic_string, \
25142 - copy_user_enhanced_fast_string
25143 - CFI_ENDPROC
25144 -ENDPROC(_copy_to_user)
25145 -
25146 -/* Standard copy_from_user with segment limit checking */
25147 -ENTRY(_copy_from_user)
25148 - CFI_STARTPROC
25149 - GET_THREAD_INFO(%rax)
25150 - movq %rsi,%rcx
25151 - addq %rdx,%rcx
25152 - jc bad_from_user
25153 - cmpq TI_addr_limit(%rax),%rcx
25154 - ja bad_from_user
25155 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25156 - copy_user_generic_unrolled,copy_user_generic_string, \
25157 - copy_user_enhanced_fast_string
25158 - CFI_ENDPROC
25159 -ENDPROC(_copy_from_user)
25160 -
25161 .section .fixup,"ax"
25162 /* must zero dest */
25163 ENTRY(bad_from_user)
25164 bad_from_user:
25165 CFI_STARTPROC
25166 + testl %edx,%edx
25167 + js bad_to_user
25168 movl %edx,%ecx
25169 xorl %eax,%eax
25170 rep
25171 stosb
25172 bad_to_user:
25173 movl %edx,%eax
25174 + pax_force_retaddr
25175 ret
25176 CFI_ENDPROC
25177 ENDPROC(bad_from_user)
25178 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25179 jz 17f
25180 1: movq (%rsi),%r8
25181 2: movq 1*8(%rsi),%r9
25182 -3: movq 2*8(%rsi),%r10
25183 +3: movq 2*8(%rsi),%rax
25184 4: movq 3*8(%rsi),%r11
25185 5: movq %r8,(%rdi)
25186 6: movq %r9,1*8(%rdi)
25187 -7: movq %r10,2*8(%rdi)
25188 +7: movq %rax,2*8(%rdi)
25189 8: movq %r11,3*8(%rdi)
25190 9: movq 4*8(%rsi),%r8
25191 10: movq 5*8(%rsi),%r9
25192 -11: movq 6*8(%rsi),%r10
25193 +11: movq 6*8(%rsi),%rax
25194 12: movq 7*8(%rsi),%r11
25195 13: movq %r8,4*8(%rdi)
25196 14: movq %r9,5*8(%rdi)
25197 -15: movq %r10,6*8(%rdi)
25198 +15: movq %rax,6*8(%rdi)
25199 16: movq %r11,7*8(%rdi)
25200 leaq 64(%rsi),%rsi
25201 leaq 64(%rdi),%rdi
25202 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25203 jnz 21b
25204 23: xor %eax,%eax
25205 ASM_CLAC
25206 + pax_force_retaddr
25207 ret
25208
25209 .section .fixup,"ax"
25210 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25211 movsb
25212 4: xorl %eax,%eax
25213 ASM_CLAC
25214 + pax_force_retaddr
25215 ret
25216
25217 .section .fixup,"ax"
25218 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25219 movsb
25220 2: xorl %eax,%eax
25221 ASM_CLAC
25222 + pax_force_retaddr
25223 ret
25224
25225 .section .fixup,"ax"
25226 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25227 index 6a4f43c..f08b4a2 100644
25228 --- a/arch/x86/lib/copy_user_nocache_64.S
25229 +++ b/arch/x86/lib/copy_user_nocache_64.S
25230 @@ -8,6 +8,7 @@
25231
25232 #include <linux/linkage.h>
25233 #include <asm/dwarf2.h>
25234 +#include <asm/alternative-asm.h>
25235
25236 #define FIX_ALIGNMENT 1
25237
25238 @@ -16,6 +17,7 @@
25239 #include <asm/thread_info.h>
25240 #include <asm/asm.h>
25241 #include <asm/smap.h>
25242 +#include <asm/pgtable.h>
25243
25244 .macro ALIGN_DESTINATION
25245 #ifdef FIX_ALIGNMENT
25246 @@ -49,6 +51,15 @@
25247 */
25248 ENTRY(__copy_user_nocache)
25249 CFI_STARTPROC
25250 +
25251 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25252 + mov pax_user_shadow_base,%rcx
25253 + cmp %rcx,%rsi
25254 + jae 1f
25255 + add %rcx,%rsi
25256 +1:
25257 +#endif
25258 +
25259 ASM_STAC
25260 cmpl $8,%edx
25261 jb 20f /* less then 8 bytes, go to byte copy loop */
25262 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25263 jz 17f
25264 1: movq (%rsi),%r8
25265 2: movq 1*8(%rsi),%r9
25266 -3: movq 2*8(%rsi),%r10
25267 +3: movq 2*8(%rsi),%rax
25268 4: movq 3*8(%rsi),%r11
25269 5: movnti %r8,(%rdi)
25270 6: movnti %r9,1*8(%rdi)
25271 -7: movnti %r10,2*8(%rdi)
25272 +7: movnti %rax,2*8(%rdi)
25273 8: movnti %r11,3*8(%rdi)
25274 9: movq 4*8(%rsi),%r8
25275 10: movq 5*8(%rsi),%r9
25276 -11: movq 6*8(%rsi),%r10
25277 +11: movq 6*8(%rsi),%rax
25278 12: movq 7*8(%rsi),%r11
25279 13: movnti %r8,4*8(%rdi)
25280 14: movnti %r9,5*8(%rdi)
25281 -15: movnti %r10,6*8(%rdi)
25282 +15: movnti %rax,6*8(%rdi)
25283 16: movnti %r11,7*8(%rdi)
25284 leaq 64(%rsi),%rsi
25285 leaq 64(%rdi),%rdi
25286 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25287 23: xorl %eax,%eax
25288 ASM_CLAC
25289 sfence
25290 + pax_force_retaddr
25291 ret
25292
25293 .section .fixup,"ax"
25294 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25295 index 2419d5f..953ee51 100644
25296 --- a/arch/x86/lib/csum-copy_64.S
25297 +++ b/arch/x86/lib/csum-copy_64.S
25298 @@ -9,6 +9,7 @@
25299 #include <asm/dwarf2.h>
25300 #include <asm/errno.h>
25301 #include <asm/asm.h>
25302 +#include <asm/alternative-asm.h>
25303
25304 /*
25305 * Checksum copy with exception handling.
25306 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25307 CFI_RESTORE rbp
25308 addq $7*8, %rsp
25309 CFI_ADJUST_CFA_OFFSET -7*8
25310 + pax_force_retaddr 0, 1
25311 ret
25312 CFI_RESTORE_STATE
25313
25314 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25315 index 25b7ae8..169fafc 100644
25316 --- a/arch/x86/lib/csum-wrappers_64.c
25317 +++ b/arch/x86/lib/csum-wrappers_64.c
25318 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25319 len -= 2;
25320 }
25321 }
25322 - isum = csum_partial_copy_generic((__force const void *)src,
25323 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25324 dst, len, isum, errp, NULL);
25325 if (unlikely(*errp))
25326 goto out_err;
25327 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25328 }
25329
25330 *errp = 0;
25331 - return csum_partial_copy_generic(src, (void __force *)dst,
25332 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25333 len, isum, NULL, errp);
25334 }
25335 EXPORT_SYMBOL(csum_partial_copy_to_user);
25336 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25337 index a451235..79fb5cf 100644
25338 --- a/arch/x86/lib/getuser.S
25339 +++ b/arch/x86/lib/getuser.S
25340 @@ -33,17 +33,40 @@
25341 #include <asm/thread_info.h>
25342 #include <asm/asm.h>
25343 #include <asm/smap.h>
25344 +#include <asm/segment.h>
25345 +#include <asm/pgtable.h>
25346 +#include <asm/alternative-asm.h>
25347 +
25348 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25349 +#define __copyuser_seg gs;
25350 +#else
25351 +#define __copyuser_seg
25352 +#endif
25353
25354 .text
25355 ENTRY(__get_user_1)
25356 CFI_STARTPROC
25357 +
25358 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25359 GET_THREAD_INFO(%_ASM_DX)
25360 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25361 jae bad_get_user
25362 ASM_STAC
25363 -1: movzbl (%_ASM_AX),%edx
25364 +
25365 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25366 + mov pax_user_shadow_base,%_ASM_DX
25367 + cmp %_ASM_DX,%_ASM_AX
25368 + jae 1234f
25369 + add %_ASM_DX,%_ASM_AX
25370 +1234:
25371 +#endif
25372 +
25373 +#endif
25374 +
25375 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25376 xor %eax,%eax
25377 ASM_CLAC
25378 + pax_force_retaddr
25379 ret
25380 CFI_ENDPROC
25381 ENDPROC(__get_user_1)
25382 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25383 ENTRY(__get_user_2)
25384 CFI_STARTPROC
25385 add $1,%_ASM_AX
25386 +
25387 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25388 jc bad_get_user
25389 GET_THREAD_INFO(%_ASM_DX)
25390 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25391 jae bad_get_user
25392 ASM_STAC
25393 -2: movzwl -1(%_ASM_AX),%edx
25394 +
25395 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25396 + mov pax_user_shadow_base,%_ASM_DX
25397 + cmp %_ASM_DX,%_ASM_AX
25398 + jae 1234f
25399 + add %_ASM_DX,%_ASM_AX
25400 +1234:
25401 +#endif
25402 +
25403 +#endif
25404 +
25405 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25406 xor %eax,%eax
25407 ASM_CLAC
25408 + pax_force_retaddr
25409 ret
25410 CFI_ENDPROC
25411 ENDPROC(__get_user_2)
25412 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25413 ENTRY(__get_user_4)
25414 CFI_STARTPROC
25415 add $3,%_ASM_AX
25416 +
25417 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25418 jc bad_get_user
25419 GET_THREAD_INFO(%_ASM_DX)
25420 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25421 jae bad_get_user
25422 ASM_STAC
25423 -3: movl -3(%_ASM_AX),%edx
25424 +
25425 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25426 + mov pax_user_shadow_base,%_ASM_DX
25427 + cmp %_ASM_DX,%_ASM_AX
25428 + jae 1234f
25429 + add %_ASM_DX,%_ASM_AX
25430 +1234:
25431 +#endif
25432 +
25433 +#endif
25434 +
25435 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25436 xor %eax,%eax
25437 ASM_CLAC
25438 + pax_force_retaddr
25439 ret
25440 CFI_ENDPROC
25441 ENDPROC(__get_user_4)
25442 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25443 GET_THREAD_INFO(%_ASM_DX)
25444 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25445 jae bad_get_user
25446 +
25447 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25448 + mov pax_user_shadow_base,%_ASM_DX
25449 + cmp %_ASM_DX,%_ASM_AX
25450 + jae 1234f
25451 + add %_ASM_DX,%_ASM_AX
25452 +1234:
25453 +#endif
25454 +
25455 ASM_STAC
25456 4: movq -7(%_ASM_AX),%rdx
25457 xor %eax,%eax
25458 ASM_CLAC
25459 + pax_force_retaddr
25460 ret
25461 #else
25462 add $7,%_ASM_AX
25463 @@ -102,6 +163,7 @@ ENTRY(__get_user_8)
25464 5: movl -3(%_ASM_AX),%ecx
25465 xor %eax,%eax
25466 ASM_CLAC
25467 + pax_force_retaddr
25468 ret
25469 #endif
25470 CFI_ENDPROC
25471 @@ -113,6 +175,7 @@ bad_get_user:
25472 xor %edx,%edx
25473 mov $(-EFAULT),%_ASM_AX
25474 ASM_CLAC
25475 + pax_force_retaddr
25476 ret
25477 CFI_ENDPROC
25478 END(bad_get_user)
25479 @@ -124,6 +187,7 @@ bad_get_user_8:
25480 xor %ecx,%ecx
25481 mov $(-EFAULT),%_ASM_AX
25482 ASM_CLAC
25483 + pax_force_retaddr
25484 ret
25485 CFI_ENDPROC
25486 END(bad_get_user_8)
25487 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25488 index 54fcffe..7be149e 100644
25489 --- a/arch/x86/lib/insn.c
25490 +++ b/arch/x86/lib/insn.c
25491 @@ -20,8 +20,10 @@
25492
25493 #ifdef __KERNEL__
25494 #include <linux/string.h>
25495 +#include <asm/pgtable_types.h>
25496 #else
25497 #include <string.h>
25498 +#define ktla_ktva(addr) addr
25499 #endif
25500 #include <asm/inat.h>
25501 #include <asm/insn.h>
25502 @@ -53,8 +55,8 @@
25503 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25504 {
25505 memset(insn, 0, sizeof(*insn));
25506 - insn->kaddr = kaddr;
25507 - insn->next_byte = kaddr;
25508 + insn->kaddr = ktla_ktva(kaddr);
25509 + insn->next_byte = ktla_ktva(kaddr);
25510 insn->x86_64 = x86_64 ? 1 : 0;
25511 insn->opnd_bytes = 4;
25512 if (x86_64)
25513 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25514 index 05a95e7..326f2fa 100644
25515 --- a/arch/x86/lib/iomap_copy_64.S
25516 +++ b/arch/x86/lib/iomap_copy_64.S
25517 @@ -17,6 +17,7 @@
25518
25519 #include <linux/linkage.h>
25520 #include <asm/dwarf2.h>
25521 +#include <asm/alternative-asm.h>
25522
25523 /*
25524 * override generic version in lib/iomap_copy.c
25525 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25526 CFI_STARTPROC
25527 movl %edx,%ecx
25528 rep movsd
25529 + pax_force_retaddr
25530 ret
25531 CFI_ENDPROC
25532 ENDPROC(__iowrite32_copy)
25533 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25534 index 1c273be..da9cc0e 100644
25535 --- a/arch/x86/lib/memcpy_64.S
25536 +++ b/arch/x86/lib/memcpy_64.S
25537 @@ -33,6 +33,7 @@
25538 rep movsq
25539 movl %edx, %ecx
25540 rep movsb
25541 + pax_force_retaddr
25542 ret
25543 .Lmemcpy_e:
25544 .previous
25545 @@ -49,6 +50,7 @@
25546 movq %rdi, %rax
25547 movq %rdx, %rcx
25548 rep movsb
25549 + pax_force_retaddr
25550 ret
25551 .Lmemcpy_e_e:
25552 .previous
25553 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25554 */
25555 movq 0*8(%rsi), %r8
25556 movq 1*8(%rsi), %r9
25557 - movq 2*8(%rsi), %r10
25558 + movq 2*8(%rsi), %rcx
25559 movq 3*8(%rsi), %r11
25560 leaq 4*8(%rsi), %rsi
25561
25562 movq %r8, 0*8(%rdi)
25563 movq %r9, 1*8(%rdi)
25564 - movq %r10, 2*8(%rdi)
25565 + movq %rcx, 2*8(%rdi)
25566 movq %r11, 3*8(%rdi)
25567 leaq 4*8(%rdi), %rdi
25568 jae .Lcopy_forward_loop
25569 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25570 subq $0x20, %rdx
25571 movq -1*8(%rsi), %r8
25572 movq -2*8(%rsi), %r9
25573 - movq -3*8(%rsi), %r10
25574 + movq -3*8(%rsi), %rcx
25575 movq -4*8(%rsi), %r11
25576 leaq -4*8(%rsi), %rsi
25577 movq %r8, -1*8(%rdi)
25578 movq %r9, -2*8(%rdi)
25579 - movq %r10, -3*8(%rdi)
25580 + movq %rcx, -3*8(%rdi)
25581 movq %r11, -4*8(%rdi)
25582 leaq -4*8(%rdi), %rdi
25583 jae .Lcopy_backward_loop
25584 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25585 */
25586 movq 0*8(%rsi), %r8
25587 movq 1*8(%rsi), %r9
25588 - movq -2*8(%rsi, %rdx), %r10
25589 + movq -2*8(%rsi, %rdx), %rcx
25590 movq -1*8(%rsi, %rdx), %r11
25591 movq %r8, 0*8(%rdi)
25592 movq %r9, 1*8(%rdi)
25593 - movq %r10, -2*8(%rdi, %rdx)
25594 + movq %rcx, -2*8(%rdi, %rdx)
25595 movq %r11, -1*8(%rdi, %rdx)
25596 + pax_force_retaddr
25597 retq
25598 .p2align 4
25599 .Lless_16bytes:
25600 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25601 movq -1*8(%rsi, %rdx), %r9
25602 movq %r8, 0*8(%rdi)
25603 movq %r9, -1*8(%rdi, %rdx)
25604 + pax_force_retaddr
25605 retq
25606 .p2align 4
25607 .Lless_8bytes:
25608 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25609 movl -4(%rsi, %rdx), %r8d
25610 movl %ecx, (%rdi)
25611 movl %r8d, -4(%rdi, %rdx)
25612 + pax_force_retaddr
25613 retq
25614 .p2align 4
25615 .Lless_3bytes:
25616 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25617 movb %cl, (%rdi)
25618
25619 .Lend:
25620 + pax_force_retaddr
25621 retq
25622 CFI_ENDPROC
25623 ENDPROC(memcpy)
25624 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25625 index ee16461..c39c199 100644
25626 --- a/arch/x86/lib/memmove_64.S
25627 +++ b/arch/x86/lib/memmove_64.S
25628 @@ -61,13 +61,13 @@ ENTRY(memmove)
25629 5:
25630 sub $0x20, %rdx
25631 movq 0*8(%rsi), %r11
25632 - movq 1*8(%rsi), %r10
25633 + movq 1*8(%rsi), %rcx
25634 movq 2*8(%rsi), %r9
25635 movq 3*8(%rsi), %r8
25636 leaq 4*8(%rsi), %rsi
25637
25638 movq %r11, 0*8(%rdi)
25639 - movq %r10, 1*8(%rdi)
25640 + movq %rcx, 1*8(%rdi)
25641 movq %r9, 2*8(%rdi)
25642 movq %r8, 3*8(%rdi)
25643 leaq 4*8(%rdi), %rdi
25644 @@ -81,10 +81,10 @@ ENTRY(memmove)
25645 4:
25646 movq %rdx, %rcx
25647 movq -8(%rsi, %rdx), %r11
25648 - lea -8(%rdi, %rdx), %r10
25649 + lea -8(%rdi, %rdx), %r9
25650 shrq $3, %rcx
25651 rep movsq
25652 - movq %r11, (%r10)
25653 + movq %r11, (%r9)
25654 jmp 13f
25655 .Lmemmove_end_forward:
25656
25657 @@ -95,14 +95,14 @@ ENTRY(memmove)
25658 7:
25659 movq %rdx, %rcx
25660 movq (%rsi), %r11
25661 - movq %rdi, %r10
25662 + movq %rdi, %r9
25663 leaq -8(%rsi, %rdx), %rsi
25664 leaq -8(%rdi, %rdx), %rdi
25665 shrq $3, %rcx
25666 std
25667 rep movsq
25668 cld
25669 - movq %r11, (%r10)
25670 + movq %r11, (%r9)
25671 jmp 13f
25672
25673 /*
25674 @@ -127,13 +127,13 @@ ENTRY(memmove)
25675 8:
25676 subq $0x20, %rdx
25677 movq -1*8(%rsi), %r11
25678 - movq -2*8(%rsi), %r10
25679 + movq -2*8(%rsi), %rcx
25680 movq -3*8(%rsi), %r9
25681 movq -4*8(%rsi), %r8
25682 leaq -4*8(%rsi), %rsi
25683
25684 movq %r11, -1*8(%rdi)
25685 - movq %r10, -2*8(%rdi)
25686 + movq %rcx, -2*8(%rdi)
25687 movq %r9, -3*8(%rdi)
25688 movq %r8, -4*8(%rdi)
25689 leaq -4*8(%rdi), %rdi
25690 @@ -151,11 +151,11 @@ ENTRY(memmove)
25691 * Move data from 16 bytes to 31 bytes.
25692 */
25693 movq 0*8(%rsi), %r11
25694 - movq 1*8(%rsi), %r10
25695 + movq 1*8(%rsi), %rcx
25696 movq -2*8(%rsi, %rdx), %r9
25697 movq -1*8(%rsi, %rdx), %r8
25698 movq %r11, 0*8(%rdi)
25699 - movq %r10, 1*8(%rdi)
25700 + movq %rcx, 1*8(%rdi)
25701 movq %r9, -2*8(%rdi, %rdx)
25702 movq %r8, -1*8(%rdi, %rdx)
25703 jmp 13f
25704 @@ -167,9 +167,9 @@ ENTRY(memmove)
25705 * Move data from 8 bytes to 15 bytes.
25706 */
25707 movq 0*8(%rsi), %r11
25708 - movq -1*8(%rsi, %rdx), %r10
25709 + movq -1*8(%rsi, %rdx), %r9
25710 movq %r11, 0*8(%rdi)
25711 - movq %r10, -1*8(%rdi, %rdx)
25712 + movq %r9, -1*8(%rdi, %rdx)
25713 jmp 13f
25714 10:
25715 cmpq $4, %rdx
25716 @@ -178,9 +178,9 @@ ENTRY(memmove)
25717 * Move data from 4 bytes to 7 bytes.
25718 */
25719 movl (%rsi), %r11d
25720 - movl -4(%rsi, %rdx), %r10d
25721 + movl -4(%rsi, %rdx), %r9d
25722 movl %r11d, (%rdi)
25723 - movl %r10d, -4(%rdi, %rdx)
25724 + movl %r9d, -4(%rdi, %rdx)
25725 jmp 13f
25726 11:
25727 cmp $2, %rdx
25728 @@ -189,9 +189,9 @@ ENTRY(memmove)
25729 * Move data from 2 bytes to 3 bytes.
25730 */
25731 movw (%rsi), %r11w
25732 - movw -2(%rsi, %rdx), %r10w
25733 + movw -2(%rsi, %rdx), %r9w
25734 movw %r11w, (%rdi)
25735 - movw %r10w, -2(%rdi, %rdx)
25736 + movw %r9w, -2(%rdi, %rdx)
25737 jmp 13f
25738 12:
25739 cmp $1, %rdx
25740 @@ -202,6 +202,7 @@ ENTRY(memmove)
25741 movb (%rsi), %r11b
25742 movb %r11b, (%rdi)
25743 13:
25744 + pax_force_retaddr
25745 retq
25746 CFI_ENDPROC
25747
25748 @@ -210,6 +211,7 @@ ENTRY(memmove)
25749 /* Forward moving data. */
25750 movq %rdx, %rcx
25751 rep movsb
25752 + pax_force_retaddr
25753 retq
25754 .Lmemmove_end_forward_efs:
25755 .previous
25756 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25757 index 2dcb380..963660a 100644
25758 --- a/arch/x86/lib/memset_64.S
25759 +++ b/arch/x86/lib/memset_64.S
25760 @@ -30,6 +30,7 @@
25761 movl %edx,%ecx
25762 rep stosb
25763 movq %r9,%rax
25764 + pax_force_retaddr
25765 ret
25766 .Lmemset_e:
25767 .previous
25768 @@ -52,6 +53,7 @@
25769 movq %rdx,%rcx
25770 rep stosb
25771 movq %r9,%rax
25772 + pax_force_retaddr
25773 ret
25774 .Lmemset_e_e:
25775 .previous
25776 @@ -59,7 +61,7 @@
25777 ENTRY(memset)
25778 ENTRY(__memset)
25779 CFI_STARTPROC
25780 - movq %rdi,%r10
25781 + movq %rdi,%r11
25782
25783 /* expand byte value */
25784 movzbl %sil,%ecx
25785 @@ -117,7 +119,8 @@ ENTRY(__memset)
25786 jnz .Lloop_1
25787
25788 .Lende:
25789 - movq %r10,%rax
25790 + movq %r11,%rax
25791 + pax_force_retaddr
25792 ret
25793
25794 CFI_RESTORE_STATE
25795 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25796 index c9f2d9b..e7fd2c0 100644
25797 --- a/arch/x86/lib/mmx_32.c
25798 +++ b/arch/x86/lib/mmx_32.c
25799 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25800 {
25801 void *p;
25802 int i;
25803 + unsigned long cr0;
25804
25805 if (unlikely(in_interrupt()))
25806 return __memcpy(to, from, len);
25807 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25808 kernel_fpu_begin();
25809
25810 __asm__ __volatile__ (
25811 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25812 - " prefetch 64(%0)\n"
25813 - " prefetch 128(%0)\n"
25814 - " prefetch 192(%0)\n"
25815 - " prefetch 256(%0)\n"
25816 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25817 + " prefetch 64(%1)\n"
25818 + " prefetch 128(%1)\n"
25819 + " prefetch 192(%1)\n"
25820 + " prefetch 256(%1)\n"
25821 "2: \n"
25822 ".section .fixup, \"ax\"\n"
25823 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25824 + "3: \n"
25825 +
25826 +#ifdef CONFIG_PAX_KERNEXEC
25827 + " movl %%cr0, %0\n"
25828 + " movl %0, %%eax\n"
25829 + " andl $0xFFFEFFFF, %%eax\n"
25830 + " movl %%eax, %%cr0\n"
25831 +#endif
25832 +
25833 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25834 +
25835 +#ifdef CONFIG_PAX_KERNEXEC
25836 + " movl %0, %%cr0\n"
25837 +#endif
25838 +
25839 " jmp 2b\n"
25840 ".previous\n"
25841 _ASM_EXTABLE(1b, 3b)
25842 - : : "r" (from));
25843 + : "=&r" (cr0) : "r" (from) : "ax");
25844
25845 for ( ; i > 5; i--) {
25846 __asm__ __volatile__ (
25847 - "1: prefetch 320(%0)\n"
25848 - "2: movq (%0), %%mm0\n"
25849 - " movq 8(%0), %%mm1\n"
25850 - " movq 16(%0), %%mm2\n"
25851 - " movq 24(%0), %%mm3\n"
25852 - " movq %%mm0, (%1)\n"
25853 - " movq %%mm1, 8(%1)\n"
25854 - " movq %%mm2, 16(%1)\n"
25855 - " movq %%mm3, 24(%1)\n"
25856 - " movq 32(%0), %%mm0\n"
25857 - " movq 40(%0), %%mm1\n"
25858 - " movq 48(%0), %%mm2\n"
25859 - " movq 56(%0), %%mm3\n"
25860 - " movq %%mm0, 32(%1)\n"
25861 - " movq %%mm1, 40(%1)\n"
25862 - " movq %%mm2, 48(%1)\n"
25863 - " movq %%mm3, 56(%1)\n"
25864 + "1: prefetch 320(%1)\n"
25865 + "2: movq (%1), %%mm0\n"
25866 + " movq 8(%1), %%mm1\n"
25867 + " movq 16(%1), %%mm2\n"
25868 + " movq 24(%1), %%mm3\n"
25869 + " movq %%mm0, (%2)\n"
25870 + " movq %%mm1, 8(%2)\n"
25871 + " movq %%mm2, 16(%2)\n"
25872 + " movq %%mm3, 24(%2)\n"
25873 + " movq 32(%1), %%mm0\n"
25874 + " movq 40(%1), %%mm1\n"
25875 + " movq 48(%1), %%mm2\n"
25876 + " movq 56(%1), %%mm3\n"
25877 + " movq %%mm0, 32(%2)\n"
25878 + " movq %%mm1, 40(%2)\n"
25879 + " movq %%mm2, 48(%2)\n"
25880 + " movq %%mm3, 56(%2)\n"
25881 ".section .fixup, \"ax\"\n"
25882 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25883 + "3:\n"
25884 +
25885 +#ifdef CONFIG_PAX_KERNEXEC
25886 + " movl %%cr0, %0\n"
25887 + " movl %0, %%eax\n"
25888 + " andl $0xFFFEFFFF, %%eax\n"
25889 + " movl %%eax, %%cr0\n"
25890 +#endif
25891 +
25892 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25893 +
25894 +#ifdef CONFIG_PAX_KERNEXEC
25895 + " movl %0, %%cr0\n"
25896 +#endif
25897 +
25898 " jmp 2b\n"
25899 ".previous\n"
25900 _ASM_EXTABLE(1b, 3b)
25901 - : : "r" (from), "r" (to) : "memory");
25902 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25903
25904 from += 64;
25905 to += 64;
25906 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25907 static void fast_copy_page(void *to, void *from)
25908 {
25909 int i;
25910 + unsigned long cr0;
25911
25912 kernel_fpu_begin();
25913
25914 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25915 * but that is for later. -AV
25916 */
25917 __asm__ __volatile__(
25918 - "1: prefetch (%0)\n"
25919 - " prefetch 64(%0)\n"
25920 - " prefetch 128(%0)\n"
25921 - " prefetch 192(%0)\n"
25922 - " prefetch 256(%0)\n"
25923 + "1: prefetch (%1)\n"
25924 + " prefetch 64(%1)\n"
25925 + " prefetch 128(%1)\n"
25926 + " prefetch 192(%1)\n"
25927 + " prefetch 256(%1)\n"
25928 "2: \n"
25929 ".section .fixup, \"ax\"\n"
25930 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25931 + "3: \n"
25932 +
25933 +#ifdef CONFIG_PAX_KERNEXEC
25934 + " movl %%cr0, %0\n"
25935 + " movl %0, %%eax\n"
25936 + " andl $0xFFFEFFFF, %%eax\n"
25937 + " movl %%eax, %%cr0\n"
25938 +#endif
25939 +
25940 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25941 +
25942 +#ifdef CONFIG_PAX_KERNEXEC
25943 + " movl %0, %%cr0\n"
25944 +#endif
25945 +
25946 " jmp 2b\n"
25947 ".previous\n"
25948 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25949 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25950
25951 for (i = 0; i < (4096-320)/64; i++) {
25952 __asm__ __volatile__ (
25953 - "1: prefetch 320(%0)\n"
25954 - "2: movq (%0), %%mm0\n"
25955 - " movntq %%mm0, (%1)\n"
25956 - " movq 8(%0), %%mm1\n"
25957 - " movntq %%mm1, 8(%1)\n"
25958 - " movq 16(%0), %%mm2\n"
25959 - " movntq %%mm2, 16(%1)\n"
25960 - " movq 24(%0), %%mm3\n"
25961 - " movntq %%mm3, 24(%1)\n"
25962 - " movq 32(%0), %%mm4\n"
25963 - " movntq %%mm4, 32(%1)\n"
25964 - " movq 40(%0), %%mm5\n"
25965 - " movntq %%mm5, 40(%1)\n"
25966 - " movq 48(%0), %%mm6\n"
25967 - " movntq %%mm6, 48(%1)\n"
25968 - " movq 56(%0), %%mm7\n"
25969 - " movntq %%mm7, 56(%1)\n"
25970 + "1: prefetch 320(%1)\n"
25971 + "2: movq (%1), %%mm0\n"
25972 + " movntq %%mm0, (%2)\n"
25973 + " movq 8(%1), %%mm1\n"
25974 + " movntq %%mm1, 8(%2)\n"
25975 + " movq 16(%1), %%mm2\n"
25976 + " movntq %%mm2, 16(%2)\n"
25977 + " movq 24(%1), %%mm3\n"
25978 + " movntq %%mm3, 24(%2)\n"
25979 + " movq 32(%1), %%mm4\n"
25980 + " movntq %%mm4, 32(%2)\n"
25981 + " movq 40(%1), %%mm5\n"
25982 + " movntq %%mm5, 40(%2)\n"
25983 + " movq 48(%1), %%mm6\n"
25984 + " movntq %%mm6, 48(%2)\n"
25985 + " movq 56(%1), %%mm7\n"
25986 + " movntq %%mm7, 56(%2)\n"
25987 ".section .fixup, \"ax\"\n"
25988 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25989 + "3:\n"
25990 +
25991 +#ifdef CONFIG_PAX_KERNEXEC
25992 + " movl %%cr0, %0\n"
25993 + " movl %0, %%eax\n"
25994 + " andl $0xFFFEFFFF, %%eax\n"
25995 + " movl %%eax, %%cr0\n"
25996 +#endif
25997 +
25998 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25999 +
26000 +#ifdef CONFIG_PAX_KERNEXEC
26001 + " movl %0, %%cr0\n"
26002 +#endif
26003 +
26004 " jmp 2b\n"
26005 ".previous\n"
26006 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26007 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26008
26009 from += 64;
26010 to += 64;
26011 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26012 static void fast_copy_page(void *to, void *from)
26013 {
26014 int i;
26015 + unsigned long cr0;
26016
26017 kernel_fpu_begin();
26018
26019 __asm__ __volatile__ (
26020 - "1: prefetch (%0)\n"
26021 - " prefetch 64(%0)\n"
26022 - " prefetch 128(%0)\n"
26023 - " prefetch 192(%0)\n"
26024 - " prefetch 256(%0)\n"
26025 + "1: prefetch (%1)\n"
26026 + " prefetch 64(%1)\n"
26027 + " prefetch 128(%1)\n"
26028 + " prefetch 192(%1)\n"
26029 + " prefetch 256(%1)\n"
26030 "2: \n"
26031 ".section .fixup, \"ax\"\n"
26032 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26033 + "3: \n"
26034 +
26035 +#ifdef CONFIG_PAX_KERNEXEC
26036 + " movl %%cr0, %0\n"
26037 + " movl %0, %%eax\n"
26038 + " andl $0xFFFEFFFF, %%eax\n"
26039 + " movl %%eax, %%cr0\n"
26040 +#endif
26041 +
26042 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26043 +
26044 +#ifdef CONFIG_PAX_KERNEXEC
26045 + " movl %0, %%cr0\n"
26046 +#endif
26047 +
26048 " jmp 2b\n"
26049 ".previous\n"
26050 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26051 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26052
26053 for (i = 0; i < 4096/64; i++) {
26054 __asm__ __volatile__ (
26055 - "1: prefetch 320(%0)\n"
26056 - "2: movq (%0), %%mm0\n"
26057 - " movq 8(%0), %%mm1\n"
26058 - " movq 16(%0), %%mm2\n"
26059 - " movq 24(%0), %%mm3\n"
26060 - " movq %%mm0, (%1)\n"
26061 - " movq %%mm1, 8(%1)\n"
26062 - " movq %%mm2, 16(%1)\n"
26063 - " movq %%mm3, 24(%1)\n"
26064 - " movq 32(%0), %%mm0\n"
26065 - " movq 40(%0), %%mm1\n"
26066 - " movq 48(%0), %%mm2\n"
26067 - " movq 56(%0), %%mm3\n"
26068 - " movq %%mm0, 32(%1)\n"
26069 - " movq %%mm1, 40(%1)\n"
26070 - " movq %%mm2, 48(%1)\n"
26071 - " movq %%mm3, 56(%1)\n"
26072 + "1: prefetch 320(%1)\n"
26073 + "2: movq (%1), %%mm0\n"
26074 + " movq 8(%1), %%mm1\n"
26075 + " movq 16(%1), %%mm2\n"
26076 + " movq 24(%1), %%mm3\n"
26077 + " movq %%mm0, (%2)\n"
26078 + " movq %%mm1, 8(%2)\n"
26079 + " movq %%mm2, 16(%2)\n"
26080 + " movq %%mm3, 24(%2)\n"
26081 + " movq 32(%1), %%mm0\n"
26082 + " movq 40(%1), %%mm1\n"
26083 + " movq 48(%1), %%mm2\n"
26084 + " movq 56(%1), %%mm3\n"
26085 + " movq %%mm0, 32(%2)\n"
26086 + " movq %%mm1, 40(%2)\n"
26087 + " movq %%mm2, 48(%2)\n"
26088 + " movq %%mm3, 56(%2)\n"
26089 ".section .fixup, \"ax\"\n"
26090 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26091 + "3:\n"
26092 +
26093 +#ifdef CONFIG_PAX_KERNEXEC
26094 + " movl %%cr0, %0\n"
26095 + " movl %0, %%eax\n"
26096 + " andl $0xFFFEFFFF, %%eax\n"
26097 + " movl %%eax, %%cr0\n"
26098 +#endif
26099 +
26100 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26101 +
26102 +#ifdef CONFIG_PAX_KERNEXEC
26103 + " movl %0, %%cr0\n"
26104 +#endif
26105 +
26106 " jmp 2b\n"
26107 ".previous\n"
26108 _ASM_EXTABLE(1b, 3b)
26109 - : : "r" (from), "r" (to) : "memory");
26110 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26111
26112 from += 64;
26113 to += 64;
26114 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26115 index f6d13ee..aca5f0b 100644
26116 --- a/arch/x86/lib/msr-reg.S
26117 +++ b/arch/x86/lib/msr-reg.S
26118 @@ -3,6 +3,7 @@
26119 #include <asm/dwarf2.h>
26120 #include <asm/asm.h>
26121 #include <asm/msr.h>
26122 +#include <asm/alternative-asm.h>
26123
26124 #ifdef CONFIG_X86_64
26125 /*
26126 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26127 CFI_STARTPROC
26128 pushq_cfi %rbx
26129 pushq_cfi %rbp
26130 - movq %rdi, %r10 /* Save pointer */
26131 + movq %rdi, %r9 /* Save pointer */
26132 xorl %r11d, %r11d /* Return value */
26133 movl (%rdi), %eax
26134 movl 4(%rdi), %ecx
26135 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26136 movl 28(%rdi), %edi
26137 CFI_REMEMBER_STATE
26138 1: \op
26139 -2: movl %eax, (%r10)
26140 +2: movl %eax, (%r9)
26141 movl %r11d, %eax /* Return value */
26142 - movl %ecx, 4(%r10)
26143 - movl %edx, 8(%r10)
26144 - movl %ebx, 12(%r10)
26145 - movl %ebp, 20(%r10)
26146 - movl %esi, 24(%r10)
26147 - movl %edi, 28(%r10)
26148 + movl %ecx, 4(%r9)
26149 + movl %edx, 8(%r9)
26150 + movl %ebx, 12(%r9)
26151 + movl %ebp, 20(%r9)
26152 + movl %esi, 24(%r9)
26153 + movl %edi, 28(%r9)
26154 popq_cfi %rbp
26155 popq_cfi %rbx
26156 + pax_force_retaddr
26157 ret
26158 3:
26159 CFI_RESTORE_STATE
26160 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26161 index fc6ba17..d4d989d 100644
26162 --- a/arch/x86/lib/putuser.S
26163 +++ b/arch/x86/lib/putuser.S
26164 @@ -16,7 +16,9 @@
26165 #include <asm/errno.h>
26166 #include <asm/asm.h>
26167 #include <asm/smap.h>
26168 -
26169 +#include <asm/segment.h>
26170 +#include <asm/pgtable.h>
26171 +#include <asm/alternative-asm.h>
26172
26173 /*
26174 * __put_user_X
26175 @@ -30,57 +32,125 @@
26176 * as they get called from within inline assembly.
26177 */
26178
26179 -#define ENTER CFI_STARTPROC ; \
26180 - GET_THREAD_INFO(%_ASM_BX)
26181 -#define EXIT ASM_CLAC ; \
26182 - ret ; \
26183 +#define ENTER CFI_STARTPROC
26184 +#define EXIT ASM_CLAC ; \
26185 + pax_force_retaddr ; \
26186 + ret ; \
26187 CFI_ENDPROC
26188
26189 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26190 +#define _DEST %_ASM_CX,%_ASM_BX
26191 +#else
26192 +#define _DEST %_ASM_CX
26193 +#endif
26194 +
26195 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26196 +#define __copyuser_seg gs;
26197 +#else
26198 +#define __copyuser_seg
26199 +#endif
26200 +
26201 .text
26202 ENTRY(__put_user_1)
26203 ENTER
26204 +
26205 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26206 + GET_THREAD_INFO(%_ASM_BX)
26207 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26208 jae bad_put_user
26209 ASM_STAC
26210 -1: movb %al,(%_ASM_CX)
26211 +
26212 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26213 + mov pax_user_shadow_base,%_ASM_BX
26214 + cmp %_ASM_BX,%_ASM_CX
26215 + jb 1234f
26216 + xor %ebx,%ebx
26217 +1234:
26218 +#endif
26219 +
26220 +#endif
26221 +
26222 +1: __copyuser_seg movb %al,(_DEST)
26223 xor %eax,%eax
26224 EXIT
26225 ENDPROC(__put_user_1)
26226
26227 ENTRY(__put_user_2)
26228 ENTER
26229 +
26230 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26231 + GET_THREAD_INFO(%_ASM_BX)
26232 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26233 sub $1,%_ASM_BX
26234 cmp %_ASM_BX,%_ASM_CX
26235 jae bad_put_user
26236 ASM_STAC
26237 -2: movw %ax,(%_ASM_CX)
26238 +
26239 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26240 + mov pax_user_shadow_base,%_ASM_BX
26241 + cmp %_ASM_BX,%_ASM_CX
26242 + jb 1234f
26243 + xor %ebx,%ebx
26244 +1234:
26245 +#endif
26246 +
26247 +#endif
26248 +
26249 +2: __copyuser_seg movw %ax,(_DEST)
26250 xor %eax,%eax
26251 EXIT
26252 ENDPROC(__put_user_2)
26253
26254 ENTRY(__put_user_4)
26255 ENTER
26256 +
26257 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26258 + GET_THREAD_INFO(%_ASM_BX)
26259 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26260 sub $3,%_ASM_BX
26261 cmp %_ASM_BX,%_ASM_CX
26262 jae bad_put_user
26263 ASM_STAC
26264 -3: movl %eax,(%_ASM_CX)
26265 +
26266 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26267 + mov pax_user_shadow_base,%_ASM_BX
26268 + cmp %_ASM_BX,%_ASM_CX
26269 + jb 1234f
26270 + xor %ebx,%ebx
26271 +1234:
26272 +#endif
26273 +
26274 +#endif
26275 +
26276 +3: __copyuser_seg movl %eax,(_DEST)
26277 xor %eax,%eax
26278 EXIT
26279 ENDPROC(__put_user_4)
26280
26281 ENTRY(__put_user_8)
26282 ENTER
26283 +
26284 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26285 + GET_THREAD_INFO(%_ASM_BX)
26286 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26287 sub $7,%_ASM_BX
26288 cmp %_ASM_BX,%_ASM_CX
26289 jae bad_put_user
26290 ASM_STAC
26291 -4: mov %_ASM_AX,(%_ASM_CX)
26292 +
26293 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26294 + mov pax_user_shadow_base,%_ASM_BX
26295 + cmp %_ASM_BX,%_ASM_CX
26296 + jb 1234f
26297 + xor %ebx,%ebx
26298 +1234:
26299 +#endif
26300 +
26301 +#endif
26302 +
26303 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26304 #ifdef CONFIG_X86_32
26305 -5: movl %edx,4(%_ASM_CX)
26306 +5: __copyuser_seg movl %edx,4(_DEST)
26307 #endif
26308 xor %eax,%eax
26309 EXIT
26310 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26311 index 1cad221..de671ee 100644
26312 --- a/arch/x86/lib/rwlock.S
26313 +++ b/arch/x86/lib/rwlock.S
26314 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26315 FRAME
26316 0: LOCK_PREFIX
26317 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26318 +
26319 +#ifdef CONFIG_PAX_REFCOUNT
26320 + jno 1234f
26321 + LOCK_PREFIX
26322 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26323 + int $4
26324 +1234:
26325 + _ASM_EXTABLE(1234b, 1234b)
26326 +#endif
26327 +
26328 1: rep; nop
26329 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26330 jne 1b
26331 LOCK_PREFIX
26332 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26333 +
26334 +#ifdef CONFIG_PAX_REFCOUNT
26335 + jno 1234f
26336 + LOCK_PREFIX
26337 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26338 + int $4
26339 +1234:
26340 + _ASM_EXTABLE(1234b, 1234b)
26341 +#endif
26342 +
26343 jnz 0b
26344 ENDFRAME
26345 + pax_force_retaddr
26346 ret
26347 CFI_ENDPROC
26348 END(__write_lock_failed)
26349 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26350 FRAME
26351 0: LOCK_PREFIX
26352 READ_LOCK_SIZE(inc) (%__lock_ptr)
26353 +
26354 +#ifdef CONFIG_PAX_REFCOUNT
26355 + jno 1234f
26356 + LOCK_PREFIX
26357 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26358 + int $4
26359 +1234:
26360 + _ASM_EXTABLE(1234b, 1234b)
26361 +#endif
26362 +
26363 1: rep; nop
26364 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26365 js 1b
26366 LOCK_PREFIX
26367 READ_LOCK_SIZE(dec) (%__lock_ptr)
26368 +
26369 +#ifdef CONFIG_PAX_REFCOUNT
26370 + jno 1234f
26371 + LOCK_PREFIX
26372 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26373 + int $4
26374 +1234:
26375 + _ASM_EXTABLE(1234b, 1234b)
26376 +#endif
26377 +
26378 js 0b
26379 ENDFRAME
26380 + pax_force_retaddr
26381 ret
26382 CFI_ENDPROC
26383 END(__read_lock_failed)
26384 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26385 index 5dff5f0..cadebf4 100644
26386 --- a/arch/x86/lib/rwsem.S
26387 +++ b/arch/x86/lib/rwsem.S
26388 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26389 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26390 CFI_RESTORE __ASM_REG(dx)
26391 restore_common_regs
26392 + pax_force_retaddr
26393 ret
26394 CFI_ENDPROC
26395 ENDPROC(call_rwsem_down_read_failed)
26396 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26397 movq %rax,%rdi
26398 call rwsem_down_write_failed
26399 restore_common_regs
26400 + pax_force_retaddr
26401 ret
26402 CFI_ENDPROC
26403 ENDPROC(call_rwsem_down_write_failed)
26404 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26405 movq %rax,%rdi
26406 call rwsem_wake
26407 restore_common_regs
26408 -1: ret
26409 +1: pax_force_retaddr
26410 + ret
26411 CFI_ENDPROC
26412 ENDPROC(call_rwsem_wake)
26413
26414 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26415 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26416 CFI_RESTORE __ASM_REG(dx)
26417 restore_common_regs
26418 + pax_force_retaddr
26419 ret
26420 CFI_ENDPROC
26421 ENDPROC(call_rwsem_downgrade_wake)
26422 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26423 index a63efd6..ccecad8 100644
26424 --- a/arch/x86/lib/thunk_64.S
26425 +++ b/arch/x86/lib/thunk_64.S
26426 @@ -8,6 +8,7 @@
26427 #include <linux/linkage.h>
26428 #include <asm/dwarf2.h>
26429 #include <asm/calling.h>
26430 +#include <asm/alternative-asm.h>
26431
26432 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26433 .macro THUNK name, func, put_ret_addr_in_rdi=0
26434 @@ -41,5 +42,6 @@
26435 SAVE_ARGS
26436 restore:
26437 RESTORE_ARGS
26438 + pax_force_retaddr
26439 ret
26440 CFI_ENDPROC
26441 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26442 index f0312d7..9c39d63 100644
26443 --- a/arch/x86/lib/usercopy_32.c
26444 +++ b/arch/x86/lib/usercopy_32.c
26445 @@ -42,11 +42,13 @@ do { \
26446 int __d0; \
26447 might_fault(); \
26448 __asm__ __volatile__( \
26449 + __COPYUSER_SET_ES \
26450 ASM_STAC "\n" \
26451 "0: rep; stosl\n" \
26452 " movl %2,%0\n" \
26453 "1: rep; stosb\n" \
26454 "2: " ASM_CLAC "\n" \
26455 + __COPYUSER_RESTORE_ES \
26456 ".section .fixup,\"ax\"\n" \
26457 "3: lea 0(%2,%0,4),%0\n" \
26458 " jmp 2b\n" \
26459 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26460
26461 #ifdef CONFIG_X86_INTEL_USERCOPY
26462 static unsigned long
26463 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26464 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26465 {
26466 int d0, d1;
26467 __asm__ __volatile__(
26468 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26469 " .align 2,0x90\n"
26470 "3: movl 0(%4), %%eax\n"
26471 "4: movl 4(%4), %%edx\n"
26472 - "5: movl %%eax, 0(%3)\n"
26473 - "6: movl %%edx, 4(%3)\n"
26474 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26475 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26476 "7: movl 8(%4), %%eax\n"
26477 "8: movl 12(%4),%%edx\n"
26478 - "9: movl %%eax, 8(%3)\n"
26479 - "10: movl %%edx, 12(%3)\n"
26480 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26481 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26482 "11: movl 16(%4), %%eax\n"
26483 "12: movl 20(%4), %%edx\n"
26484 - "13: movl %%eax, 16(%3)\n"
26485 - "14: movl %%edx, 20(%3)\n"
26486 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26487 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26488 "15: movl 24(%4), %%eax\n"
26489 "16: movl 28(%4), %%edx\n"
26490 - "17: movl %%eax, 24(%3)\n"
26491 - "18: movl %%edx, 28(%3)\n"
26492 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26493 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26494 "19: movl 32(%4), %%eax\n"
26495 "20: movl 36(%4), %%edx\n"
26496 - "21: movl %%eax, 32(%3)\n"
26497 - "22: movl %%edx, 36(%3)\n"
26498 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26499 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26500 "23: movl 40(%4), %%eax\n"
26501 "24: movl 44(%4), %%edx\n"
26502 - "25: movl %%eax, 40(%3)\n"
26503 - "26: movl %%edx, 44(%3)\n"
26504 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26505 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26506 "27: movl 48(%4), %%eax\n"
26507 "28: movl 52(%4), %%edx\n"
26508 - "29: movl %%eax, 48(%3)\n"
26509 - "30: movl %%edx, 52(%3)\n"
26510 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26511 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26512 "31: movl 56(%4), %%eax\n"
26513 "32: movl 60(%4), %%edx\n"
26514 - "33: movl %%eax, 56(%3)\n"
26515 - "34: movl %%edx, 60(%3)\n"
26516 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26517 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26518 " addl $-64, %0\n"
26519 " addl $64, %4\n"
26520 " addl $64, %3\n"
26521 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26522 " shrl $2, %0\n"
26523 " andl $3, %%eax\n"
26524 " cld\n"
26525 + __COPYUSER_SET_ES
26526 "99: rep; movsl\n"
26527 "36: movl %%eax, %0\n"
26528 "37: rep; movsb\n"
26529 "100:\n"
26530 + __COPYUSER_RESTORE_ES
26531 ".section .fixup,\"ax\"\n"
26532 "101: lea 0(%%eax,%0,4),%0\n"
26533 " jmp 100b\n"
26534 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26535 }
26536
26537 static unsigned long
26538 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26539 +{
26540 + int d0, d1;
26541 + __asm__ __volatile__(
26542 + " .align 2,0x90\n"
26543 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26544 + " cmpl $67, %0\n"
26545 + " jbe 3f\n"
26546 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26547 + " .align 2,0x90\n"
26548 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26549 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26550 + "5: movl %%eax, 0(%3)\n"
26551 + "6: movl %%edx, 4(%3)\n"
26552 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26553 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26554 + "9: movl %%eax, 8(%3)\n"
26555 + "10: movl %%edx, 12(%3)\n"
26556 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26557 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26558 + "13: movl %%eax, 16(%3)\n"
26559 + "14: movl %%edx, 20(%3)\n"
26560 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26561 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26562 + "17: movl %%eax, 24(%3)\n"
26563 + "18: movl %%edx, 28(%3)\n"
26564 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26565 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26566 + "21: movl %%eax, 32(%3)\n"
26567 + "22: movl %%edx, 36(%3)\n"
26568 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26569 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26570 + "25: movl %%eax, 40(%3)\n"
26571 + "26: movl %%edx, 44(%3)\n"
26572 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26573 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26574 + "29: movl %%eax, 48(%3)\n"
26575 + "30: movl %%edx, 52(%3)\n"
26576 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26577 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26578 + "33: movl %%eax, 56(%3)\n"
26579 + "34: movl %%edx, 60(%3)\n"
26580 + " addl $-64, %0\n"
26581 + " addl $64, %4\n"
26582 + " addl $64, %3\n"
26583 + " cmpl $63, %0\n"
26584 + " ja 1b\n"
26585 + "35: movl %0, %%eax\n"
26586 + " shrl $2, %0\n"
26587 + " andl $3, %%eax\n"
26588 + " cld\n"
26589 + "99: rep; "__copyuser_seg" movsl\n"
26590 + "36: movl %%eax, %0\n"
26591 + "37: rep; "__copyuser_seg" movsb\n"
26592 + "100:\n"
26593 + ".section .fixup,\"ax\"\n"
26594 + "101: lea 0(%%eax,%0,4),%0\n"
26595 + " jmp 100b\n"
26596 + ".previous\n"
26597 + _ASM_EXTABLE(1b,100b)
26598 + _ASM_EXTABLE(2b,100b)
26599 + _ASM_EXTABLE(3b,100b)
26600 + _ASM_EXTABLE(4b,100b)
26601 + _ASM_EXTABLE(5b,100b)
26602 + _ASM_EXTABLE(6b,100b)
26603 + _ASM_EXTABLE(7b,100b)
26604 + _ASM_EXTABLE(8b,100b)
26605 + _ASM_EXTABLE(9b,100b)
26606 + _ASM_EXTABLE(10b,100b)
26607 + _ASM_EXTABLE(11b,100b)
26608 + _ASM_EXTABLE(12b,100b)
26609 + _ASM_EXTABLE(13b,100b)
26610 + _ASM_EXTABLE(14b,100b)
26611 + _ASM_EXTABLE(15b,100b)
26612 + _ASM_EXTABLE(16b,100b)
26613 + _ASM_EXTABLE(17b,100b)
26614 + _ASM_EXTABLE(18b,100b)
26615 + _ASM_EXTABLE(19b,100b)
26616 + _ASM_EXTABLE(20b,100b)
26617 + _ASM_EXTABLE(21b,100b)
26618 + _ASM_EXTABLE(22b,100b)
26619 + _ASM_EXTABLE(23b,100b)
26620 + _ASM_EXTABLE(24b,100b)
26621 + _ASM_EXTABLE(25b,100b)
26622 + _ASM_EXTABLE(26b,100b)
26623 + _ASM_EXTABLE(27b,100b)
26624 + _ASM_EXTABLE(28b,100b)
26625 + _ASM_EXTABLE(29b,100b)
26626 + _ASM_EXTABLE(30b,100b)
26627 + _ASM_EXTABLE(31b,100b)
26628 + _ASM_EXTABLE(32b,100b)
26629 + _ASM_EXTABLE(33b,100b)
26630 + _ASM_EXTABLE(34b,100b)
26631 + _ASM_EXTABLE(35b,100b)
26632 + _ASM_EXTABLE(36b,100b)
26633 + _ASM_EXTABLE(37b,100b)
26634 + _ASM_EXTABLE(99b,101b)
26635 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26636 + : "1"(to), "2"(from), "0"(size)
26637 + : "eax", "edx", "memory");
26638 + return size;
26639 +}
26640 +
26641 +static unsigned long __size_overflow(3)
26642 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26643 {
26644 int d0, d1;
26645 __asm__ __volatile__(
26646 " .align 2,0x90\n"
26647 - "0: movl 32(%4), %%eax\n"
26648 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26649 " cmpl $67, %0\n"
26650 " jbe 2f\n"
26651 - "1: movl 64(%4), %%eax\n"
26652 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26653 " .align 2,0x90\n"
26654 - "2: movl 0(%4), %%eax\n"
26655 - "21: movl 4(%4), %%edx\n"
26656 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26657 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26658 " movl %%eax, 0(%3)\n"
26659 " movl %%edx, 4(%3)\n"
26660 - "3: movl 8(%4), %%eax\n"
26661 - "31: movl 12(%4),%%edx\n"
26662 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26663 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26664 " movl %%eax, 8(%3)\n"
26665 " movl %%edx, 12(%3)\n"
26666 - "4: movl 16(%4), %%eax\n"
26667 - "41: movl 20(%4), %%edx\n"
26668 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26669 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26670 " movl %%eax, 16(%3)\n"
26671 " movl %%edx, 20(%3)\n"
26672 - "10: movl 24(%4), %%eax\n"
26673 - "51: movl 28(%4), %%edx\n"
26674 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26675 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26676 " movl %%eax, 24(%3)\n"
26677 " movl %%edx, 28(%3)\n"
26678 - "11: movl 32(%4), %%eax\n"
26679 - "61: movl 36(%4), %%edx\n"
26680 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26681 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26682 " movl %%eax, 32(%3)\n"
26683 " movl %%edx, 36(%3)\n"
26684 - "12: movl 40(%4), %%eax\n"
26685 - "71: movl 44(%4), %%edx\n"
26686 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26687 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26688 " movl %%eax, 40(%3)\n"
26689 " movl %%edx, 44(%3)\n"
26690 - "13: movl 48(%4), %%eax\n"
26691 - "81: movl 52(%4), %%edx\n"
26692 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26693 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26694 " movl %%eax, 48(%3)\n"
26695 " movl %%edx, 52(%3)\n"
26696 - "14: movl 56(%4), %%eax\n"
26697 - "91: movl 60(%4), %%edx\n"
26698 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26699 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26700 " movl %%eax, 56(%3)\n"
26701 " movl %%edx, 60(%3)\n"
26702 " addl $-64, %0\n"
26703 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26704 " shrl $2, %0\n"
26705 " andl $3, %%eax\n"
26706 " cld\n"
26707 - "6: rep; movsl\n"
26708 + "6: rep; "__copyuser_seg" movsl\n"
26709 " movl %%eax,%0\n"
26710 - "7: rep; movsb\n"
26711 + "7: rep; "__copyuser_seg" movsb\n"
26712 "8:\n"
26713 ".section .fixup,\"ax\"\n"
26714 "9: lea 0(%%eax,%0,4),%0\n"
26715 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26716 * hyoshiok@miraclelinux.com
26717 */
26718
26719 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26720 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26721 const void __user *from, unsigned long size)
26722 {
26723 int d0, d1;
26724
26725 __asm__ __volatile__(
26726 " .align 2,0x90\n"
26727 - "0: movl 32(%4), %%eax\n"
26728 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26729 " cmpl $67, %0\n"
26730 " jbe 2f\n"
26731 - "1: movl 64(%4), %%eax\n"
26732 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26733 " .align 2,0x90\n"
26734 - "2: movl 0(%4), %%eax\n"
26735 - "21: movl 4(%4), %%edx\n"
26736 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26737 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26738 " movnti %%eax, 0(%3)\n"
26739 " movnti %%edx, 4(%3)\n"
26740 - "3: movl 8(%4), %%eax\n"
26741 - "31: movl 12(%4),%%edx\n"
26742 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26743 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26744 " movnti %%eax, 8(%3)\n"
26745 " movnti %%edx, 12(%3)\n"
26746 - "4: movl 16(%4), %%eax\n"
26747 - "41: movl 20(%4), %%edx\n"
26748 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26749 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26750 " movnti %%eax, 16(%3)\n"
26751 " movnti %%edx, 20(%3)\n"
26752 - "10: movl 24(%4), %%eax\n"
26753 - "51: movl 28(%4), %%edx\n"
26754 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26755 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26756 " movnti %%eax, 24(%3)\n"
26757 " movnti %%edx, 28(%3)\n"
26758 - "11: movl 32(%4), %%eax\n"
26759 - "61: movl 36(%4), %%edx\n"
26760 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26761 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26762 " movnti %%eax, 32(%3)\n"
26763 " movnti %%edx, 36(%3)\n"
26764 - "12: movl 40(%4), %%eax\n"
26765 - "71: movl 44(%4), %%edx\n"
26766 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26767 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26768 " movnti %%eax, 40(%3)\n"
26769 " movnti %%edx, 44(%3)\n"
26770 - "13: movl 48(%4), %%eax\n"
26771 - "81: movl 52(%4), %%edx\n"
26772 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26773 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26774 " movnti %%eax, 48(%3)\n"
26775 " movnti %%edx, 52(%3)\n"
26776 - "14: movl 56(%4), %%eax\n"
26777 - "91: movl 60(%4), %%edx\n"
26778 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26779 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26780 " movnti %%eax, 56(%3)\n"
26781 " movnti %%edx, 60(%3)\n"
26782 " addl $-64, %0\n"
26783 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26784 " shrl $2, %0\n"
26785 " andl $3, %%eax\n"
26786 " cld\n"
26787 - "6: rep; movsl\n"
26788 + "6: rep; "__copyuser_seg" movsl\n"
26789 " movl %%eax,%0\n"
26790 - "7: rep; movsb\n"
26791 + "7: rep; "__copyuser_seg" movsb\n"
26792 "8:\n"
26793 ".section .fixup,\"ax\"\n"
26794 "9: lea 0(%%eax,%0,4),%0\n"
26795 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26796 return size;
26797 }
26798
26799 -static unsigned long __copy_user_intel_nocache(void *to,
26800 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26801 const void __user *from, unsigned long size)
26802 {
26803 int d0, d1;
26804
26805 __asm__ __volatile__(
26806 " .align 2,0x90\n"
26807 - "0: movl 32(%4), %%eax\n"
26808 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26809 " cmpl $67, %0\n"
26810 " jbe 2f\n"
26811 - "1: movl 64(%4), %%eax\n"
26812 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26813 " .align 2,0x90\n"
26814 - "2: movl 0(%4), %%eax\n"
26815 - "21: movl 4(%4), %%edx\n"
26816 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26817 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26818 " movnti %%eax, 0(%3)\n"
26819 " movnti %%edx, 4(%3)\n"
26820 - "3: movl 8(%4), %%eax\n"
26821 - "31: movl 12(%4),%%edx\n"
26822 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26823 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26824 " movnti %%eax, 8(%3)\n"
26825 " movnti %%edx, 12(%3)\n"
26826 - "4: movl 16(%4), %%eax\n"
26827 - "41: movl 20(%4), %%edx\n"
26828 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26829 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26830 " movnti %%eax, 16(%3)\n"
26831 " movnti %%edx, 20(%3)\n"
26832 - "10: movl 24(%4), %%eax\n"
26833 - "51: movl 28(%4), %%edx\n"
26834 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26835 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26836 " movnti %%eax, 24(%3)\n"
26837 " movnti %%edx, 28(%3)\n"
26838 - "11: movl 32(%4), %%eax\n"
26839 - "61: movl 36(%4), %%edx\n"
26840 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26841 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26842 " movnti %%eax, 32(%3)\n"
26843 " movnti %%edx, 36(%3)\n"
26844 - "12: movl 40(%4), %%eax\n"
26845 - "71: movl 44(%4), %%edx\n"
26846 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26847 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26848 " movnti %%eax, 40(%3)\n"
26849 " movnti %%edx, 44(%3)\n"
26850 - "13: movl 48(%4), %%eax\n"
26851 - "81: movl 52(%4), %%edx\n"
26852 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26853 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26854 " movnti %%eax, 48(%3)\n"
26855 " movnti %%edx, 52(%3)\n"
26856 - "14: movl 56(%4), %%eax\n"
26857 - "91: movl 60(%4), %%edx\n"
26858 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26859 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26860 " movnti %%eax, 56(%3)\n"
26861 " movnti %%edx, 60(%3)\n"
26862 " addl $-64, %0\n"
26863 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26864 " shrl $2, %0\n"
26865 " andl $3, %%eax\n"
26866 " cld\n"
26867 - "6: rep; movsl\n"
26868 + "6: rep; "__copyuser_seg" movsl\n"
26869 " movl %%eax,%0\n"
26870 - "7: rep; movsb\n"
26871 + "7: rep; "__copyuser_seg" movsb\n"
26872 "8:\n"
26873 ".section .fixup,\"ax\"\n"
26874 "9: lea 0(%%eax,%0,4),%0\n"
26875 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26876 */
26877 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26878 unsigned long size);
26879 -unsigned long __copy_user_intel(void __user *to, const void *from,
26880 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26881 + unsigned long size);
26882 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26883 unsigned long size);
26884 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26885 const void __user *from, unsigned long size);
26886 #endif /* CONFIG_X86_INTEL_USERCOPY */
26887
26888 /* Generic arbitrary sized copy. */
26889 -#define __copy_user(to, from, size) \
26890 +#define __copy_user(to, from, size, prefix, set, restore) \
26891 do { \
26892 int __d0, __d1, __d2; \
26893 __asm__ __volatile__( \
26894 + set \
26895 " cmp $7,%0\n" \
26896 " jbe 1f\n" \
26897 " movl %1,%0\n" \
26898 " negl %0\n" \
26899 " andl $7,%0\n" \
26900 " subl %0,%3\n" \
26901 - "4: rep; movsb\n" \
26902 + "4: rep; "prefix"movsb\n" \
26903 " movl %3,%0\n" \
26904 " shrl $2,%0\n" \
26905 " andl $3,%3\n" \
26906 " .align 2,0x90\n" \
26907 - "0: rep; movsl\n" \
26908 + "0: rep; "prefix"movsl\n" \
26909 " movl %3,%0\n" \
26910 - "1: rep; movsb\n" \
26911 + "1: rep; "prefix"movsb\n" \
26912 "2:\n" \
26913 + restore \
26914 ".section .fixup,\"ax\"\n" \
26915 "5: addl %3,%0\n" \
26916 " jmp 2b\n" \
26917 @@ -538,14 +650,14 @@ do { \
26918 " negl %0\n" \
26919 " andl $7,%0\n" \
26920 " subl %0,%3\n" \
26921 - "4: rep; movsb\n" \
26922 + "4: rep; "__copyuser_seg"movsb\n" \
26923 " movl %3,%0\n" \
26924 " shrl $2,%0\n" \
26925 " andl $3,%3\n" \
26926 " .align 2,0x90\n" \
26927 - "0: rep; movsl\n" \
26928 + "0: rep; "__copyuser_seg"movsl\n" \
26929 " movl %3,%0\n" \
26930 - "1: rep; movsb\n" \
26931 + "1: rep; "__copyuser_seg"movsb\n" \
26932 "2:\n" \
26933 ".section .fixup,\"ax\"\n" \
26934 "5: addl %3,%0\n" \
26935 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26936 {
26937 stac();
26938 if (movsl_is_ok(to, from, n))
26939 - __copy_user(to, from, n);
26940 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26941 else
26942 - n = __copy_user_intel(to, from, n);
26943 + n = __generic_copy_to_user_intel(to, from, n);
26944 clac();
26945 return n;
26946 }
26947 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
26948 {
26949 stac();
26950 if (movsl_is_ok(to, from, n))
26951 - __copy_user(to, from, n);
26952 + __copy_user(to, from, n, __copyuser_seg, "", "");
26953 else
26954 - n = __copy_user_intel((void __user *)to,
26955 - (const void *)from, n);
26956 + n = __generic_copy_from_user_intel(to, from, n);
26957 clac();
26958 return n;
26959 }
26960 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
26961 if (n > 64 && cpu_has_xmm2)
26962 n = __copy_user_intel_nocache(to, from, n);
26963 else
26964 - __copy_user(to, from, n);
26965 + __copy_user(to, from, n, __copyuser_seg, "", "");
26966 #else
26967 - __copy_user(to, from, n);
26968 + __copy_user(to, from, n, __copyuser_seg, "", "");
26969 #endif
26970 clac();
26971 return n;
26972 }
26973 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
26974
26975 -/**
26976 - * copy_to_user: - Copy a block of data into user space.
26977 - * @to: Destination address, in user space.
26978 - * @from: Source address, in kernel space.
26979 - * @n: Number of bytes to copy.
26980 - *
26981 - * Context: User context only. This function may sleep.
26982 - *
26983 - * Copy data from kernel space to user space.
26984 - *
26985 - * Returns number of bytes that could not be copied.
26986 - * On success, this will be zero.
26987 - */
26988 -unsigned long
26989 -copy_to_user(void __user *to, const void *from, unsigned long n)
26990 -{
26991 - if (access_ok(VERIFY_WRITE, to, n))
26992 - n = __copy_to_user(to, from, n);
26993 - return n;
26994 -}
26995 -EXPORT_SYMBOL(copy_to_user);
26996 -
26997 -/**
26998 - * copy_from_user: - Copy a block of data from user space.
26999 - * @to: Destination address, in kernel space.
27000 - * @from: Source address, in user space.
27001 - * @n: Number of bytes to copy.
27002 - *
27003 - * Context: User context only. This function may sleep.
27004 - *
27005 - * Copy data from user space to kernel space.
27006 - *
27007 - * Returns number of bytes that could not be copied.
27008 - * On success, this will be zero.
27009 - *
27010 - * If some data could not be copied, this function will pad the copied
27011 - * data to the requested size using zero bytes.
27012 - */
27013 -unsigned long
27014 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27015 -{
27016 - if (access_ok(VERIFY_READ, from, n))
27017 - n = __copy_from_user(to, from, n);
27018 - else
27019 - memset(to, 0, n);
27020 - return n;
27021 -}
27022 -EXPORT_SYMBOL(_copy_from_user);
27023 -
27024 void copy_from_user_overflow(void)
27025 {
27026 WARN(1, "Buffer overflow detected!\n");
27027 }
27028 EXPORT_SYMBOL(copy_from_user_overflow);
27029 +
27030 +void copy_to_user_overflow(void)
27031 +{
27032 + WARN(1, "Buffer overflow detected!\n");
27033 +}
27034 +EXPORT_SYMBOL(copy_to_user_overflow);
27035 +
27036 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27037 +void __set_fs(mm_segment_t x)
27038 +{
27039 + switch (x.seg) {
27040 + case 0:
27041 + loadsegment(gs, 0);
27042 + break;
27043 + case TASK_SIZE_MAX:
27044 + loadsegment(gs, __USER_DS);
27045 + break;
27046 + case -1UL:
27047 + loadsegment(gs, __KERNEL_DS);
27048 + break;
27049 + default:
27050 + BUG();
27051 + }
27052 + return;
27053 +}
27054 +EXPORT_SYMBOL(__set_fs);
27055 +
27056 +void set_fs(mm_segment_t x)
27057 +{
27058 + current_thread_info()->addr_limit = x;
27059 + __set_fs(x);
27060 +}
27061 +EXPORT_SYMBOL(set_fs);
27062 +#endif
27063 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27064 index 906fea3..ee8a097 100644
27065 --- a/arch/x86/lib/usercopy_64.c
27066 +++ b/arch/x86/lib/usercopy_64.c
27067 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27068 _ASM_EXTABLE(0b,3b)
27069 _ASM_EXTABLE(1b,2b)
27070 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27071 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27072 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27073 [zero] "r" (0UL), [eight] "r" (8UL));
27074 clac();
27075 return size;
27076 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27077 }
27078 EXPORT_SYMBOL(clear_user);
27079
27080 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27081 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27082 {
27083 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27084 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27085 - }
27086 - return len;
27087 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27088 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27089 + return len;
27090 }
27091 EXPORT_SYMBOL(copy_in_user);
27092
27093 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27094 * it is not necessary to optimize tail handling.
27095 */
27096 unsigned long
27097 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27098 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27099 {
27100 char c;
27101 unsigned zero_len;
27102 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27103 clac();
27104 return len;
27105 }
27106 +
27107 +void copy_from_user_overflow(void)
27108 +{
27109 + WARN(1, "Buffer overflow detected!\n");
27110 +}
27111 +EXPORT_SYMBOL(copy_from_user_overflow);
27112 +
27113 +void copy_to_user_overflow(void)
27114 +{
27115 + WARN(1, "Buffer overflow detected!\n");
27116 +}
27117 +EXPORT_SYMBOL(copy_to_user_overflow);
27118 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27119 index 903ec1e..c4166b2 100644
27120 --- a/arch/x86/mm/extable.c
27121 +++ b/arch/x86/mm/extable.c
27122 @@ -6,12 +6,24 @@
27123 static inline unsigned long
27124 ex_insn_addr(const struct exception_table_entry *x)
27125 {
27126 - return (unsigned long)&x->insn + x->insn;
27127 + unsigned long reloc = 0;
27128 +
27129 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27130 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27131 +#endif
27132 +
27133 + return (unsigned long)&x->insn + x->insn + reloc;
27134 }
27135 static inline unsigned long
27136 ex_fixup_addr(const struct exception_table_entry *x)
27137 {
27138 - return (unsigned long)&x->fixup + x->fixup;
27139 + unsigned long reloc = 0;
27140 +
27141 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27142 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27143 +#endif
27144 +
27145 + return (unsigned long)&x->fixup + x->fixup + reloc;
27146 }
27147
27148 int fixup_exception(struct pt_regs *regs)
27149 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27150 unsigned long new_ip;
27151
27152 #ifdef CONFIG_PNPBIOS
27153 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27154 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27155 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27156 extern u32 pnp_bios_is_utter_crap;
27157 pnp_bios_is_utter_crap = 1;
27158 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27159 i += 4;
27160 p->fixup -= i;
27161 i += 4;
27162 +
27163 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27164 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27165 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27166 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27167 +#endif
27168 +
27169 }
27170 }
27171
27172 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27173 index 0e88336..2bb9777 100644
27174 --- a/arch/x86/mm/fault.c
27175 +++ b/arch/x86/mm/fault.c
27176 @@ -13,12 +13,19 @@
27177 #include <linux/perf_event.h> /* perf_sw_event */
27178 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27179 #include <linux/prefetch.h> /* prefetchw */
27180 +#include <linux/unistd.h>
27181 +#include <linux/compiler.h>
27182
27183 #include <asm/traps.h> /* dotraplinkage, ... */
27184 #include <asm/pgalloc.h> /* pgd_*(), ... */
27185 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27186 #include <asm/fixmap.h> /* VSYSCALL_START */
27187 #include <asm/context_tracking.h> /* exception_enter(), ... */
27188 +#include <asm/tlbflush.h>
27189 +
27190 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27191 +#include <asm/stacktrace.h>
27192 +#endif
27193
27194 /*
27195 * Page fault error code bits:
27196 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27197 int ret = 0;
27198
27199 /* kprobe_running() needs smp_processor_id() */
27200 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27201 + if (kprobes_built_in() && !user_mode(regs)) {
27202 preempt_disable();
27203 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27204 ret = 1;
27205 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27206 return !instr_lo || (instr_lo>>1) == 1;
27207 case 0x00:
27208 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27209 - if (probe_kernel_address(instr, opcode))
27210 + if (user_mode(regs)) {
27211 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27212 + return 0;
27213 + } else if (probe_kernel_address(instr, opcode))
27214 return 0;
27215
27216 *prefetch = (instr_lo == 0xF) &&
27217 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27218 while (instr < max_instr) {
27219 unsigned char opcode;
27220
27221 - if (probe_kernel_address(instr, opcode))
27222 + if (user_mode(regs)) {
27223 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27224 + break;
27225 + } else if (probe_kernel_address(instr, opcode))
27226 break;
27227
27228 instr++;
27229 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27230 force_sig_info(si_signo, &info, tsk);
27231 }
27232
27233 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27234 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27235 +#endif
27236 +
27237 +#ifdef CONFIG_PAX_EMUTRAMP
27238 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27239 +#endif
27240 +
27241 +#ifdef CONFIG_PAX_PAGEEXEC
27242 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27243 +{
27244 + pgd_t *pgd;
27245 + pud_t *pud;
27246 + pmd_t *pmd;
27247 +
27248 + pgd = pgd_offset(mm, address);
27249 + if (!pgd_present(*pgd))
27250 + return NULL;
27251 + pud = pud_offset(pgd, address);
27252 + if (!pud_present(*pud))
27253 + return NULL;
27254 + pmd = pmd_offset(pud, address);
27255 + if (!pmd_present(*pmd))
27256 + return NULL;
27257 + return pmd;
27258 +}
27259 +#endif
27260 +
27261 DEFINE_SPINLOCK(pgd_lock);
27262 LIST_HEAD(pgd_list);
27263
27264 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27265 for (address = VMALLOC_START & PMD_MASK;
27266 address >= TASK_SIZE && address < FIXADDR_TOP;
27267 address += PMD_SIZE) {
27268 +
27269 +#ifdef CONFIG_PAX_PER_CPU_PGD
27270 + unsigned long cpu;
27271 +#else
27272 struct page *page;
27273 +#endif
27274
27275 spin_lock(&pgd_lock);
27276 +
27277 +#ifdef CONFIG_PAX_PER_CPU_PGD
27278 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27279 + pgd_t *pgd = get_cpu_pgd(cpu);
27280 + pmd_t *ret;
27281 +#else
27282 list_for_each_entry(page, &pgd_list, lru) {
27283 + pgd_t *pgd;
27284 spinlock_t *pgt_lock;
27285 pmd_t *ret;
27286
27287 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27288 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27289
27290 spin_lock(pgt_lock);
27291 - ret = vmalloc_sync_one(page_address(page), address);
27292 + pgd = page_address(page);
27293 +#endif
27294 +
27295 + ret = vmalloc_sync_one(pgd, address);
27296 +
27297 +#ifndef CONFIG_PAX_PER_CPU_PGD
27298 spin_unlock(pgt_lock);
27299 +#endif
27300
27301 if (!ret)
27302 break;
27303 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27304 * an interrupt in the middle of a task switch..
27305 */
27306 pgd_paddr = read_cr3();
27307 +
27308 +#ifdef CONFIG_PAX_PER_CPU_PGD
27309 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27310 +#endif
27311 +
27312 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27313 if (!pmd_k)
27314 return -1;
27315 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27316 * happen within a race in page table update. In the later
27317 * case just flush:
27318 */
27319 +
27320 +#ifdef CONFIG_PAX_PER_CPU_PGD
27321 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27322 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27323 +#else
27324 pgd = pgd_offset(current->active_mm, address);
27325 +#endif
27326 +
27327 pgd_ref = pgd_offset_k(address);
27328 if (pgd_none(*pgd_ref))
27329 return -1;
27330 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27331 static int is_errata100(struct pt_regs *regs, unsigned long address)
27332 {
27333 #ifdef CONFIG_X86_64
27334 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27335 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27336 return 1;
27337 #endif
27338 return 0;
27339 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27340 }
27341
27342 static const char nx_warning[] = KERN_CRIT
27343 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27344 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27345
27346 static void
27347 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27348 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27349 if (!oops_may_print())
27350 return;
27351
27352 - if (error_code & PF_INSTR) {
27353 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27354 unsigned int level;
27355
27356 pte_t *pte = lookup_address(address, &level);
27357
27358 if (pte && pte_present(*pte) && !pte_exec(*pte))
27359 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27360 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27361 }
27362
27363 +#ifdef CONFIG_PAX_KERNEXEC
27364 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27365 + if (current->signal->curr_ip)
27366 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27367 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27368 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27369 + else
27370 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27371 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27372 + }
27373 +#endif
27374 +
27375 printk(KERN_ALERT "BUG: unable to handle kernel ");
27376 if (address < PAGE_SIZE)
27377 printk(KERN_CONT "NULL pointer dereference");
27378 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27379 return;
27380 }
27381 #endif
27382 +
27383 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27384 + if (pax_is_fetch_fault(regs, error_code, address)) {
27385 +
27386 +#ifdef CONFIG_PAX_EMUTRAMP
27387 + switch (pax_handle_fetch_fault(regs)) {
27388 + case 2:
27389 + return;
27390 + }
27391 +#endif
27392 +
27393 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27394 + do_group_exit(SIGKILL);
27395 + }
27396 +#endif
27397 +
27398 /* Kernel addresses are always protection faults: */
27399 if (address >= TASK_SIZE)
27400 error_code |= PF_PROT;
27401 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27402 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27403 printk(KERN_ERR
27404 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27405 - tsk->comm, tsk->pid, address);
27406 + tsk->comm, task_pid_nr(tsk), address);
27407 code = BUS_MCEERR_AR;
27408 }
27409 #endif
27410 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27411 return 1;
27412 }
27413
27414 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27415 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27416 +{
27417 + pte_t *pte;
27418 + pmd_t *pmd;
27419 + spinlock_t *ptl;
27420 + unsigned char pte_mask;
27421 +
27422 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27423 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27424 + return 0;
27425 +
27426 + /* PaX: it's our fault, let's handle it if we can */
27427 +
27428 + /* PaX: take a look at read faults before acquiring any locks */
27429 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27430 + /* instruction fetch attempt from a protected page in user mode */
27431 + up_read(&mm->mmap_sem);
27432 +
27433 +#ifdef CONFIG_PAX_EMUTRAMP
27434 + switch (pax_handle_fetch_fault(regs)) {
27435 + case 2:
27436 + return 1;
27437 + }
27438 +#endif
27439 +
27440 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27441 + do_group_exit(SIGKILL);
27442 + }
27443 +
27444 + pmd = pax_get_pmd(mm, address);
27445 + if (unlikely(!pmd))
27446 + return 0;
27447 +
27448 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27449 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27450 + pte_unmap_unlock(pte, ptl);
27451 + return 0;
27452 + }
27453 +
27454 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27455 + /* write attempt to a protected page in user mode */
27456 + pte_unmap_unlock(pte, ptl);
27457 + return 0;
27458 + }
27459 +
27460 +#ifdef CONFIG_SMP
27461 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27462 +#else
27463 + if (likely(address > get_limit(regs->cs)))
27464 +#endif
27465 + {
27466 + set_pte(pte, pte_mkread(*pte));
27467 + __flush_tlb_one(address);
27468 + pte_unmap_unlock(pte, ptl);
27469 + up_read(&mm->mmap_sem);
27470 + return 1;
27471 + }
27472 +
27473 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27474 +
27475 + /*
27476 + * PaX: fill DTLB with user rights and retry
27477 + */
27478 + __asm__ __volatile__ (
27479 + "orb %2,(%1)\n"
27480 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27481 +/*
27482 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27483 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27484 + * page fault when examined during a TLB load attempt. this is true not only
27485 + * for PTEs holding a non-present entry but also present entries that will
27486 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27487 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27488 + * for our target pages since their PTEs are simply not in the TLBs at all.
27489 +
27490 + * the best thing in omitting it is that we gain around 15-20% speed in the
27491 + * fast path of the page fault handler and can get rid of tracing since we
27492 + * can no longer flush unintended entries.
27493 + */
27494 + "invlpg (%0)\n"
27495 +#endif
27496 + __copyuser_seg"testb $0,(%0)\n"
27497 + "xorb %3,(%1)\n"
27498 + :
27499 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27500 + : "memory", "cc");
27501 + pte_unmap_unlock(pte, ptl);
27502 + up_read(&mm->mmap_sem);
27503 + return 1;
27504 +}
27505 +#endif
27506 +
27507 /*
27508 * Handle a spurious fault caused by a stale TLB entry.
27509 *
27510 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27511 static inline int
27512 access_error(unsigned long error_code, struct vm_area_struct *vma)
27513 {
27514 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27515 + return 1;
27516 +
27517 if (error_code & PF_WRITE) {
27518 /* write, present and write, not present: */
27519 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27520 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27521 if (error_code & PF_USER)
27522 return false;
27523
27524 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27525 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27526 return false;
27527
27528 return true;
27529 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27530 {
27531 struct vm_area_struct *vma;
27532 struct task_struct *tsk;
27533 - unsigned long address;
27534 struct mm_struct *mm;
27535 int fault;
27536 int write = error_code & PF_WRITE;
27537 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27538 (write ? FAULT_FLAG_WRITE : 0);
27539
27540 - tsk = current;
27541 - mm = tsk->mm;
27542 -
27543 /* Get the faulting address: */
27544 - address = read_cr2();
27545 + unsigned long address = read_cr2();
27546 +
27547 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27548 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27549 + if (!search_exception_tables(regs->ip)) {
27550 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27551 + bad_area_nosemaphore(regs, error_code, address);
27552 + return;
27553 + }
27554 + if (address < pax_user_shadow_base) {
27555 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27556 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27557 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27558 + } else
27559 + address -= pax_user_shadow_base;
27560 + }
27561 +#endif
27562 +
27563 + tsk = current;
27564 + mm = tsk->mm;
27565
27566 /*
27567 * Detect and handle instructions that would cause a page fault for
27568 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27569 * User-mode registers count as a user access even for any
27570 * potential system fault or CPU buglet:
27571 */
27572 - if (user_mode_vm(regs)) {
27573 + if (user_mode(regs)) {
27574 local_irq_enable();
27575 error_code |= PF_USER;
27576 } else {
27577 @@ -1142,6 +1352,11 @@ retry:
27578 might_sleep();
27579 }
27580
27581 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27582 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27583 + return;
27584 +#endif
27585 +
27586 vma = find_vma(mm, address);
27587 if (unlikely(!vma)) {
27588 bad_area(regs, error_code, address);
27589 @@ -1153,18 +1368,24 @@ retry:
27590 bad_area(regs, error_code, address);
27591 return;
27592 }
27593 - if (error_code & PF_USER) {
27594 - /*
27595 - * Accessing the stack below %sp is always a bug.
27596 - * The large cushion allows instructions like enter
27597 - * and pusha to work. ("enter $65535, $31" pushes
27598 - * 32 pointers and then decrements %sp by 65535.)
27599 - */
27600 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27601 - bad_area(regs, error_code, address);
27602 - return;
27603 - }
27604 + /*
27605 + * Accessing the stack below %sp is always a bug.
27606 + * The large cushion allows instructions like enter
27607 + * and pusha to work. ("enter $65535, $31" pushes
27608 + * 32 pointers and then decrements %sp by 65535.)
27609 + */
27610 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27611 + bad_area(regs, error_code, address);
27612 + return;
27613 }
27614 +
27615 +#ifdef CONFIG_PAX_SEGMEXEC
27616 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27617 + bad_area(regs, error_code, address);
27618 + return;
27619 + }
27620 +#endif
27621 +
27622 if (unlikely(expand_stack(vma, address))) {
27623 bad_area(regs, error_code, address);
27624 return;
27625 @@ -1228,3 +1449,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27626 __do_page_fault(regs, error_code);
27627 exception_exit(regs);
27628 }
27629 +
27630 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27631 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27632 +{
27633 + struct mm_struct *mm = current->mm;
27634 + unsigned long ip = regs->ip;
27635 +
27636 + if (v8086_mode(regs))
27637 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27638 +
27639 +#ifdef CONFIG_PAX_PAGEEXEC
27640 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27641 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27642 + return true;
27643 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27644 + return true;
27645 + return false;
27646 + }
27647 +#endif
27648 +
27649 +#ifdef CONFIG_PAX_SEGMEXEC
27650 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27651 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27652 + return true;
27653 + return false;
27654 + }
27655 +#endif
27656 +
27657 + return false;
27658 +}
27659 +#endif
27660 +
27661 +#ifdef CONFIG_PAX_EMUTRAMP
27662 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27663 +{
27664 + int err;
27665 +
27666 + do { /* PaX: libffi trampoline emulation */
27667 + unsigned char mov, jmp;
27668 + unsigned int addr1, addr2;
27669 +
27670 +#ifdef CONFIG_X86_64
27671 + if ((regs->ip + 9) >> 32)
27672 + break;
27673 +#endif
27674 +
27675 + err = get_user(mov, (unsigned char __user *)regs->ip);
27676 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27677 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27678 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27679 +
27680 + if (err)
27681 + break;
27682 +
27683 + if (mov == 0xB8 && jmp == 0xE9) {
27684 + regs->ax = addr1;
27685 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27686 + return 2;
27687 + }
27688 + } while (0);
27689 +
27690 + do { /* PaX: gcc trampoline emulation #1 */
27691 + unsigned char mov1, mov2;
27692 + unsigned short jmp;
27693 + unsigned int addr1, addr2;
27694 +
27695 +#ifdef CONFIG_X86_64
27696 + if ((regs->ip + 11) >> 32)
27697 + break;
27698 +#endif
27699 +
27700 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27701 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27702 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27703 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27704 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27705 +
27706 + if (err)
27707 + break;
27708 +
27709 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27710 + regs->cx = addr1;
27711 + regs->ax = addr2;
27712 + regs->ip = addr2;
27713 + return 2;
27714 + }
27715 + } while (0);
27716 +
27717 + do { /* PaX: gcc trampoline emulation #2 */
27718 + unsigned char mov, jmp;
27719 + unsigned int addr1, addr2;
27720 +
27721 +#ifdef CONFIG_X86_64
27722 + if ((regs->ip + 9) >> 32)
27723 + break;
27724 +#endif
27725 +
27726 + err = get_user(mov, (unsigned char __user *)regs->ip);
27727 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27728 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27729 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27730 +
27731 + if (err)
27732 + break;
27733 +
27734 + if (mov == 0xB9 && jmp == 0xE9) {
27735 + regs->cx = addr1;
27736 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27737 + return 2;
27738 + }
27739 + } while (0);
27740 +
27741 + return 1; /* PaX in action */
27742 +}
27743 +
27744 +#ifdef CONFIG_X86_64
27745 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27746 +{
27747 + int err;
27748 +
27749 + do { /* PaX: libffi trampoline emulation */
27750 + unsigned short mov1, mov2, jmp1;
27751 + unsigned char stcclc, jmp2;
27752 + unsigned long addr1, addr2;
27753 +
27754 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27755 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27756 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27757 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27758 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27759 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27760 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27761 +
27762 + if (err)
27763 + break;
27764 +
27765 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27766 + regs->r11 = addr1;
27767 + regs->r10 = addr2;
27768 + if (stcclc == 0xF8)
27769 + regs->flags &= ~X86_EFLAGS_CF;
27770 + else
27771 + regs->flags |= X86_EFLAGS_CF;
27772 + regs->ip = addr1;
27773 + return 2;
27774 + }
27775 + } while (0);
27776 +
27777 + do { /* PaX: gcc trampoline emulation #1 */
27778 + unsigned short mov1, mov2, jmp1;
27779 + unsigned char jmp2;
27780 + unsigned int addr1;
27781 + unsigned long addr2;
27782 +
27783 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27784 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27785 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27786 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27787 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27788 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27789 +
27790 + if (err)
27791 + break;
27792 +
27793 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27794 + regs->r11 = addr1;
27795 + regs->r10 = addr2;
27796 + regs->ip = addr1;
27797 + return 2;
27798 + }
27799 + } while (0);
27800 +
27801 + do { /* PaX: gcc trampoline emulation #2 */
27802 + unsigned short mov1, mov2, jmp1;
27803 + unsigned char jmp2;
27804 + unsigned long addr1, addr2;
27805 +
27806 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27807 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27808 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27809 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27810 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27811 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27812 +
27813 + if (err)
27814 + break;
27815 +
27816 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27817 + regs->r11 = addr1;
27818 + regs->r10 = addr2;
27819 + regs->ip = addr1;
27820 + return 2;
27821 + }
27822 + } while (0);
27823 +
27824 + return 1; /* PaX in action */
27825 +}
27826 +#endif
27827 +
27828 +/*
27829 + * PaX: decide what to do with offenders (regs->ip = fault address)
27830 + *
27831 + * returns 1 when task should be killed
27832 + * 2 when gcc trampoline was detected
27833 + */
27834 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27835 +{
27836 + if (v8086_mode(regs))
27837 + return 1;
27838 +
27839 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27840 + return 1;
27841 +
27842 +#ifdef CONFIG_X86_32
27843 + return pax_handle_fetch_fault_32(regs);
27844 +#else
27845 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27846 + return pax_handle_fetch_fault_32(regs);
27847 + else
27848 + return pax_handle_fetch_fault_64(regs);
27849 +#endif
27850 +}
27851 +#endif
27852 +
27853 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27854 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27855 +{
27856 + long i;
27857 +
27858 + printk(KERN_ERR "PAX: bytes at PC: ");
27859 + for (i = 0; i < 20; i++) {
27860 + unsigned char c;
27861 + if (get_user(c, (unsigned char __force_user *)pc+i))
27862 + printk(KERN_CONT "?? ");
27863 + else
27864 + printk(KERN_CONT "%02x ", c);
27865 + }
27866 + printk("\n");
27867 +
27868 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27869 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27870 + unsigned long c;
27871 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27872 +#ifdef CONFIG_X86_32
27873 + printk(KERN_CONT "???????? ");
27874 +#else
27875 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27876 + printk(KERN_CONT "???????? ???????? ");
27877 + else
27878 + printk(KERN_CONT "???????????????? ");
27879 +#endif
27880 + } else {
27881 +#ifdef CONFIG_X86_64
27882 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27883 + printk(KERN_CONT "%08x ", (unsigned int)c);
27884 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27885 + } else
27886 +#endif
27887 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27888 + }
27889 + }
27890 + printk("\n");
27891 +}
27892 +#endif
27893 +
27894 +/**
27895 + * probe_kernel_write(): safely attempt to write to a location
27896 + * @dst: address to write to
27897 + * @src: pointer to the data that shall be written
27898 + * @size: size of the data chunk
27899 + *
27900 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27901 + * happens, handle that and return -EFAULT.
27902 + */
27903 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27904 +{
27905 + long ret;
27906 + mm_segment_t old_fs = get_fs();
27907 +
27908 + set_fs(KERNEL_DS);
27909 + pagefault_disable();
27910 + pax_open_kernel();
27911 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27912 + pax_close_kernel();
27913 + pagefault_enable();
27914 + set_fs(old_fs);
27915 +
27916 + return ret ? -EFAULT : 0;
27917 +}
27918 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27919 index dd74e46..7d26398 100644
27920 --- a/arch/x86/mm/gup.c
27921 +++ b/arch/x86/mm/gup.c
27922 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27923 addr = start;
27924 len = (unsigned long) nr_pages << PAGE_SHIFT;
27925 end = start + len;
27926 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27927 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27928 (void __user *)start, len)))
27929 return 0;
27930
27931 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27932 index 6f31ee5..8ee4164 100644
27933 --- a/arch/x86/mm/highmem_32.c
27934 +++ b/arch/x86/mm/highmem_32.c
27935 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27936 idx = type + KM_TYPE_NR*smp_processor_id();
27937 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27938 BUG_ON(!pte_none(*(kmap_pte-idx)));
27939 +
27940 + pax_open_kernel();
27941 set_pte(kmap_pte-idx, mk_pte(page, prot));
27942 + pax_close_kernel();
27943 +
27944 arch_flush_lazy_mmu_mode();
27945
27946 return (void *)vaddr;
27947 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27948 index ae1aa71..d9bea75 100644
27949 --- a/arch/x86/mm/hugetlbpage.c
27950 +++ b/arch/x86/mm/hugetlbpage.c
27951 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
27952 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
27953 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27954 unsigned long addr, unsigned long len,
27955 - unsigned long pgoff, unsigned long flags)
27956 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27957 {
27958 struct hstate *h = hstate_file(file);
27959 struct vm_unmapped_area_info info;
27960 -
27961 +
27962 info.flags = 0;
27963 info.length = len;
27964 info.low_limit = TASK_UNMAPPED_BASE;
27965 +
27966 +#ifdef CONFIG_PAX_RANDMMAP
27967 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27968 + info.low_limit += current->mm->delta_mmap;
27969 +#endif
27970 +
27971 info.high_limit = TASK_SIZE;
27972 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27973 info.align_offset = 0;
27974 + info.threadstack_offset = offset;
27975 return vm_unmapped_area(&info);
27976 }
27977
27978 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27979 unsigned long addr0, unsigned long len,
27980 - unsigned long pgoff, unsigned long flags)
27981 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27982 {
27983 struct hstate *h = hstate_file(file);
27984 struct vm_unmapped_area_info info;
27985 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27986 info.high_limit = current->mm->mmap_base;
27987 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27988 info.align_offset = 0;
27989 + info.threadstack_offset = offset;
27990 addr = vm_unmapped_area(&info);
27991
27992 /*
27993 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27994 VM_BUG_ON(addr != -ENOMEM);
27995 info.flags = 0;
27996 info.low_limit = TASK_UNMAPPED_BASE;
27997 +
27998 +#ifdef CONFIG_PAX_RANDMMAP
27999 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28000 + info.low_limit += current->mm->delta_mmap;
28001 +#endif
28002 +
28003 info.high_limit = TASK_SIZE;
28004 addr = vm_unmapped_area(&info);
28005 }
28006 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28007 struct hstate *h = hstate_file(file);
28008 struct mm_struct *mm = current->mm;
28009 struct vm_area_struct *vma;
28010 + unsigned long pax_task_size = TASK_SIZE;
28011 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28012
28013 if (len & ~huge_page_mask(h))
28014 return -EINVAL;
28015 - if (len > TASK_SIZE)
28016 +
28017 +#ifdef CONFIG_PAX_SEGMEXEC
28018 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28019 + pax_task_size = SEGMEXEC_TASK_SIZE;
28020 +#endif
28021 +
28022 + pax_task_size -= PAGE_SIZE;
28023 +
28024 + if (len > pax_task_size)
28025 return -ENOMEM;
28026
28027 if (flags & MAP_FIXED) {
28028 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28029 return addr;
28030 }
28031
28032 +#ifdef CONFIG_PAX_RANDMMAP
28033 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28034 +#endif
28035 +
28036 if (addr) {
28037 addr = ALIGN(addr, huge_page_size(h));
28038 vma = find_vma(mm, addr);
28039 - if (TASK_SIZE - len >= addr &&
28040 - (!vma || addr + len <= vma->vm_start))
28041 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28042 return addr;
28043 }
28044 if (mm->get_unmapped_area == arch_get_unmapped_area)
28045 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
28046 - pgoff, flags);
28047 + pgoff, flags, offset);
28048 else
28049 return hugetlb_get_unmapped_area_topdown(file, addr, len,
28050 - pgoff, flags);
28051 + pgoff, flags, offset);
28052 }
28053
28054 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
28055 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28056 index 59b7fc4..b1dd75f 100644
28057 --- a/arch/x86/mm/init.c
28058 +++ b/arch/x86/mm/init.c
28059 @@ -4,6 +4,7 @@
28060 #include <linux/swap.h>
28061 #include <linux/memblock.h>
28062 #include <linux/bootmem.h> /* for max_low_pfn */
28063 +#include <linux/tboot.h>
28064
28065 #include <asm/cacheflush.h>
28066 #include <asm/e820.h>
28067 @@ -17,6 +18,8 @@
28068 #include <asm/proto.h>
28069 #include <asm/dma.h> /* for MAX_DMA_PFN */
28070 #include <asm/microcode.h>
28071 +#include <asm/desc.h>
28072 +#include <asm/bios_ebda.h>
28073
28074 #include "mm_internal.h"
28075
28076 @@ -464,10 +467,40 @@ void __init init_mem_mapping(void)
28077 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28078 * mmio resources as well as potential bios/acpi data regions.
28079 */
28080 +
28081 +#ifdef CONFIG_GRKERNSEC_KMEM
28082 +static unsigned int ebda_start __read_only;
28083 +static unsigned int ebda_end __read_only;
28084 +#endif
28085 +
28086 int devmem_is_allowed(unsigned long pagenr)
28087 {
28088 - if (pagenr < 256)
28089 +#ifdef CONFIG_GRKERNSEC_KMEM
28090 + /* allow BDA */
28091 + if (!pagenr)
28092 return 1;
28093 + /* allow EBDA */
28094 + if (pagenr >= ebda_start && pagenr < ebda_end)
28095 + return 1;
28096 + /* if tboot is in use, allow access to its hardcoded serial log range */
28097 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28098 + return 1;
28099 +#else
28100 + if (!pagenr)
28101 + return 1;
28102 +#ifdef CONFIG_VM86
28103 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28104 + return 1;
28105 +#endif
28106 +#endif
28107 +
28108 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28109 + return 1;
28110 +#ifdef CONFIG_GRKERNSEC_KMEM
28111 + /* throw out everything else below 1MB */
28112 + if (pagenr <= 256)
28113 + return 0;
28114 +#endif
28115 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28116 return 0;
28117 if (!page_is_ram(pagenr))
28118 @@ -524,8 +557,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28119 #endif
28120 }
28121
28122 +#ifdef CONFIG_GRKERNSEC_KMEM
28123 +static inline void gr_init_ebda(void)
28124 +{
28125 + unsigned int ebda_addr;
28126 + unsigned int ebda_size = 0;
28127 +
28128 + ebda_addr = get_bios_ebda();
28129 + if (ebda_addr) {
28130 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28131 + ebda_size <<= 10;
28132 + }
28133 + if (ebda_addr && ebda_size) {
28134 + ebda_start = ebda_addr >> PAGE_SHIFT;
28135 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28136 + } else {
28137 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28138 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28139 + }
28140 +}
28141 +#else
28142 +static inline void gr_init_ebda(void) { }
28143 +#endif
28144 +
28145 void free_initmem(void)
28146 {
28147 +#ifdef CONFIG_PAX_KERNEXEC
28148 +#ifdef CONFIG_X86_32
28149 + /* PaX: limit KERNEL_CS to actual size */
28150 + unsigned long addr, limit;
28151 + struct desc_struct d;
28152 + int cpu;
28153 +#else
28154 + pgd_t *pgd;
28155 + pud_t *pud;
28156 + pmd_t *pmd;
28157 + unsigned long addr, end;
28158 +#endif
28159 +#endif
28160 +
28161 + gr_init_ebda();
28162 +
28163 +#ifdef CONFIG_PAX_KERNEXEC
28164 +#ifdef CONFIG_X86_32
28165 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28166 + limit = (limit - 1UL) >> PAGE_SHIFT;
28167 +
28168 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28169 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28170 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28171 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28172 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28173 + }
28174 +
28175 + /* PaX: make KERNEL_CS read-only */
28176 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28177 + if (!paravirt_enabled())
28178 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28179 +/*
28180 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28181 + pgd = pgd_offset_k(addr);
28182 + pud = pud_offset(pgd, addr);
28183 + pmd = pmd_offset(pud, addr);
28184 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28185 + }
28186 +*/
28187 +#ifdef CONFIG_X86_PAE
28188 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28189 +/*
28190 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28191 + pgd = pgd_offset_k(addr);
28192 + pud = pud_offset(pgd, addr);
28193 + pmd = pmd_offset(pud, addr);
28194 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28195 + }
28196 +*/
28197 +#endif
28198 +
28199 +#ifdef CONFIG_MODULES
28200 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28201 +#endif
28202 +
28203 +#else
28204 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28205 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28206 + pgd = pgd_offset_k(addr);
28207 + pud = pud_offset(pgd, addr);
28208 + pmd = pmd_offset(pud, addr);
28209 + if (!pmd_present(*pmd))
28210 + continue;
28211 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28212 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28213 + else
28214 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28215 + }
28216 +
28217 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28218 + end = addr + KERNEL_IMAGE_SIZE;
28219 + for (; addr < end; addr += PMD_SIZE) {
28220 + pgd = pgd_offset_k(addr);
28221 + pud = pud_offset(pgd, addr);
28222 + pmd = pmd_offset(pud, addr);
28223 + if (!pmd_present(*pmd))
28224 + continue;
28225 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28226 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28227 + }
28228 +#endif
28229 +
28230 + flush_tlb_all();
28231 +#endif
28232 +
28233 free_init_pages("unused kernel memory",
28234 (unsigned long)(&__init_begin),
28235 (unsigned long)(&__init_end));
28236 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28237 index 2d19001..6a1046c 100644
28238 --- a/arch/x86/mm/init_32.c
28239 +++ b/arch/x86/mm/init_32.c
28240 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28241 bool __read_mostly __vmalloc_start_set = false;
28242
28243 /*
28244 - * Creates a middle page table and puts a pointer to it in the
28245 - * given global directory entry. This only returns the gd entry
28246 - * in non-PAE compilation mode, since the middle layer is folded.
28247 - */
28248 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28249 -{
28250 - pud_t *pud;
28251 - pmd_t *pmd_table;
28252 -
28253 -#ifdef CONFIG_X86_PAE
28254 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28255 - pmd_table = (pmd_t *)alloc_low_page();
28256 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28257 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28258 - pud = pud_offset(pgd, 0);
28259 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28260 -
28261 - return pmd_table;
28262 - }
28263 -#endif
28264 - pud = pud_offset(pgd, 0);
28265 - pmd_table = pmd_offset(pud, 0);
28266 -
28267 - return pmd_table;
28268 -}
28269 -
28270 -/*
28271 * Create a page table and place a pointer to it in a middle page
28272 * directory entry:
28273 */
28274 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28275 pte_t *page_table = (pte_t *)alloc_low_page();
28276
28277 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28278 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28279 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28280 +#else
28281 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28282 +#endif
28283 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28284 }
28285
28286 return pte_offset_kernel(pmd, 0);
28287 }
28288
28289 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28290 +{
28291 + pud_t *pud;
28292 + pmd_t *pmd_table;
28293 +
28294 + pud = pud_offset(pgd, 0);
28295 + pmd_table = pmd_offset(pud, 0);
28296 +
28297 + return pmd_table;
28298 +}
28299 +
28300 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28301 {
28302 int pgd_idx = pgd_index(vaddr);
28303 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28304 int pgd_idx, pmd_idx;
28305 unsigned long vaddr;
28306 pgd_t *pgd;
28307 + pud_t *pud;
28308 pmd_t *pmd;
28309 pte_t *pte = NULL;
28310 unsigned long count = page_table_range_init_count(start, end);
28311 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28312 pgd = pgd_base + pgd_idx;
28313
28314 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28315 - pmd = one_md_table_init(pgd);
28316 - pmd = pmd + pmd_index(vaddr);
28317 + pud = pud_offset(pgd, vaddr);
28318 + pmd = pmd_offset(pud, vaddr);
28319 +
28320 +#ifdef CONFIG_X86_PAE
28321 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28322 +#endif
28323 +
28324 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28325 pmd++, pmd_idx++) {
28326 pte = page_table_kmap_check(one_page_table_init(pmd),
28327 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28328 }
28329 }
28330
28331 -static inline int is_kernel_text(unsigned long addr)
28332 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28333 {
28334 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28335 - return 1;
28336 - return 0;
28337 + if ((start > ktla_ktva((unsigned long)_etext) ||
28338 + end <= ktla_ktva((unsigned long)_stext)) &&
28339 + (start > ktla_ktva((unsigned long)_einittext) ||
28340 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28341 +
28342 +#ifdef CONFIG_ACPI_SLEEP
28343 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28344 +#endif
28345 +
28346 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28347 + return 0;
28348 + return 1;
28349 }
28350
28351 /*
28352 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28353 unsigned long last_map_addr = end;
28354 unsigned long start_pfn, end_pfn;
28355 pgd_t *pgd_base = swapper_pg_dir;
28356 - int pgd_idx, pmd_idx, pte_ofs;
28357 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28358 unsigned long pfn;
28359 pgd_t *pgd;
28360 + pud_t *pud;
28361 pmd_t *pmd;
28362 pte_t *pte;
28363 unsigned pages_2m, pages_4k;
28364 @@ -291,8 +295,13 @@ repeat:
28365 pfn = start_pfn;
28366 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28367 pgd = pgd_base + pgd_idx;
28368 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28369 - pmd = one_md_table_init(pgd);
28370 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28371 + pud = pud_offset(pgd, 0);
28372 + pmd = pmd_offset(pud, 0);
28373 +
28374 +#ifdef CONFIG_X86_PAE
28375 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28376 +#endif
28377
28378 if (pfn >= end_pfn)
28379 continue;
28380 @@ -304,14 +313,13 @@ repeat:
28381 #endif
28382 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28383 pmd++, pmd_idx++) {
28384 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28385 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28386
28387 /*
28388 * Map with big pages if possible, otherwise
28389 * create normal page tables:
28390 */
28391 if (use_pse) {
28392 - unsigned int addr2;
28393 pgprot_t prot = PAGE_KERNEL_LARGE;
28394 /*
28395 * first pass will use the same initial
28396 @@ -322,11 +330,7 @@ repeat:
28397 _PAGE_PSE);
28398
28399 pfn &= PMD_MASK >> PAGE_SHIFT;
28400 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28401 - PAGE_OFFSET + PAGE_SIZE-1;
28402 -
28403 - if (is_kernel_text(addr) ||
28404 - is_kernel_text(addr2))
28405 + if (is_kernel_text(address, address + PMD_SIZE))
28406 prot = PAGE_KERNEL_LARGE_EXEC;
28407
28408 pages_2m++;
28409 @@ -343,7 +347,7 @@ repeat:
28410 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28411 pte += pte_ofs;
28412 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28413 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28414 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28415 pgprot_t prot = PAGE_KERNEL;
28416 /*
28417 * first pass will use the same initial
28418 @@ -351,7 +355,7 @@ repeat:
28419 */
28420 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28421
28422 - if (is_kernel_text(addr))
28423 + if (is_kernel_text(address, address + PAGE_SIZE))
28424 prot = PAGE_KERNEL_EXEC;
28425
28426 pages_4k++;
28427 @@ -482,7 +486,7 @@ void __init native_pagetable_init(void)
28428
28429 pud = pud_offset(pgd, va);
28430 pmd = pmd_offset(pud, va);
28431 - if (!pmd_present(*pmd))
28432 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28433 break;
28434
28435 /* should not be large page here */
28436 @@ -540,12 +544,10 @@ void __init early_ioremap_page_table_range_init(void)
28437
28438 static void __init pagetable_init(void)
28439 {
28440 - pgd_t *pgd_base = swapper_pg_dir;
28441 -
28442 - permanent_kmaps_init(pgd_base);
28443 + permanent_kmaps_init(swapper_pg_dir);
28444 }
28445
28446 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28447 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28448 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28449
28450 /* user-defined highmem size */
28451 @@ -752,6 +754,12 @@ void __init mem_init(void)
28452
28453 pci_iommu_alloc();
28454
28455 +#ifdef CONFIG_PAX_PER_CPU_PGD
28456 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28457 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28458 + KERNEL_PGD_PTRS);
28459 +#endif
28460 +
28461 #ifdef CONFIG_FLATMEM
28462 BUG_ON(!mem_map);
28463 #endif
28464 @@ -780,7 +788,7 @@ void __init mem_init(void)
28465 after_bootmem = 1;
28466
28467 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28468 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28469 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28470 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28471
28472 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28473 @@ -821,10 +829,10 @@ void __init mem_init(void)
28474 ((unsigned long)&__init_end -
28475 (unsigned long)&__init_begin) >> 10,
28476
28477 - (unsigned long)&_etext, (unsigned long)&_edata,
28478 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28479 + (unsigned long)&_sdata, (unsigned long)&_edata,
28480 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28481
28482 - (unsigned long)&_text, (unsigned long)&_etext,
28483 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28484 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28485
28486 /*
28487 @@ -914,6 +922,7 @@ void set_kernel_text_rw(void)
28488 if (!kernel_set_to_readonly)
28489 return;
28490
28491 + start = ktla_ktva(start);
28492 pr_debug("Set kernel text: %lx - %lx for read write\n",
28493 start, start+size);
28494
28495 @@ -928,6 +937,7 @@ void set_kernel_text_ro(void)
28496 if (!kernel_set_to_readonly)
28497 return;
28498
28499 + start = ktla_ktva(start);
28500 pr_debug("Set kernel text: %lx - %lx for read only\n",
28501 start, start+size);
28502
28503 @@ -956,6 +966,7 @@ void mark_rodata_ro(void)
28504 unsigned long start = PFN_ALIGN(_text);
28505 unsigned long size = PFN_ALIGN(_etext) - start;
28506
28507 + start = ktla_ktva(start);
28508 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28509 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28510 size >> 10);
28511 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28512 index 474e28f..647dd12 100644
28513 --- a/arch/x86/mm/init_64.c
28514 +++ b/arch/x86/mm/init_64.c
28515 @@ -150,7 +150,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28516 * around without checking the pgd every time.
28517 */
28518
28519 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28520 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28521 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28522
28523 int force_personality32;
28524 @@ -183,12 +183,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28525
28526 for (address = start; address <= end; address += PGDIR_SIZE) {
28527 const pgd_t *pgd_ref = pgd_offset_k(address);
28528 +
28529 +#ifdef CONFIG_PAX_PER_CPU_PGD
28530 + unsigned long cpu;
28531 +#else
28532 struct page *page;
28533 +#endif
28534
28535 if (pgd_none(*pgd_ref))
28536 continue;
28537
28538 spin_lock(&pgd_lock);
28539 +
28540 +#ifdef CONFIG_PAX_PER_CPU_PGD
28541 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28542 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28543 +#else
28544 list_for_each_entry(page, &pgd_list, lru) {
28545 pgd_t *pgd;
28546 spinlock_t *pgt_lock;
28547 @@ -197,6 +207,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28548 /* the pgt_lock only for Xen */
28549 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28550 spin_lock(pgt_lock);
28551 +#endif
28552
28553 if (pgd_none(*pgd))
28554 set_pgd(pgd, *pgd_ref);
28555 @@ -204,7 +215,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28556 BUG_ON(pgd_page_vaddr(*pgd)
28557 != pgd_page_vaddr(*pgd_ref));
28558
28559 +#ifndef CONFIG_PAX_PER_CPU_PGD
28560 spin_unlock(pgt_lock);
28561 +#endif
28562 +
28563 }
28564 spin_unlock(&pgd_lock);
28565 }
28566 @@ -237,7 +251,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28567 {
28568 if (pgd_none(*pgd)) {
28569 pud_t *pud = (pud_t *)spp_getpage();
28570 - pgd_populate(&init_mm, pgd, pud);
28571 + pgd_populate_kernel(&init_mm, pgd, pud);
28572 if (pud != pud_offset(pgd, 0))
28573 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28574 pud, pud_offset(pgd, 0));
28575 @@ -249,7 +263,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28576 {
28577 if (pud_none(*pud)) {
28578 pmd_t *pmd = (pmd_t *) spp_getpage();
28579 - pud_populate(&init_mm, pud, pmd);
28580 + pud_populate_kernel(&init_mm, pud, pmd);
28581 if (pmd != pmd_offset(pud, 0))
28582 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28583 pmd, pmd_offset(pud, 0));
28584 @@ -278,7 +292,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28585 pmd = fill_pmd(pud, vaddr);
28586 pte = fill_pte(pmd, vaddr);
28587
28588 + pax_open_kernel();
28589 set_pte(pte, new_pte);
28590 + pax_close_kernel();
28591
28592 /*
28593 * It's enough to flush this one mapping.
28594 @@ -337,14 +353,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28595 pgd = pgd_offset_k((unsigned long)__va(phys));
28596 if (pgd_none(*pgd)) {
28597 pud = (pud_t *) spp_getpage();
28598 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28599 - _PAGE_USER));
28600 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28601 }
28602 pud = pud_offset(pgd, (unsigned long)__va(phys));
28603 if (pud_none(*pud)) {
28604 pmd = (pmd_t *) spp_getpage();
28605 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28606 - _PAGE_USER));
28607 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28608 }
28609 pmd = pmd_offset(pud, phys);
28610 BUG_ON(!pmd_none(*pmd));
28611 @@ -585,7 +599,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28612 prot);
28613
28614 spin_lock(&init_mm.page_table_lock);
28615 - pud_populate(&init_mm, pud, pmd);
28616 + pud_populate_kernel(&init_mm, pud, pmd);
28617 spin_unlock(&init_mm.page_table_lock);
28618 }
28619 __flush_tlb_all();
28620 @@ -626,7 +640,7 @@ kernel_physical_mapping_init(unsigned long start,
28621 page_size_mask);
28622
28623 spin_lock(&init_mm.page_table_lock);
28624 - pgd_populate(&init_mm, pgd, pud);
28625 + pgd_populate_kernel(&init_mm, pgd, pud);
28626 spin_unlock(&init_mm.page_table_lock);
28627 pgd_changed = true;
28628 }
28629 @@ -1065,6 +1079,12 @@ void __init mem_init(void)
28630
28631 pci_iommu_alloc();
28632
28633 +#ifdef CONFIG_PAX_PER_CPU_PGD
28634 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28635 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28636 + KERNEL_PGD_PTRS);
28637 +#endif
28638 +
28639 /* clear_bss() already clear the empty_zero_page */
28640
28641 reservedpages = 0;
28642 @@ -1224,8 +1244,8 @@ int kern_addr_valid(unsigned long addr)
28643 static struct vm_area_struct gate_vma = {
28644 .vm_start = VSYSCALL_START,
28645 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28646 - .vm_page_prot = PAGE_READONLY_EXEC,
28647 - .vm_flags = VM_READ | VM_EXEC
28648 + .vm_page_prot = PAGE_READONLY,
28649 + .vm_flags = VM_READ
28650 };
28651
28652 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28653 @@ -1259,7 +1279,7 @@ int in_gate_area_no_mm(unsigned long addr)
28654
28655 const char *arch_vma_name(struct vm_area_struct *vma)
28656 {
28657 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28658 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28659 return "[vdso]";
28660 if (vma == &gate_vma)
28661 return "[vsyscall]";
28662 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28663 index 7b179b4..6bd17777 100644
28664 --- a/arch/x86/mm/iomap_32.c
28665 +++ b/arch/x86/mm/iomap_32.c
28666 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28667 type = kmap_atomic_idx_push();
28668 idx = type + KM_TYPE_NR * smp_processor_id();
28669 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28670 +
28671 + pax_open_kernel();
28672 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28673 + pax_close_kernel();
28674 +
28675 arch_flush_lazy_mmu_mode();
28676
28677 return (void *)vaddr;
28678 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28679 index 78fe3f1..73b95e2 100644
28680 --- a/arch/x86/mm/ioremap.c
28681 +++ b/arch/x86/mm/ioremap.c
28682 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28683 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28684 int is_ram = page_is_ram(pfn);
28685
28686 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28687 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28688 return NULL;
28689 WARN_ON_ONCE(is_ram);
28690 }
28691 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28692 *
28693 * Caller must ensure there is only one unmapping for the same pointer.
28694 */
28695 -void iounmap(volatile void __iomem *addr)
28696 +void iounmap(const volatile void __iomem *addr)
28697 {
28698 struct vm_struct *p, *o;
28699
28700 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28701
28702 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28703 if (page_is_ram(start >> PAGE_SHIFT))
28704 +#ifdef CONFIG_HIGHMEM
28705 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28706 +#endif
28707 return __va(phys);
28708
28709 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28710 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28711 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28712 {
28713 if (page_is_ram(phys >> PAGE_SHIFT))
28714 +#ifdef CONFIG_HIGHMEM
28715 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28716 +#endif
28717 return;
28718
28719 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28720 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
28721 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28722
28723 static __initdata int after_paging_init;
28724 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28725 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28726
28727 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28728 {
28729 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
28730 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28731
28732 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28733 - memset(bm_pte, 0, sizeof(bm_pte));
28734 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28735 + pmd_populate_user(&init_mm, pmd, bm_pte);
28736
28737 /*
28738 * The boot-ioremap range spans multiple pmds, for which
28739 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28740 index d87dd6d..bf3fa66 100644
28741 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28742 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28743 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28744 * memory (e.g. tracked pages)? For now, we need this to avoid
28745 * invoking kmemcheck for PnP BIOS calls.
28746 */
28747 - if (regs->flags & X86_VM_MASK)
28748 + if (v8086_mode(regs))
28749 return false;
28750 - if (regs->cs != __KERNEL_CS)
28751 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28752 return false;
28753
28754 pte = kmemcheck_pte_lookup(address);
28755 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28756 index 845df68..1d8d29f 100644
28757 --- a/arch/x86/mm/mmap.c
28758 +++ b/arch/x86/mm/mmap.c
28759 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28760 * Leave an at least ~128 MB hole with possible stack randomization.
28761 */
28762 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28763 -#define MAX_GAP (TASK_SIZE/6*5)
28764 +#define MAX_GAP (pax_task_size/6*5)
28765
28766 static int mmap_is_legacy(void)
28767 {
28768 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28769 return rnd << PAGE_SHIFT;
28770 }
28771
28772 -static unsigned long mmap_base(void)
28773 +static unsigned long mmap_base(struct mm_struct *mm)
28774 {
28775 unsigned long gap = rlimit(RLIMIT_STACK);
28776 + unsigned long pax_task_size = TASK_SIZE;
28777 +
28778 +#ifdef CONFIG_PAX_SEGMEXEC
28779 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28780 + pax_task_size = SEGMEXEC_TASK_SIZE;
28781 +#endif
28782
28783 if (gap < MIN_GAP)
28784 gap = MIN_GAP;
28785 else if (gap > MAX_GAP)
28786 gap = MAX_GAP;
28787
28788 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28789 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28790 }
28791
28792 /*
28793 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28794 * does, but not when emulating X86_32
28795 */
28796 -static unsigned long mmap_legacy_base(void)
28797 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28798 {
28799 - if (mmap_is_ia32())
28800 + if (mmap_is_ia32()) {
28801 +
28802 +#ifdef CONFIG_PAX_SEGMEXEC
28803 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28804 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28805 + else
28806 +#endif
28807 +
28808 return TASK_UNMAPPED_BASE;
28809 - else
28810 + } else
28811 return TASK_UNMAPPED_BASE + mmap_rnd();
28812 }
28813
28814 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28815 void arch_pick_mmap_layout(struct mm_struct *mm)
28816 {
28817 if (mmap_is_legacy()) {
28818 - mm->mmap_base = mmap_legacy_base();
28819 + mm->mmap_base = mmap_legacy_base(mm);
28820 +
28821 +#ifdef CONFIG_PAX_RANDMMAP
28822 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28823 + mm->mmap_base += mm->delta_mmap;
28824 +#endif
28825 +
28826 mm->get_unmapped_area = arch_get_unmapped_area;
28827 mm->unmap_area = arch_unmap_area;
28828 } else {
28829 - mm->mmap_base = mmap_base();
28830 + mm->mmap_base = mmap_base(mm);
28831 +
28832 +#ifdef CONFIG_PAX_RANDMMAP
28833 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28834 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28835 +#endif
28836 +
28837 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28838 mm->unmap_area = arch_unmap_area_topdown;
28839 }
28840 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28841 index dc0b727..f612039 100644
28842 --- a/arch/x86/mm/mmio-mod.c
28843 +++ b/arch/x86/mm/mmio-mod.c
28844 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28845 break;
28846 default:
28847 {
28848 - unsigned char *ip = (unsigned char *)instptr;
28849 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28850 my_trace->opcode = MMIO_UNKNOWN_OP;
28851 my_trace->width = 0;
28852 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28853 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28854 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28855 void __iomem *addr)
28856 {
28857 - static atomic_t next_id;
28858 + static atomic_unchecked_t next_id;
28859 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28860 /* These are page-unaligned. */
28861 struct mmiotrace_map map = {
28862 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28863 .private = trace
28864 },
28865 .phys = offset,
28866 - .id = atomic_inc_return(&next_id)
28867 + .id = atomic_inc_return_unchecked(&next_id)
28868 };
28869 map.map_id = trace->id;
28870
28871 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28872 ioremap_trace_core(offset, size, addr);
28873 }
28874
28875 -static void iounmap_trace_core(volatile void __iomem *addr)
28876 +static void iounmap_trace_core(const volatile void __iomem *addr)
28877 {
28878 struct mmiotrace_map map = {
28879 .phys = 0,
28880 @@ -328,7 +328,7 @@ not_enabled:
28881 }
28882 }
28883
28884 -void mmiotrace_iounmap(volatile void __iomem *addr)
28885 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28886 {
28887 might_sleep();
28888 if (is_enabled()) /* recheck and proper locking in *_core() */
28889 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28890 index 72fe01e..f1a8daa 100644
28891 --- a/arch/x86/mm/numa.c
28892 +++ b/arch/x86/mm/numa.c
28893 @@ -477,7 +477,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28894 return true;
28895 }
28896
28897 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28898 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28899 {
28900 unsigned long uninitialized_var(pfn_align);
28901 int i, nid;
28902 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28903 index 0e38951..4ca8458 100644
28904 --- a/arch/x86/mm/pageattr-test.c
28905 +++ b/arch/x86/mm/pageattr-test.c
28906 @@ -36,7 +36,7 @@ enum {
28907
28908 static int pte_testbit(pte_t pte)
28909 {
28910 - return pte_flags(pte) & _PAGE_UNUSED1;
28911 + return pte_flags(pte) & _PAGE_CPA_TEST;
28912 }
28913
28914 struct split_state {
28915 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28916 index fb4e73e..43f7238 100644
28917 --- a/arch/x86/mm/pageattr.c
28918 +++ b/arch/x86/mm/pageattr.c
28919 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28920 */
28921 #ifdef CONFIG_PCI_BIOS
28922 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28923 - pgprot_val(forbidden) |= _PAGE_NX;
28924 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28925 #endif
28926
28927 /*
28928 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28929 * Does not cover __inittext since that is gone later on. On
28930 * 64bit we do not enforce !NX on the low mapping
28931 */
28932 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28933 - pgprot_val(forbidden) |= _PAGE_NX;
28934 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28935 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28936
28937 +#ifdef CONFIG_DEBUG_RODATA
28938 /*
28939 * The .rodata section needs to be read-only. Using the pfn
28940 * catches all aliases.
28941 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28942 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
28943 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
28944 pgprot_val(forbidden) |= _PAGE_RW;
28945 +#endif
28946
28947 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28948 /*
28949 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28950 }
28951 #endif
28952
28953 +#ifdef CONFIG_PAX_KERNEXEC
28954 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28955 + pgprot_val(forbidden) |= _PAGE_RW;
28956 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28957 + }
28958 +#endif
28959 +
28960 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28961
28962 return prot;
28963 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
28964 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28965 {
28966 /* change init_mm */
28967 + pax_open_kernel();
28968 set_pte_atomic(kpte, pte);
28969 +
28970 #ifdef CONFIG_X86_32
28971 if (!SHARED_KERNEL_PMD) {
28972 +
28973 +#ifdef CONFIG_PAX_PER_CPU_PGD
28974 + unsigned long cpu;
28975 +#else
28976 struct page *page;
28977 +#endif
28978
28979 +#ifdef CONFIG_PAX_PER_CPU_PGD
28980 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28981 + pgd_t *pgd = get_cpu_pgd(cpu);
28982 +#else
28983 list_for_each_entry(page, &pgd_list, lru) {
28984 - pgd_t *pgd;
28985 + pgd_t *pgd = (pgd_t *)page_address(page);
28986 +#endif
28987 +
28988 pud_t *pud;
28989 pmd_t *pmd;
28990
28991 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
28992 + pgd += pgd_index(address);
28993 pud = pud_offset(pgd, address);
28994 pmd = pmd_offset(pud, address);
28995 set_pte_atomic((pte_t *)pmd, pte);
28996 }
28997 }
28998 #endif
28999 + pax_close_kernel();
29000 }
29001
29002 static int
29003 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29004 index 6574388..87e9bef 100644
29005 --- a/arch/x86/mm/pat.c
29006 +++ b/arch/x86/mm/pat.c
29007 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29008
29009 if (!entry) {
29010 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29011 - current->comm, current->pid, start, end - 1);
29012 + current->comm, task_pid_nr(current), start, end - 1);
29013 return -EINVAL;
29014 }
29015
29016 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29017
29018 while (cursor < to) {
29019 if (!devmem_is_allowed(pfn)) {
29020 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29021 - current->comm, from, to - 1);
29022 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29023 + current->comm, from, to - 1, cursor);
29024 return 0;
29025 }
29026 cursor += PAGE_SIZE;
29027 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29028 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29029 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29030 "for [mem %#010Lx-%#010Lx]\n",
29031 - current->comm, current->pid,
29032 + current->comm, task_pid_nr(current),
29033 cattr_name(flags),
29034 base, (unsigned long long)(base + size-1));
29035 return -EINVAL;
29036 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29037 flags = lookup_memtype(paddr);
29038 if (want_flags != flags) {
29039 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29040 - current->comm, current->pid,
29041 + current->comm, task_pid_nr(current),
29042 cattr_name(want_flags),
29043 (unsigned long long)paddr,
29044 (unsigned long long)(paddr + size - 1),
29045 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29046 free_memtype(paddr, paddr + size);
29047 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29048 " for [mem %#010Lx-%#010Lx], got %s\n",
29049 - current->comm, current->pid,
29050 + current->comm, task_pid_nr(current),
29051 cattr_name(want_flags),
29052 (unsigned long long)paddr,
29053 (unsigned long long)(paddr + size - 1),
29054 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29055 index 9f0614d..92ae64a 100644
29056 --- a/arch/x86/mm/pf_in.c
29057 +++ b/arch/x86/mm/pf_in.c
29058 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29059 int i;
29060 enum reason_type rv = OTHERS;
29061
29062 - p = (unsigned char *)ins_addr;
29063 + p = (unsigned char *)ktla_ktva(ins_addr);
29064 p += skip_prefix(p, &prf);
29065 p += get_opcode(p, &opcode);
29066
29067 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29068 struct prefix_bits prf;
29069 int i;
29070
29071 - p = (unsigned char *)ins_addr;
29072 + p = (unsigned char *)ktla_ktva(ins_addr);
29073 p += skip_prefix(p, &prf);
29074 p += get_opcode(p, &opcode);
29075
29076 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29077 struct prefix_bits prf;
29078 int i;
29079
29080 - p = (unsigned char *)ins_addr;
29081 + p = (unsigned char *)ktla_ktva(ins_addr);
29082 p += skip_prefix(p, &prf);
29083 p += get_opcode(p, &opcode);
29084
29085 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29086 struct prefix_bits prf;
29087 int i;
29088
29089 - p = (unsigned char *)ins_addr;
29090 + p = (unsigned char *)ktla_ktva(ins_addr);
29091 p += skip_prefix(p, &prf);
29092 p += get_opcode(p, &opcode);
29093 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29094 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29095 struct prefix_bits prf;
29096 int i;
29097
29098 - p = (unsigned char *)ins_addr;
29099 + p = (unsigned char *)ktla_ktva(ins_addr);
29100 p += skip_prefix(p, &prf);
29101 p += get_opcode(p, &opcode);
29102 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29103 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29104 index 17fda6a..489c74a 100644
29105 --- a/arch/x86/mm/pgtable.c
29106 +++ b/arch/x86/mm/pgtable.c
29107 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29108 list_del(&page->lru);
29109 }
29110
29111 -#define UNSHARED_PTRS_PER_PGD \
29112 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29113 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29114 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29115
29116 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29117 +{
29118 + unsigned int count = USER_PGD_PTRS;
29119
29120 + while (count--)
29121 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29122 +}
29123 +#endif
29124 +
29125 +#ifdef CONFIG_PAX_PER_CPU_PGD
29126 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29127 +{
29128 + unsigned int count = USER_PGD_PTRS;
29129 +
29130 + while (count--) {
29131 + pgd_t pgd;
29132 +
29133 +#ifdef CONFIG_X86_64
29134 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29135 +#else
29136 + pgd = *src++;
29137 +#endif
29138 +
29139 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29140 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29141 +#endif
29142 +
29143 + *dst++ = pgd;
29144 + }
29145 +
29146 +}
29147 +#endif
29148 +
29149 +#ifdef CONFIG_X86_64
29150 +#define pxd_t pud_t
29151 +#define pyd_t pgd_t
29152 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29153 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29154 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29155 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29156 +#define PYD_SIZE PGDIR_SIZE
29157 +#else
29158 +#define pxd_t pmd_t
29159 +#define pyd_t pud_t
29160 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29161 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29162 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29163 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29164 +#define PYD_SIZE PUD_SIZE
29165 +#endif
29166 +
29167 +#ifdef CONFIG_PAX_PER_CPU_PGD
29168 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29169 +static inline void pgd_dtor(pgd_t *pgd) {}
29170 +#else
29171 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29172 {
29173 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29174 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29175 pgd_list_del(pgd);
29176 spin_unlock(&pgd_lock);
29177 }
29178 +#endif
29179
29180 /*
29181 * List of all pgd's needed for non-PAE so it can invalidate entries
29182 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29183 * -- nyc
29184 */
29185
29186 -#ifdef CONFIG_X86_PAE
29187 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29188 /*
29189 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29190 * updating the top-level pagetable entries to guarantee the
29191 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29192 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29193 * and initialize the kernel pmds here.
29194 */
29195 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29196 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29197
29198 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29199 {
29200 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29201 */
29202 flush_tlb_mm(mm);
29203 }
29204 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29205 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29206 #else /* !CONFIG_X86_PAE */
29207
29208 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29209 -#define PREALLOCATED_PMDS 0
29210 +#define PREALLOCATED_PXDS 0
29211
29212 #endif /* CONFIG_X86_PAE */
29213
29214 -static void free_pmds(pmd_t *pmds[])
29215 +static void free_pxds(pxd_t *pxds[])
29216 {
29217 int i;
29218
29219 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29220 - if (pmds[i])
29221 - free_page((unsigned long)pmds[i]);
29222 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29223 + if (pxds[i])
29224 + free_page((unsigned long)pxds[i]);
29225 }
29226
29227 -static int preallocate_pmds(pmd_t *pmds[])
29228 +static int preallocate_pxds(pxd_t *pxds[])
29229 {
29230 int i;
29231 bool failed = false;
29232
29233 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29234 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29235 - if (pmd == NULL)
29236 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29237 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29238 + if (pxd == NULL)
29239 failed = true;
29240 - pmds[i] = pmd;
29241 + pxds[i] = pxd;
29242 }
29243
29244 if (failed) {
29245 - free_pmds(pmds);
29246 + free_pxds(pxds);
29247 return -ENOMEM;
29248 }
29249
29250 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29251 * preallocate which never got a corresponding vma will need to be
29252 * freed manually.
29253 */
29254 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29255 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29256 {
29257 int i;
29258
29259 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29260 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29261 pgd_t pgd = pgdp[i];
29262
29263 if (pgd_val(pgd) != 0) {
29264 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29265 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29266
29267 - pgdp[i] = native_make_pgd(0);
29268 + set_pgd(pgdp + i, native_make_pgd(0));
29269
29270 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29271 - pmd_free(mm, pmd);
29272 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29273 + pxd_free(mm, pxd);
29274 }
29275 }
29276 }
29277
29278 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29279 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29280 {
29281 - pud_t *pud;
29282 + pyd_t *pyd;
29283 unsigned long addr;
29284 int i;
29285
29286 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29287 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29288 return;
29289
29290 - pud = pud_offset(pgd, 0);
29291 +#ifdef CONFIG_X86_64
29292 + pyd = pyd_offset(mm, 0L);
29293 +#else
29294 + pyd = pyd_offset(pgd, 0L);
29295 +#endif
29296
29297 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29298 - i++, pud++, addr += PUD_SIZE) {
29299 - pmd_t *pmd = pmds[i];
29300 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29301 + i++, pyd++, addr += PYD_SIZE) {
29302 + pxd_t *pxd = pxds[i];
29303
29304 if (i >= KERNEL_PGD_BOUNDARY)
29305 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29306 - sizeof(pmd_t) * PTRS_PER_PMD);
29307 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29308 + sizeof(pxd_t) * PTRS_PER_PMD);
29309
29310 - pud_populate(mm, pud, pmd);
29311 + pyd_populate(mm, pyd, pxd);
29312 }
29313 }
29314
29315 pgd_t *pgd_alloc(struct mm_struct *mm)
29316 {
29317 pgd_t *pgd;
29318 - pmd_t *pmds[PREALLOCATED_PMDS];
29319 + pxd_t *pxds[PREALLOCATED_PXDS];
29320
29321 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29322
29323 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29324
29325 mm->pgd = pgd;
29326
29327 - if (preallocate_pmds(pmds) != 0)
29328 + if (preallocate_pxds(pxds) != 0)
29329 goto out_free_pgd;
29330
29331 if (paravirt_pgd_alloc(mm) != 0)
29332 - goto out_free_pmds;
29333 + goto out_free_pxds;
29334
29335 /*
29336 * Make sure that pre-populating the pmds is atomic with
29337 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29338 spin_lock(&pgd_lock);
29339
29340 pgd_ctor(mm, pgd);
29341 - pgd_prepopulate_pmd(mm, pgd, pmds);
29342 + pgd_prepopulate_pxd(mm, pgd, pxds);
29343
29344 spin_unlock(&pgd_lock);
29345
29346 return pgd;
29347
29348 -out_free_pmds:
29349 - free_pmds(pmds);
29350 +out_free_pxds:
29351 + free_pxds(pxds);
29352 out_free_pgd:
29353 free_page((unsigned long)pgd);
29354 out:
29355 @@ -302,7 +363,7 @@ out:
29356
29357 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29358 {
29359 - pgd_mop_up_pmds(mm, pgd);
29360 + pgd_mop_up_pxds(mm, pgd);
29361 pgd_dtor(pgd);
29362 paravirt_pgd_free(mm, pgd);
29363 free_page((unsigned long)pgd);
29364 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29365 index a69bcb8..19068ab 100644
29366 --- a/arch/x86/mm/pgtable_32.c
29367 +++ b/arch/x86/mm/pgtable_32.c
29368 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29369 return;
29370 }
29371 pte = pte_offset_kernel(pmd, vaddr);
29372 +
29373 + pax_open_kernel();
29374 if (pte_val(pteval))
29375 set_pte_at(&init_mm, vaddr, pte, pteval);
29376 else
29377 pte_clear(&init_mm, vaddr, pte);
29378 + pax_close_kernel();
29379
29380 /*
29381 * It's enough to flush this one mapping.
29382 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29383 index e666cbb..61788c45 100644
29384 --- a/arch/x86/mm/physaddr.c
29385 +++ b/arch/x86/mm/physaddr.c
29386 @@ -10,7 +10,7 @@
29387 #ifdef CONFIG_X86_64
29388
29389 #ifdef CONFIG_DEBUG_VIRTUAL
29390 -unsigned long __phys_addr(unsigned long x)
29391 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29392 {
29393 unsigned long y = x - __START_KERNEL_map;
29394
29395 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29396 #else
29397
29398 #ifdef CONFIG_DEBUG_VIRTUAL
29399 -unsigned long __phys_addr(unsigned long x)
29400 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29401 {
29402 unsigned long phys_addr = x - PAGE_OFFSET;
29403 /* VMALLOC_* aren't constants */
29404 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29405 index 410531d..0f16030 100644
29406 --- a/arch/x86/mm/setup_nx.c
29407 +++ b/arch/x86/mm/setup_nx.c
29408 @@ -5,8 +5,10 @@
29409 #include <asm/pgtable.h>
29410 #include <asm/proto.h>
29411
29412 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29413 static int disable_nx __cpuinitdata;
29414
29415 +#ifndef CONFIG_PAX_PAGEEXEC
29416 /*
29417 * noexec = on|off
29418 *
29419 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29420 return 0;
29421 }
29422 early_param("noexec", noexec_setup);
29423 +#endif
29424 +
29425 +#endif
29426
29427 void __cpuinit x86_configure_nx(void)
29428 {
29429 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29430 if (cpu_has_nx && !disable_nx)
29431 __supported_pte_mask |= _PAGE_NX;
29432 else
29433 +#endif
29434 __supported_pte_mask &= ~_PAGE_NX;
29435 }
29436
29437 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29438 index 282375f..e03a98f 100644
29439 --- a/arch/x86/mm/tlb.c
29440 +++ b/arch/x86/mm/tlb.c
29441 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29442 BUG();
29443 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29444 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29445 +
29446 +#ifndef CONFIG_PAX_PER_CPU_PGD
29447 load_cr3(swapper_pg_dir);
29448 +#endif
29449 +
29450 }
29451 }
29452 EXPORT_SYMBOL_GPL(leave_mm);
29453 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29454 index 877b9a1..a8ecf42 100644
29455 --- a/arch/x86/net/bpf_jit.S
29456 +++ b/arch/x86/net/bpf_jit.S
29457 @@ -9,6 +9,7 @@
29458 */
29459 #include <linux/linkage.h>
29460 #include <asm/dwarf2.h>
29461 +#include <asm/alternative-asm.h>
29462
29463 /*
29464 * Calling convention :
29465 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29466 jle bpf_slow_path_word
29467 mov (SKBDATA,%rsi),%eax
29468 bswap %eax /* ntohl() */
29469 + pax_force_retaddr
29470 ret
29471
29472 sk_load_half:
29473 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29474 jle bpf_slow_path_half
29475 movzwl (SKBDATA,%rsi),%eax
29476 rol $8,%ax # ntohs()
29477 + pax_force_retaddr
29478 ret
29479
29480 sk_load_byte:
29481 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29482 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29483 jle bpf_slow_path_byte
29484 movzbl (SKBDATA,%rsi),%eax
29485 + pax_force_retaddr
29486 ret
29487
29488 /**
29489 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29490 movzbl (SKBDATA,%rsi),%ebx
29491 and $15,%bl
29492 shl $2,%bl
29493 + pax_force_retaddr
29494 ret
29495
29496 /* rsi contains offset and can be scratched */
29497 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29498 js bpf_error
29499 mov -12(%rbp),%eax
29500 bswap %eax
29501 + pax_force_retaddr
29502 ret
29503
29504 bpf_slow_path_half:
29505 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29506 mov -12(%rbp),%ax
29507 rol $8,%ax
29508 movzwl %ax,%eax
29509 + pax_force_retaddr
29510 ret
29511
29512 bpf_slow_path_byte:
29513 bpf_slow_path_common(1)
29514 js bpf_error
29515 movzbl -12(%rbp),%eax
29516 + pax_force_retaddr
29517 ret
29518
29519 bpf_slow_path_byte_msh:
29520 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29521 and $15,%al
29522 shl $2,%al
29523 xchg %eax,%ebx
29524 + pax_force_retaddr
29525 ret
29526
29527 #define sk_negative_common(SIZE) \
29528 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29529 sk_negative_common(4)
29530 mov (%rax), %eax
29531 bswap %eax
29532 + pax_force_retaddr
29533 ret
29534
29535 bpf_slow_path_half_neg:
29536 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29537 mov (%rax),%ax
29538 rol $8,%ax
29539 movzwl %ax,%eax
29540 + pax_force_retaddr
29541 ret
29542
29543 bpf_slow_path_byte_neg:
29544 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29545 .globl sk_load_byte_negative_offset
29546 sk_negative_common(1)
29547 movzbl (%rax), %eax
29548 + pax_force_retaddr
29549 ret
29550
29551 bpf_slow_path_byte_msh_neg:
29552 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29553 and $15,%al
29554 shl $2,%al
29555 xchg %eax,%ebx
29556 + pax_force_retaddr
29557 ret
29558
29559 bpf_error:
29560 @@ -197,4 +210,5 @@ bpf_error:
29561 xor %eax,%eax
29562 mov -8(%rbp),%rbx
29563 leaveq
29564 + pax_force_retaddr
29565 ret
29566 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29567 index 3cbe4538..003d011 100644
29568 --- a/arch/x86/net/bpf_jit_comp.c
29569 +++ b/arch/x86/net/bpf_jit_comp.c
29570 @@ -12,6 +12,7 @@
29571 #include <linux/netdevice.h>
29572 #include <linux/filter.h>
29573 #include <linux/if_vlan.h>
29574 +#include <linux/random.h>
29575
29576 /*
29577 * Conventions :
29578 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29579 return ptr + len;
29580 }
29581
29582 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29583 +#define MAX_INSTR_CODE_SIZE 96
29584 +#else
29585 +#define MAX_INSTR_CODE_SIZE 64
29586 +#endif
29587 +
29588 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29589
29590 #define EMIT1(b1) EMIT(b1, 1)
29591 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29592 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29593 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29594 +
29595 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29596 +/* original constant will appear in ecx */
29597 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29598 +do { \
29599 + /* mov ecx, randkey */ \
29600 + EMIT1(0xb9); \
29601 + EMIT(_key, 4); \
29602 + /* xor ecx, randkey ^ off */ \
29603 + EMIT2(0x81, 0xf1); \
29604 + EMIT((_key) ^ (_off), 4); \
29605 +} while (0)
29606 +
29607 +#define EMIT1_off32(b1, _off) \
29608 +do { \
29609 + switch (b1) { \
29610 + case 0x05: /* add eax, imm32 */ \
29611 + case 0x2d: /* sub eax, imm32 */ \
29612 + case 0x25: /* and eax, imm32 */ \
29613 + case 0x0d: /* or eax, imm32 */ \
29614 + case 0xb8: /* mov eax, imm32 */ \
29615 + case 0x35: /* xor eax, imm32 */ \
29616 + case 0x3d: /* cmp eax, imm32 */ \
29617 + case 0xa9: /* test eax, imm32 */ \
29618 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29619 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29620 + break; \
29621 + case 0xbb: /* mov ebx, imm32 */ \
29622 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29623 + /* mov ebx, ecx */ \
29624 + EMIT2(0x89, 0xcb); \
29625 + break; \
29626 + case 0xbe: /* mov esi, imm32 */ \
29627 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29628 + /* mov esi, ecx */ \
29629 + EMIT2(0x89, 0xce); \
29630 + break; \
29631 + case 0xe8: /* call rel imm32, always to known funcs */ \
29632 + EMIT1(b1); \
29633 + EMIT(_off, 4); \
29634 + break; \
29635 + case 0xe9: /* jmp rel imm32 */ \
29636 + EMIT1(b1); \
29637 + EMIT(_off, 4); \
29638 + /* prevent fall-through, we're not called if off = 0 */ \
29639 + EMIT(0xcccccccc, 4); \
29640 + EMIT(0xcccccccc, 4); \
29641 + break; \
29642 + default: \
29643 + BUILD_BUG(); \
29644 + } \
29645 +} while (0)
29646 +
29647 +#define EMIT2_off32(b1, b2, _off) \
29648 +do { \
29649 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29650 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29651 + EMIT(randkey, 4); \
29652 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29653 + EMIT((_off) - randkey, 4); \
29654 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29655 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29656 + /* imul eax, ecx */ \
29657 + EMIT3(0x0f, 0xaf, 0xc1); \
29658 + } else { \
29659 + BUILD_BUG(); \
29660 + } \
29661 +} while (0)
29662 +#else
29663 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29664 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29665 +#endif
29666
29667 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29668 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29669 @@ -90,6 +168,24 @@ do { \
29670 #define X86_JBE 0x76
29671 #define X86_JA 0x77
29672
29673 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29674 +#define APPEND_FLOW_VERIFY() \
29675 +do { \
29676 + /* mov ecx, randkey */ \
29677 + EMIT1(0xb9); \
29678 + EMIT(randkey, 4); \
29679 + /* cmp ecx, randkey */ \
29680 + EMIT2(0x81, 0xf9); \
29681 + EMIT(randkey, 4); \
29682 + /* jz after 8 int 3s */ \
29683 + EMIT2(0x74, 0x08); \
29684 + EMIT(0xcccccccc, 4); \
29685 + EMIT(0xcccccccc, 4); \
29686 +} while (0)
29687 +#else
29688 +#define APPEND_FLOW_VERIFY() do { } while (0)
29689 +#endif
29690 +
29691 #define EMIT_COND_JMP(op, offset) \
29692 do { \
29693 if (is_near(offset)) \
29694 @@ -97,6 +193,7 @@ do { \
29695 else { \
29696 EMIT2(0x0f, op + 0x10); \
29697 EMIT(offset, 4); /* jxx .+off32 */ \
29698 + APPEND_FLOW_VERIFY(); \
29699 } \
29700 } while (0)
29701
29702 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29703 set_fs(old_fs);
29704 }
29705
29706 +struct bpf_jit_work {
29707 + struct work_struct work;
29708 + void *image;
29709 +};
29710 +
29711 #define CHOOSE_LOAD_FUNC(K, func) \
29712 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29713
29714 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
29715
29716 void bpf_jit_compile(struct sk_filter *fp)
29717 {
29718 - u8 temp[64];
29719 + u8 temp[MAX_INSTR_CODE_SIZE];
29720 u8 *prog;
29721 unsigned int proglen, oldproglen = 0;
29722 int ilen, i;
29723 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29724 unsigned int *addrs;
29725 const struct sock_filter *filter = fp->insns;
29726 int flen = fp->len;
29727 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29728 + unsigned int randkey;
29729 +#endif
29730
29731 if (!bpf_jit_enable)
29732 return;
29733 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29734 if (addrs == NULL)
29735 return;
29736
29737 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29738 + if (!fp->work)
29739 + goto out;
29740 +
29741 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29742 + randkey = get_random_int();
29743 +#endif
29744 +
29745 /* Before first pass, make a rough estimation of addrs[]
29746 - * each bpf instruction is translated to less than 64 bytes
29747 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29748 */
29749 for (proglen = 0, i = 0; i < flen; i++) {
29750 - proglen += 64;
29751 + proglen += MAX_INSTR_CODE_SIZE;
29752 addrs[i] = proglen;
29753 }
29754 cleanup_addr = proglen; /* epilogue address */
29755 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29756 case BPF_S_ALU_MUL_K: /* A *= K */
29757 if (is_imm8(K))
29758 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29759 - else {
29760 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29761 - EMIT(K, 4);
29762 - }
29763 + else
29764 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29765 break;
29766 case BPF_S_ALU_DIV_X: /* A /= X; */
29767 seen |= SEEN_XREG;
29768 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29769 break;
29770 case BPF_S_ALU_MOD_K: /* A %= K; */
29771 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29772 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29773 + DILUTE_CONST_SEQUENCE(K, randkey);
29774 +#else
29775 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29776 +#endif
29777 EMIT2(0xf7, 0xf1); /* div %ecx */
29778 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29779 break;
29780 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29781 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29782 + DILUTE_CONST_SEQUENCE(K, randkey);
29783 + // imul rax, rcx
29784 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29785 +#else
29786 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29787 EMIT(K, 4);
29788 +#endif
29789 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29790 break;
29791 case BPF_S_ALU_AND_X:
29792 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29793 if (is_imm8(K)) {
29794 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29795 } else {
29796 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29797 - EMIT(K, 4);
29798 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29799 }
29800 } else {
29801 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29802 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29803 break;
29804 default:
29805 /* hmm, too complex filter, give up with jit compiler */
29806 - goto out;
29807 + goto error;
29808 }
29809 ilen = prog - temp;
29810 if (image) {
29811 if (unlikely(proglen + ilen > oldproglen)) {
29812 pr_err("bpb_jit_compile fatal error\n");
29813 - kfree(addrs);
29814 - module_free(NULL, image);
29815 - return;
29816 + module_free_exec(NULL, image);
29817 + goto error;
29818 }
29819 + pax_open_kernel();
29820 memcpy(image + proglen, temp, ilen);
29821 + pax_close_kernel();
29822 }
29823 proglen += ilen;
29824 addrs[i] = proglen;
29825 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29826 break;
29827 }
29828 if (proglen == oldproglen) {
29829 - image = module_alloc(max_t(unsigned int,
29830 - proglen,
29831 - sizeof(struct work_struct)));
29832 + image = module_alloc_exec(proglen);
29833 if (!image)
29834 - goto out;
29835 + goto error;
29836 }
29837 oldproglen = proglen;
29838 }
29839 @@ -737,7 +856,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29840 bpf_flush_icache(image, image + proglen);
29841
29842 fp->bpf_func = (void *)image;
29843 - }
29844 + } else
29845 +error:
29846 + kfree(fp->work);
29847 +
29848 out:
29849 kfree(addrs);
29850 return;
29851 @@ -745,18 +867,20 @@ out:
29852
29853 static void jit_free_defer(struct work_struct *arg)
29854 {
29855 - module_free(NULL, arg);
29856 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29857 + kfree(arg);
29858 }
29859
29860 /* run from softirq, we must use a work_struct to call
29861 - * module_free() from process context
29862 + * module_free_exec() from process context
29863 */
29864 void bpf_jit_free(struct sk_filter *fp)
29865 {
29866 if (fp->bpf_func != sk_run_filter) {
29867 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29868 + struct work_struct *work = &fp->work->work;
29869
29870 INIT_WORK(work, jit_free_defer);
29871 + fp->work->image = fp->bpf_func;
29872 schedule_work(work);
29873 }
29874 }
29875 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29876 index d6aa6e8..266395a 100644
29877 --- a/arch/x86/oprofile/backtrace.c
29878 +++ b/arch/x86/oprofile/backtrace.c
29879 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29880 struct stack_frame_ia32 *fp;
29881 unsigned long bytes;
29882
29883 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29884 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29885 if (bytes != sizeof(bufhead))
29886 return NULL;
29887
29888 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29889 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29890
29891 oprofile_add_trace(bufhead[0].return_address);
29892
29893 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29894 struct stack_frame bufhead[2];
29895 unsigned long bytes;
29896
29897 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29898 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29899 if (bytes != sizeof(bufhead))
29900 return NULL;
29901
29902 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29903 {
29904 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29905
29906 - if (!user_mode_vm(regs)) {
29907 + if (!user_mode(regs)) {
29908 unsigned long stack = kernel_stack_pointer(regs);
29909 if (depth)
29910 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29911 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29912 index 48768df..ba9143c 100644
29913 --- a/arch/x86/oprofile/nmi_int.c
29914 +++ b/arch/x86/oprofile/nmi_int.c
29915 @@ -23,6 +23,7 @@
29916 #include <asm/nmi.h>
29917 #include <asm/msr.h>
29918 #include <asm/apic.h>
29919 +#include <asm/pgtable.h>
29920
29921 #include "op_counter.h"
29922 #include "op_x86_model.h"
29923 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29924 if (ret)
29925 return ret;
29926
29927 - if (!model->num_virt_counters)
29928 - model->num_virt_counters = model->num_counters;
29929 + if (!model->num_virt_counters) {
29930 + pax_open_kernel();
29931 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29932 + pax_close_kernel();
29933 + }
29934
29935 mux_init(ops);
29936
29937 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29938 index b2b9443..be58856 100644
29939 --- a/arch/x86/oprofile/op_model_amd.c
29940 +++ b/arch/x86/oprofile/op_model_amd.c
29941 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29942 num_counters = AMD64_NUM_COUNTERS;
29943 }
29944
29945 - op_amd_spec.num_counters = num_counters;
29946 - op_amd_spec.num_controls = num_counters;
29947 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29948 + pax_open_kernel();
29949 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29950 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29951 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29952 + pax_close_kernel();
29953
29954 return 0;
29955 }
29956 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29957 index d90528e..0127e2b 100644
29958 --- a/arch/x86/oprofile/op_model_ppro.c
29959 +++ b/arch/x86/oprofile/op_model_ppro.c
29960 @@ -19,6 +19,7 @@
29961 #include <asm/msr.h>
29962 #include <asm/apic.h>
29963 #include <asm/nmi.h>
29964 +#include <asm/pgtable.h>
29965
29966 #include "op_x86_model.h"
29967 #include "op_counter.h"
29968 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
29969
29970 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
29971
29972 - op_arch_perfmon_spec.num_counters = num_counters;
29973 - op_arch_perfmon_spec.num_controls = num_counters;
29974 + pax_open_kernel();
29975 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
29976 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
29977 + pax_close_kernel();
29978 }
29979
29980 static int arch_perfmon_init(struct oprofile_operations *ignore)
29981 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
29982 index 71e8a67..6a313bb 100644
29983 --- a/arch/x86/oprofile/op_x86_model.h
29984 +++ b/arch/x86/oprofile/op_x86_model.h
29985 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
29986 void (*switch_ctrl)(struct op_x86_model_spec const *model,
29987 struct op_msrs const * const msrs);
29988 #endif
29989 -};
29990 +} __do_const;
29991
29992 struct op_counter_config;
29993
29994 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
29995 index e9e6ed5..e47ae67 100644
29996 --- a/arch/x86/pci/amd_bus.c
29997 +++ b/arch/x86/pci/amd_bus.c
29998 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
29999 return NOTIFY_OK;
30000 }
30001
30002 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30003 +static struct notifier_block amd_cpu_notifier = {
30004 .notifier_call = amd_cpu_notify,
30005 };
30006
30007 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30008 index 372e9b8..e775a6c 100644
30009 --- a/arch/x86/pci/irq.c
30010 +++ b/arch/x86/pci/irq.c
30011 @@ -50,7 +50,7 @@ struct irq_router {
30012 struct irq_router_handler {
30013 u16 vendor;
30014 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30015 -};
30016 +} __do_const;
30017
30018 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30019 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30020 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30021 return 0;
30022 }
30023
30024 -static __initdata struct irq_router_handler pirq_routers[] = {
30025 +static __initconst const struct irq_router_handler pirq_routers[] = {
30026 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30027 { PCI_VENDOR_ID_AL, ali_router_probe },
30028 { PCI_VENDOR_ID_ITE, ite_router_probe },
30029 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30030 static void __init pirq_find_router(struct irq_router *r)
30031 {
30032 struct irq_routing_table *rt = pirq_table;
30033 - struct irq_router_handler *h;
30034 + const struct irq_router_handler *h;
30035
30036 #ifdef CONFIG_PCI_BIOS
30037 if (!rt->signature) {
30038 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30039 return 0;
30040 }
30041
30042 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30043 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30044 {
30045 .callback = fix_broken_hp_bios_irq9,
30046 .ident = "HP Pavilion N5400 Series Laptop",
30047 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30048 index 6eb18c4..20d83de 100644
30049 --- a/arch/x86/pci/mrst.c
30050 +++ b/arch/x86/pci/mrst.c
30051 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30052 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30053 pci_mmcfg_late_init();
30054 pcibios_enable_irq = mrst_pci_irq_enable;
30055 - pci_root_ops = pci_mrst_ops;
30056 + pax_open_kernel();
30057 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30058 + pax_close_kernel();
30059 pci_soc_mode = 1;
30060 /* Continue with standard init */
30061 return 1;
30062 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30063 index c77b24a..c979855 100644
30064 --- a/arch/x86/pci/pcbios.c
30065 +++ b/arch/x86/pci/pcbios.c
30066 @@ -79,7 +79,7 @@ union bios32 {
30067 static struct {
30068 unsigned long address;
30069 unsigned short segment;
30070 -} bios32_indirect = { 0, __KERNEL_CS };
30071 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30072
30073 /*
30074 * Returns the entry point for the given service, NULL on error
30075 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30076 unsigned long length; /* %ecx */
30077 unsigned long entry; /* %edx */
30078 unsigned long flags;
30079 + struct desc_struct d, *gdt;
30080
30081 local_irq_save(flags);
30082 - __asm__("lcall *(%%edi); cld"
30083 +
30084 + gdt = get_cpu_gdt_table(smp_processor_id());
30085 +
30086 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30087 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30088 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30089 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30090 +
30091 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30092 : "=a" (return_code),
30093 "=b" (address),
30094 "=c" (length),
30095 "=d" (entry)
30096 : "0" (service),
30097 "1" (0),
30098 - "D" (&bios32_indirect));
30099 + "D" (&bios32_indirect),
30100 + "r"(__PCIBIOS_DS)
30101 + : "memory");
30102 +
30103 + pax_open_kernel();
30104 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30105 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30106 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30107 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30108 + pax_close_kernel();
30109 +
30110 local_irq_restore(flags);
30111
30112 switch (return_code) {
30113 - case 0:
30114 - return address + entry;
30115 - case 0x80: /* Not present */
30116 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30117 - return 0;
30118 - default: /* Shouldn't happen */
30119 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30120 - service, return_code);
30121 + case 0: {
30122 + int cpu;
30123 + unsigned char flags;
30124 +
30125 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30126 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30127 + printk(KERN_WARNING "bios32_service: not valid\n");
30128 return 0;
30129 + }
30130 + address = address + PAGE_OFFSET;
30131 + length += 16UL; /* some BIOSs underreport this... */
30132 + flags = 4;
30133 + if (length >= 64*1024*1024) {
30134 + length >>= PAGE_SHIFT;
30135 + flags |= 8;
30136 + }
30137 +
30138 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30139 + gdt = get_cpu_gdt_table(cpu);
30140 + pack_descriptor(&d, address, length, 0x9b, flags);
30141 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30142 + pack_descriptor(&d, address, length, 0x93, flags);
30143 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30144 + }
30145 + return entry;
30146 + }
30147 + case 0x80: /* Not present */
30148 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30149 + return 0;
30150 + default: /* Shouldn't happen */
30151 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30152 + service, return_code);
30153 + return 0;
30154 }
30155 }
30156
30157 static struct {
30158 unsigned long address;
30159 unsigned short segment;
30160 -} pci_indirect = { 0, __KERNEL_CS };
30161 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30162
30163 -static int pci_bios_present;
30164 +static int pci_bios_present __read_only;
30165
30166 static int check_pcibios(void)
30167 {
30168 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30169 unsigned long flags, pcibios_entry;
30170
30171 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30172 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30173 + pci_indirect.address = pcibios_entry;
30174
30175 local_irq_save(flags);
30176 - __asm__(
30177 - "lcall *(%%edi); cld\n\t"
30178 + __asm__("movw %w6, %%ds\n\t"
30179 + "lcall *%%ss:(%%edi); cld\n\t"
30180 + "push %%ss\n\t"
30181 + "pop %%ds\n\t"
30182 "jc 1f\n\t"
30183 "xor %%ah, %%ah\n"
30184 "1:"
30185 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30186 "=b" (ebx),
30187 "=c" (ecx)
30188 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30189 - "D" (&pci_indirect)
30190 + "D" (&pci_indirect),
30191 + "r" (__PCIBIOS_DS)
30192 : "memory");
30193 local_irq_restore(flags);
30194
30195 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30196
30197 switch (len) {
30198 case 1:
30199 - __asm__("lcall *(%%esi); cld\n\t"
30200 + __asm__("movw %w6, %%ds\n\t"
30201 + "lcall *%%ss:(%%esi); cld\n\t"
30202 + "push %%ss\n\t"
30203 + "pop %%ds\n\t"
30204 "jc 1f\n\t"
30205 "xor %%ah, %%ah\n"
30206 "1:"
30207 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30208 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30209 "b" (bx),
30210 "D" ((long)reg),
30211 - "S" (&pci_indirect));
30212 + "S" (&pci_indirect),
30213 + "r" (__PCIBIOS_DS));
30214 /*
30215 * Zero-extend the result beyond 8 bits, do not trust the
30216 * BIOS having done it:
30217 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30218 *value &= 0xff;
30219 break;
30220 case 2:
30221 - __asm__("lcall *(%%esi); cld\n\t"
30222 + __asm__("movw %w6, %%ds\n\t"
30223 + "lcall *%%ss:(%%esi); cld\n\t"
30224 + "push %%ss\n\t"
30225 + "pop %%ds\n\t"
30226 "jc 1f\n\t"
30227 "xor %%ah, %%ah\n"
30228 "1:"
30229 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30230 : "1" (PCIBIOS_READ_CONFIG_WORD),
30231 "b" (bx),
30232 "D" ((long)reg),
30233 - "S" (&pci_indirect));
30234 + "S" (&pci_indirect),
30235 + "r" (__PCIBIOS_DS));
30236 /*
30237 * Zero-extend the result beyond 16 bits, do not trust the
30238 * BIOS having done it:
30239 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30240 *value &= 0xffff;
30241 break;
30242 case 4:
30243 - __asm__("lcall *(%%esi); cld\n\t"
30244 + __asm__("movw %w6, %%ds\n\t"
30245 + "lcall *%%ss:(%%esi); cld\n\t"
30246 + "push %%ss\n\t"
30247 + "pop %%ds\n\t"
30248 "jc 1f\n\t"
30249 "xor %%ah, %%ah\n"
30250 "1:"
30251 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30252 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30253 "b" (bx),
30254 "D" ((long)reg),
30255 - "S" (&pci_indirect));
30256 + "S" (&pci_indirect),
30257 + "r" (__PCIBIOS_DS));
30258 break;
30259 }
30260
30261 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30262
30263 switch (len) {
30264 case 1:
30265 - __asm__("lcall *(%%esi); cld\n\t"
30266 + __asm__("movw %w6, %%ds\n\t"
30267 + "lcall *%%ss:(%%esi); cld\n\t"
30268 + "push %%ss\n\t"
30269 + "pop %%ds\n\t"
30270 "jc 1f\n\t"
30271 "xor %%ah, %%ah\n"
30272 "1:"
30273 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30274 "c" (value),
30275 "b" (bx),
30276 "D" ((long)reg),
30277 - "S" (&pci_indirect));
30278 + "S" (&pci_indirect),
30279 + "r" (__PCIBIOS_DS));
30280 break;
30281 case 2:
30282 - __asm__("lcall *(%%esi); cld\n\t"
30283 + __asm__("movw %w6, %%ds\n\t"
30284 + "lcall *%%ss:(%%esi); cld\n\t"
30285 + "push %%ss\n\t"
30286 + "pop %%ds\n\t"
30287 "jc 1f\n\t"
30288 "xor %%ah, %%ah\n"
30289 "1:"
30290 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30291 "c" (value),
30292 "b" (bx),
30293 "D" ((long)reg),
30294 - "S" (&pci_indirect));
30295 + "S" (&pci_indirect),
30296 + "r" (__PCIBIOS_DS));
30297 break;
30298 case 4:
30299 - __asm__("lcall *(%%esi); cld\n\t"
30300 + __asm__("movw %w6, %%ds\n\t"
30301 + "lcall *%%ss:(%%esi); cld\n\t"
30302 + "push %%ss\n\t"
30303 + "pop %%ds\n\t"
30304 "jc 1f\n\t"
30305 "xor %%ah, %%ah\n"
30306 "1:"
30307 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30308 "c" (value),
30309 "b" (bx),
30310 "D" ((long)reg),
30311 - "S" (&pci_indirect));
30312 + "S" (&pci_indirect),
30313 + "r" (__PCIBIOS_DS));
30314 break;
30315 }
30316
30317 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30318
30319 DBG("PCI: Fetching IRQ routing table... ");
30320 __asm__("push %%es\n\t"
30321 + "movw %w8, %%ds\n\t"
30322 "push %%ds\n\t"
30323 "pop %%es\n\t"
30324 - "lcall *(%%esi); cld\n\t"
30325 + "lcall *%%ss:(%%esi); cld\n\t"
30326 "pop %%es\n\t"
30327 + "push %%ss\n\t"
30328 + "pop %%ds\n"
30329 "jc 1f\n\t"
30330 "xor %%ah, %%ah\n"
30331 "1:"
30332 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30333 "1" (0),
30334 "D" ((long) &opt),
30335 "S" (&pci_indirect),
30336 - "m" (opt)
30337 + "m" (opt),
30338 + "r" (__PCIBIOS_DS)
30339 : "memory");
30340 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30341 if (ret & 0xff00)
30342 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30343 {
30344 int ret;
30345
30346 - __asm__("lcall *(%%esi); cld\n\t"
30347 + __asm__("movw %w5, %%ds\n\t"
30348 + "lcall *%%ss:(%%esi); cld\n\t"
30349 + "push %%ss\n\t"
30350 + "pop %%ds\n"
30351 "jc 1f\n\t"
30352 "xor %%ah, %%ah\n"
30353 "1:"
30354 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30355 : "0" (PCIBIOS_SET_PCI_HW_INT),
30356 "b" ((dev->bus->number << 8) | dev->devfn),
30357 "c" ((irq << 8) | (pin + 10)),
30358 - "S" (&pci_indirect));
30359 + "S" (&pci_indirect),
30360 + "r" (__PCIBIOS_DS));
30361 return !(ret & 0xff00);
30362 }
30363 EXPORT_SYMBOL(pcibios_set_irq_routing);
30364 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30365 index 40e4469..1ab536e 100644
30366 --- a/arch/x86/platform/efi/efi_32.c
30367 +++ b/arch/x86/platform/efi/efi_32.c
30368 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30369 {
30370 struct desc_ptr gdt_descr;
30371
30372 +#ifdef CONFIG_PAX_KERNEXEC
30373 + struct desc_struct d;
30374 +#endif
30375 +
30376 local_irq_save(efi_rt_eflags);
30377
30378 load_cr3(initial_page_table);
30379 __flush_tlb_all();
30380
30381 +#ifdef CONFIG_PAX_KERNEXEC
30382 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30383 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30384 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30385 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30386 +#endif
30387 +
30388 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30389 gdt_descr.size = GDT_SIZE - 1;
30390 load_gdt(&gdt_descr);
30391 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30392 {
30393 struct desc_ptr gdt_descr;
30394
30395 +#ifdef CONFIG_PAX_KERNEXEC
30396 + struct desc_struct d;
30397 +
30398 + memset(&d, 0, sizeof d);
30399 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30400 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30401 +#endif
30402 +
30403 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30404 gdt_descr.size = GDT_SIZE - 1;
30405 load_gdt(&gdt_descr);
30406 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30407 index fbe66e6..eae5e38 100644
30408 --- a/arch/x86/platform/efi/efi_stub_32.S
30409 +++ b/arch/x86/platform/efi/efi_stub_32.S
30410 @@ -6,7 +6,9 @@
30411 */
30412
30413 #include <linux/linkage.h>
30414 +#include <linux/init.h>
30415 #include <asm/page_types.h>
30416 +#include <asm/segment.h>
30417
30418 /*
30419 * efi_call_phys(void *, ...) is a function with variable parameters.
30420 @@ -20,7 +22,7 @@
30421 * service functions will comply with gcc calling convention, too.
30422 */
30423
30424 -.text
30425 +__INIT
30426 ENTRY(efi_call_phys)
30427 /*
30428 * 0. The function can only be called in Linux kernel. So CS has been
30429 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30430 * The mapping of lower virtual memory has been created in prelog and
30431 * epilog.
30432 */
30433 - movl $1f, %edx
30434 - subl $__PAGE_OFFSET, %edx
30435 - jmp *%edx
30436 +#ifdef CONFIG_PAX_KERNEXEC
30437 + movl $(__KERNEXEC_EFI_DS), %edx
30438 + mov %edx, %ds
30439 + mov %edx, %es
30440 + mov %edx, %ss
30441 + addl $2f,(1f)
30442 + ljmp *(1f)
30443 +
30444 +__INITDATA
30445 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30446 +.previous
30447 +
30448 +2:
30449 + subl $2b,(1b)
30450 +#else
30451 + jmp 1f-__PAGE_OFFSET
30452 1:
30453 +#endif
30454
30455 /*
30456 * 2. Now on the top of stack is the return
30457 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30458 * parameter 2, ..., param n. To make things easy, we save the return
30459 * address of efi_call_phys in a global variable.
30460 */
30461 - popl %edx
30462 - movl %edx, saved_return_addr
30463 - /* get the function pointer into ECX*/
30464 - popl %ecx
30465 - movl %ecx, efi_rt_function_ptr
30466 - movl $2f, %edx
30467 - subl $__PAGE_OFFSET, %edx
30468 - pushl %edx
30469 + popl (saved_return_addr)
30470 + popl (efi_rt_function_ptr)
30471
30472 /*
30473 * 3. Clear PG bit in %CR0.
30474 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30475 /*
30476 * 5. Call the physical function.
30477 */
30478 - jmp *%ecx
30479 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30480
30481 -2:
30482 /*
30483 * 6. After EFI runtime service returns, control will return to
30484 * following instruction. We'd better readjust stack pointer first.
30485 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30486 movl %cr0, %edx
30487 orl $0x80000000, %edx
30488 movl %edx, %cr0
30489 - jmp 1f
30490 -1:
30491 +
30492 /*
30493 * 8. Now restore the virtual mode from flat mode by
30494 * adding EIP with PAGE_OFFSET.
30495 */
30496 - movl $1f, %edx
30497 - jmp *%edx
30498 +#ifdef CONFIG_PAX_KERNEXEC
30499 + movl $(__KERNEL_DS), %edx
30500 + mov %edx, %ds
30501 + mov %edx, %es
30502 + mov %edx, %ss
30503 + ljmp $(__KERNEL_CS),$1f
30504 +#else
30505 + jmp 1f+__PAGE_OFFSET
30506 +#endif
30507 1:
30508
30509 /*
30510 * 9. Balance the stack. And because EAX contain the return value,
30511 * we'd better not clobber it.
30512 */
30513 - leal efi_rt_function_ptr, %edx
30514 - movl (%edx), %ecx
30515 - pushl %ecx
30516 + pushl (efi_rt_function_ptr)
30517
30518 /*
30519 - * 10. Push the saved return address onto the stack and return.
30520 + * 10. Return to the saved return address.
30521 */
30522 - leal saved_return_addr, %edx
30523 - movl (%edx), %ecx
30524 - pushl %ecx
30525 - ret
30526 + jmpl *(saved_return_addr)
30527 ENDPROC(efi_call_phys)
30528 .previous
30529
30530 -.data
30531 +__INITDATA
30532 saved_return_addr:
30533 .long 0
30534 efi_rt_function_ptr:
30535 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30536 index 4c07cca..2c8427d 100644
30537 --- a/arch/x86/platform/efi/efi_stub_64.S
30538 +++ b/arch/x86/platform/efi/efi_stub_64.S
30539 @@ -7,6 +7,7 @@
30540 */
30541
30542 #include <linux/linkage.h>
30543 +#include <asm/alternative-asm.h>
30544
30545 #define SAVE_XMM \
30546 mov %rsp, %rax; \
30547 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30548 call *%rdi
30549 addq $32, %rsp
30550 RESTORE_XMM
30551 + pax_force_retaddr 0, 1
30552 ret
30553 ENDPROC(efi_call0)
30554
30555 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30556 call *%rdi
30557 addq $32, %rsp
30558 RESTORE_XMM
30559 + pax_force_retaddr 0, 1
30560 ret
30561 ENDPROC(efi_call1)
30562
30563 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30564 call *%rdi
30565 addq $32, %rsp
30566 RESTORE_XMM
30567 + pax_force_retaddr 0, 1
30568 ret
30569 ENDPROC(efi_call2)
30570
30571 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30572 call *%rdi
30573 addq $32, %rsp
30574 RESTORE_XMM
30575 + pax_force_retaddr 0, 1
30576 ret
30577 ENDPROC(efi_call3)
30578
30579 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30580 call *%rdi
30581 addq $32, %rsp
30582 RESTORE_XMM
30583 + pax_force_retaddr 0, 1
30584 ret
30585 ENDPROC(efi_call4)
30586
30587 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30588 call *%rdi
30589 addq $48, %rsp
30590 RESTORE_XMM
30591 + pax_force_retaddr 0, 1
30592 ret
30593 ENDPROC(efi_call5)
30594
30595 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30596 call *%rdi
30597 addq $48, %rsp
30598 RESTORE_XMM
30599 + pax_force_retaddr 0, 1
30600 ret
30601 ENDPROC(efi_call6)
30602 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30603 index e31bcd8..f12dc46 100644
30604 --- a/arch/x86/platform/mrst/mrst.c
30605 +++ b/arch/x86/platform/mrst/mrst.c
30606 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30607 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30608 int sfi_mrtc_num;
30609
30610 -static void mrst_power_off(void)
30611 +static __noreturn void mrst_power_off(void)
30612 {
30613 + BUG();
30614 }
30615
30616 -static void mrst_reboot(void)
30617 +static __noreturn void mrst_reboot(void)
30618 {
30619 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30620 + BUG();
30621 }
30622
30623 /* parse all the mtimer info to a static mtimer array */
30624 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30625 index d6ee929..3637cb5 100644
30626 --- a/arch/x86/platform/olpc/olpc_dt.c
30627 +++ b/arch/x86/platform/olpc/olpc_dt.c
30628 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30629 return res;
30630 }
30631
30632 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30633 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30634 .nextprop = olpc_dt_nextprop,
30635 .getproplen = olpc_dt_getproplen,
30636 .getproperty = olpc_dt_getproperty,
30637 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30638 index 3c68768..07e82b8 100644
30639 --- a/arch/x86/power/cpu.c
30640 +++ b/arch/x86/power/cpu.c
30641 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30642 static void fix_processor_context(void)
30643 {
30644 int cpu = smp_processor_id();
30645 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30646 + struct tss_struct *t = init_tss + cpu;
30647
30648 set_tss_desc(cpu, t); /*
30649 * This just modifies memory; should not be
30650 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30651 */
30652
30653 #ifdef CONFIG_X86_64
30654 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30655 -
30656 syscall_init(); /* This sets MSR_*STAR and related */
30657 #endif
30658 load_TR_desc(); /* This does ltr */
30659 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30660 index a44f457..9140171 100644
30661 --- a/arch/x86/realmode/init.c
30662 +++ b/arch/x86/realmode/init.c
30663 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30664 __va(real_mode_header->trampoline_header);
30665
30666 #ifdef CONFIG_X86_32
30667 - trampoline_header->start = __pa_symbol(startup_32_smp);
30668 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30669 +
30670 +#ifdef CONFIG_PAX_KERNEXEC
30671 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30672 +#endif
30673 +
30674 + trampoline_header->boot_cs = __BOOT_CS;
30675 trampoline_header->gdt_limit = __BOOT_DS + 7;
30676 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30677 #else
30678 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30679 *trampoline_cr4_features = read_cr4();
30680
30681 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30682 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30683 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30684 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30685 #endif
30686 }
30687 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30688 index 8869287..d577672 100644
30689 --- a/arch/x86/realmode/rm/Makefile
30690 +++ b/arch/x86/realmode/rm/Makefile
30691 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30692 $(call cc-option, -fno-unit-at-a-time)) \
30693 $(call cc-option, -fno-stack-protector) \
30694 $(call cc-option, -mpreferred-stack-boundary=2)
30695 +ifdef CONSTIFY_PLUGIN
30696 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30697 +endif
30698 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30699 GCOV_PROFILE := n
30700 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30701 index a28221d..93c40f1 100644
30702 --- a/arch/x86/realmode/rm/header.S
30703 +++ b/arch/x86/realmode/rm/header.S
30704 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30705 #endif
30706 /* APM/BIOS reboot */
30707 .long pa_machine_real_restart_asm
30708 -#ifdef CONFIG_X86_64
30709 +#ifdef CONFIG_X86_32
30710 + .long __KERNEL_CS
30711 +#else
30712 .long __KERNEL32_CS
30713 #endif
30714 END(real_mode_header)
30715 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30716 index c1b2791..f9e31c7 100644
30717 --- a/arch/x86/realmode/rm/trampoline_32.S
30718 +++ b/arch/x86/realmode/rm/trampoline_32.S
30719 @@ -25,6 +25,12 @@
30720 #include <asm/page_types.h>
30721 #include "realmode.h"
30722
30723 +#ifdef CONFIG_PAX_KERNEXEC
30724 +#define ta(X) (X)
30725 +#else
30726 +#define ta(X) (pa_ ## X)
30727 +#endif
30728 +
30729 .text
30730 .code16
30731
30732 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30733
30734 cli # We should be safe anyway
30735
30736 - movl tr_start, %eax # where we need to go
30737 -
30738 movl $0xA5A5A5A5, trampoline_status
30739 # write marker for master knows we're running
30740
30741 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30742 movw $1, %dx # protected mode (PE) bit
30743 lmsw %dx # into protected mode
30744
30745 - ljmpl $__BOOT_CS, $pa_startup_32
30746 + ljmpl *(trampoline_header)
30747
30748 .section ".text32","ax"
30749 .code32
30750 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30751 .balign 8
30752 GLOBAL(trampoline_header)
30753 tr_start: .space 4
30754 - tr_gdt_pad: .space 2
30755 + tr_boot_cs: .space 2
30756 tr_gdt: .space 6
30757 END(trampoline_header)
30758
30759 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30760 index bb360dc..3e5945f 100644
30761 --- a/arch/x86/realmode/rm/trampoline_64.S
30762 +++ b/arch/x86/realmode/rm/trampoline_64.S
30763 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30764 wrmsr
30765
30766 # Enable paging and in turn activate Long Mode
30767 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30768 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30769 movl %eax, %cr0
30770
30771 /*
30772 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30773 index 79d67bd..c7e1b90 100644
30774 --- a/arch/x86/tools/relocs.c
30775 +++ b/arch/x86/tools/relocs.c
30776 @@ -12,10 +12,13 @@
30777 #include <regex.h>
30778 #include <tools/le_byteshift.h>
30779
30780 +#include "../../../include/generated/autoconf.h"
30781 +
30782 static void die(char *fmt, ...);
30783
30784 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
30785 static Elf32_Ehdr ehdr;
30786 +static Elf32_Phdr *phdr;
30787 static unsigned long reloc_count, reloc_idx;
30788 static unsigned long *relocs;
30789 static unsigned long reloc16_count, reloc16_idx;
30790 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
30791 }
30792 }
30793
30794 +static void read_phdrs(FILE *fp)
30795 +{
30796 + unsigned int i;
30797 +
30798 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
30799 + if (!phdr) {
30800 + die("Unable to allocate %d program headers\n",
30801 + ehdr.e_phnum);
30802 + }
30803 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30804 + die("Seek to %d failed: %s\n",
30805 + ehdr.e_phoff, strerror(errno));
30806 + }
30807 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30808 + die("Cannot read ELF program headers: %s\n",
30809 + strerror(errno));
30810 + }
30811 + for(i = 0; i < ehdr.e_phnum; i++) {
30812 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
30813 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
30814 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
30815 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
30816 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
30817 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
30818 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
30819 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
30820 + }
30821 +
30822 +}
30823 +
30824 static void read_shdrs(FILE *fp)
30825 {
30826 - int i;
30827 + unsigned int i;
30828 Elf32_Shdr shdr;
30829
30830 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30831 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
30832
30833 static void read_strtabs(FILE *fp)
30834 {
30835 - int i;
30836 + unsigned int i;
30837 for (i = 0; i < ehdr.e_shnum; i++) {
30838 struct section *sec = &secs[i];
30839 if (sec->shdr.sh_type != SHT_STRTAB) {
30840 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
30841
30842 static void read_symtabs(FILE *fp)
30843 {
30844 - int i,j;
30845 + unsigned int i,j;
30846 for (i = 0; i < ehdr.e_shnum; i++) {
30847 struct section *sec = &secs[i];
30848 if (sec->shdr.sh_type != SHT_SYMTAB) {
30849 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
30850 }
30851
30852
30853 -static void read_relocs(FILE *fp)
30854 +static void read_relocs(FILE *fp, int use_real_mode)
30855 {
30856 - int i,j;
30857 + unsigned int i,j;
30858 + uint32_t base;
30859 +
30860 for (i = 0; i < ehdr.e_shnum; i++) {
30861 struct section *sec = &secs[i];
30862 if (sec->shdr.sh_type != SHT_REL) {
30863 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
30864 die("Cannot read symbol table: %s\n",
30865 strerror(errno));
30866 }
30867 + base = 0;
30868 +
30869 +#ifdef CONFIG_X86_32
30870 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30871 + if (phdr[j].p_type != PT_LOAD )
30872 + continue;
30873 + if (secs[sec->shdr.sh_info].shdr.sh_offset < phdr[j].p_offset || secs[sec->shdr.sh_info].shdr.sh_offset >= phdr[j].p_offset + phdr[j].p_filesz)
30874 + continue;
30875 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30876 + break;
30877 + }
30878 +#endif
30879 +
30880 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
30881 Elf32_Rel *rel = &sec->reltab[j];
30882 - rel->r_offset = elf32_to_cpu(rel->r_offset);
30883 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
30884 rel->r_info = elf32_to_cpu(rel->r_info);
30885 }
30886 }
30887 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
30888
30889 static void print_absolute_symbols(void)
30890 {
30891 - int i;
30892 + unsigned int i;
30893 printf("Absolute symbols\n");
30894 printf(" Num: Value Size Type Bind Visibility Name\n");
30895 for (i = 0; i < ehdr.e_shnum; i++) {
30896 struct section *sec = &secs[i];
30897 char *sym_strtab;
30898 - int j;
30899 + unsigned int j;
30900
30901 if (sec->shdr.sh_type != SHT_SYMTAB) {
30902 continue;
30903 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
30904
30905 static void print_absolute_relocs(void)
30906 {
30907 - int i, printed = 0;
30908 + unsigned int i, printed = 0;
30909
30910 for (i = 0; i < ehdr.e_shnum; i++) {
30911 struct section *sec = &secs[i];
30912 struct section *sec_applies, *sec_symtab;
30913 char *sym_strtab;
30914 Elf32_Sym *sh_symtab;
30915 - int j;
30916 + unsigned int j;
30917 if (sec->shdr.sh_type != SHT_REL) {
30918 continue;
30919 }
30920 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
30921 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30922 int use_real_mode)
30923 {
30924 - int i;
30925 + unsigned int i;
30926 /* Walk through the relocations */
30927 for (i = 0; i < ehdr.e_shnum; i++) {
30928 char *sym_strtab;
30929 Elf32_Sym *sh_symtab;
30930 struct section *sec_applies, *sec_symtab;
30931 - int j;
30932 + unsigned int j;
30933 struct section *sec = &secs[i];
30934
30935 if (sec->shdr.sh_type != SHT_REL) {
30936 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30937 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
30938 r_type = ELF32_R_TYPE(rel->r_info);
30939
30940 + if (!use_real_mode) {
30941 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
30942 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
30943 + continue;
30944 +
30945 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
30946 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
30947 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
30948 + continue;
30949 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
30950 + continue;
30951 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
30952 + continue;
30953 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
30954 + continue;
30955 +#endif
30956 + }
30957 +
30958 shn_abs = sym->st_shndx == SHN_ABS;
30959
30960 switch (r_type) {
30961 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
30962
30963 static void emit_relocs(int as_text, int use_real_mode)
30964 {
30965 - int i;
30966 + unsigned int i;
30967 /* Count how many relocations I have and allocate space for them. */
30968 reloc_count = 0;
30969 walk_relocs(count_reloc, use_real_mode);
30970 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
30971 fname, strerror(errno));
30972 }
30973 read_ehdr(fp);
30974 + read_phdrs(fp);
30975 read_shdrs(fp);
30976 read_strtabs(fp);
30977 read_symtabs(fp);
30978 - read_relocs(fp);
30979 + read_relocs(fp, use_real_mode);
30980 if (show_absolute_syms) {
30981 print_absolute_symbols();
30982 goto out;
30983 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
30984 index fd14be1..e3c79c0 100644
30985 --- a/arch/x86/vdso/Makefile
30986 +++ b/arch/x86/vdso/Makefile
30987 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
30988 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
30989 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
30990
30991 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30992 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30993 GCOV_PROFILE := n
30994
30995 #
30996 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
30997 index 0faad64..39ef157 100644
30998 --- a/arch/x86/vdso/vdso32-setup.c
30999 +++ b/arch/x86/vdso/vdso32-setup.c
31000 @@ -25,6 +25,7 @@
31001 #include <asm/tlbflush.h>
31002 #include <asm/vdso.h>
31003 #include <asm/proto.h>
31004 +#include <asm/mman.h>
31005
31006 enum {
31007 VDSO_DISABLED = 0,
31008 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31009 void enable_sep_cpu(void)
31010 {
31011 int cpu = get_cpu();
31012 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31013 + struct tss_struct *tss = init_tss + cpu;
31014
31015 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31016 put_cpu();
31017 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31018 gate_vma.vm_start = FIXADDR_USER_START;
31019 gate_vma.vm_end = FIXADDR_USER_END;
31020 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31021 - gate_vma.vm_page_prot = __P101;
31022 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31023
31024 return 0;
31025 }
31026 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31027 if (compat)
31028 addr = VDSO_HIGH_BASE;
31029 else {
31030 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31031 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31032 if (IS_ERR_VALUE(addr)) {
31033 ret = addr;
31034 goto up_fail;
31035 }
31036 }
31037
31038 - current->mm->context.vdso = (void *)addr;
31039 + current->mm->context.vdso = addr;
31040
31041 if (compat_uses_vma || !compat) {
31042 /*
31043 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31044 }
31045
31046 current_thread_info()->sysenter_return =
31047 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31048 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31049
31050 up_fail:
31051 if (ret)
31052 - current->mm->context.vdso = NULL;
31053 + current->mm->context.vdso = 0;
31054
31055 up_write(&mm->mmap_sem);
31056
31057 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31058
31059 const char *arch_vma_name(struct vm_area_struct *vma)
31060 {
31061 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31062 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31063 return "[vdso]";
31064 +
31065 +#ifdef CONFIG_PAX_SEGMEXEC
31066 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31067 + return "[vdso]";
31068 +#endif
31069 +
31070 return NULL;
31071 }
31072
31073 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31074 * Check to see if the corresponding task was created in compat vdso
31075 * mode.
31076 */
31077 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31078 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31079 return &gate_vma;
31080 return NULL;
31081 }
31082 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31083 index 431e875..cbb23f3 100644
31084 --- a/arch/x86/vdso/vma.c
31085 +++ b/arch/x86/vdso/vma.c
31086 @@ -16,8 +16,6 @@
31087 #include <asm/vdso.h>
31088 #include <asm/page.h>
31089
31090 -unsigned int __read_mostly vdso_enabled = 1;
31091 -
31092 extern char vdso_start[], vdso_end[];
31093 extern unsigned short vdso_sync_cpuid;
31094
31095 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31096 * unaligned here as a result of stack start randomization.
31097 */
31098 addr = PAGE_ALIGN(addr);
31099 - addr = align_vdso_addr(addr);
31100
31101 return addr;
31102 }
31103 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31104 unsigned size)
31105 {
31106 struct mm_struct *mm = current->mm;
31107 - unsigned long addr;
31108 + unsigned long addr = 0;
31109 int ret;
31110
31111 - if (!vdso_enabled)
31112 - return 0;
31113 -
31114 down_write(&mm->mmap_sem);
31115 +
31116 +#ifdef CONFIG_PAX_RANDMMAP
31117 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31118 +#endif
31119 +
31120 addr = vdso_addr(mm->start_stack, size);
31121 + addr = align_vdso_addr(addr);
31122 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31123 if (IS_ERR_VALUE(addr)) {
31124 ret = addr;
31125 goto up_fail;
31126 }
31127
31128 - current->mm->context.vdso = (void *)addr;
31129 + mm->context.vdso = addr;
31130
31131 ret = install_special_mapping(mm, addr, size,
31132 VM_READ|VM_EXEC|
31133 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31134 pages);
31135 - if (ret) {
31136 - current->mm->context.vdso = NULL;
31137 - goto up_fail;
31138 - }
31139 + if (ret)
31140 + mm->context.vdso = 0;
31141
31142 up_fail:
31143 up_write(&mm->mmap_sem);
31144 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31145 vdsox32_size);
31146 }
31147 #endif
31148 -
31149 -static __init int vdso_setup(char *s)
31150 -{
31151 - vdso_enabled = simple_strtoul(s, NULL, 0);
31152 - return 0;
31153 -}
31154 -__setup("vdso=", vdso_setup);
31155 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31156 index cf95e19..17e9f50 100644
31157 --- a/arch/x86/xen/enlighten.c
31158 +++ b/arch/x86/xen/enlighten.c
31159 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31160
31161 struct shared_info xen_dummy_shared_info;
31162
31163 -void *xen_initial_gdt;
31164 -
31165 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31166 __read_mostly int xen_have_vector_callback;
31167 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31168 @@ -511,8 +509,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31169 {
31170 unsigned long va = dtr->address;
31171 unsigned int size = dtr->size + 1;
31172 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31173 - unsigned long frames[pages];
31174 + unsigned long frames[65536 / PAGE_SIZE];
31175 int f;
31176
31177 /*
31178 @@ -560,8 +557,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31179 {
31180 unsigned long va = dtr->address;
31181 unsigned int size = dtr->size + 1;
31182 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31183 - unsigned long frames[pages];
31184 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31185 int f;
31186
31187 /*
31188 @@ -569,7 +565,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31189 * 8-byte entries, or 16 4k pages..
31190 */
31191
31192 - BUG_ON(size > 65536);
31193 + BUG_ON(size > GDT_SIZE);
31194 BUG_ON(va & ~PAGE_MASK);
31195
31196 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31197 @@ -954,7 +950,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31198 return 0;
31199 }
31200
31201 -static void set_xen_basic_apic_ops(void)
31202 +static void __init set_xen_basic_apic_ops(void)
31203 {
31204 apic->read = xen_apic_read;
31205 apic->write = xen_apic_write;
31206 @@ -1260,30 +1256,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31207 #endif
31208 };
31209
31210 -static void xen_reboot(int reason)
31211 +static __noreturn void xen_reboot(int reason)
31212 {
31213 struct sched_shutdown r = { .reason = reason };
31214
31215 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31216 - BUG();
31217 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31218 + BUG();
31219 }
31220
31221 -static void xen_restart(char *msg)
31222 +static __noreturn void xen_restart(char *msg)
31223 {
31224 xen_reboot(SHUTDOWN_reboot);
31225 }
31226
31227 -static void xen_emergency_restart(void)
31228 +static __noreturn void xen_emergency_restart(void)
31229 {
31230 xen_reboot(SHUTDOWN_reboot);
31231 }
31232
31233 -static void xen_machine_halt(void)
31234 +static __noreturn void xen_machine_halt(void)
31235 {
31236 xen_reboot(SHUTDOWN_poweroff);
31237 }
31238
31239 -static void xen_machine_power_off(void)
31240 +static __noreturn void xen_machine_power_off(void)
31241 {
31242 if (pm_power_off)
31243 pm_power_off();
31244 @@ -1385,7 +1381,17 @@ asmlinkage void __init xen_start_kernel(void)
31245 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31246
31247 /* Work out if we support NX */
31248 - x86_configure_nx();
31249 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31250 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31251 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31252 + unsigned l, h;
31253 +
31254 + __supported_pte_mask |= _PAGE_NX;
31255 + rdmsr(MSR_EFER, l, h);
31256 + l |= EFER_NX;
31257 + wrmsr(MSR_EFER, l, h);
31258 + }
31259 +#endif
31260
31261 xen_setup_features();
31262
31263 @@ -1416,13 +1422,6 @@ asmlinkage void __init xen_start_kernel(void)
31264
31265 machine_ops = xen_machine_ops;
31266
31267 - /*
31268 - * The only reliable way to retain the initial address of the
31269 - * percpu gdt_page is to remember it here, so we can go and
31270 - * mark it RW later, when the initial percpu area is freed.
31271 - */
31272 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31273 -
31274 xen_smp_init();
31275
31276 #ifdef CONFIG_ACPI_NUMA
31277 @@ -1616,7 +1615,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31278 return NOTIFY_OK;
31279 }
31280
31281 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31282 +static struct notifier_block xen_hvm_cpu_notifier = {
31283 .notifier_call = xen_hvm_cpu_notify,
31284 };
31285
31286 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31287 index e006c18..b9a7d6c 100644
31288 --- a/arch/x86/xen/mmu.c
31289 +++ b/arch/x86/xen/mmu.c
31290 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31291 /* L3_k[510] -> level2_kernel_pgt
31292 * L3_i[511] -> level2_fixmap_pgt */
31293 convert_pfn_mfn(level3_kernel_pgt);
31294 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31295 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31296 + convert_pfn_mfn(level3_vmemmap_pgt);
31297
31298 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31299 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31300 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31301 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31302 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31303 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31304 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31305 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31306 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31307 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31308 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31309 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31310 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31311 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31312
31313 @@ -2110,6 +2117,7 @@ static void __init xen_post_allocator_init(void)
31314 pv_mmu_ops.set_pud = xen_set_pud;
31315 #if PAGETABLE_LEVELS == 4
31316 pv_mmu_ops.set_pgd = xen_set_pgd;
31317 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31318 #endif
31319
31320 /* This will work as long as patching hasn't happened yet
31321 @@ -2188,6 +2196,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31322 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31323 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31324 .set_pgd = xen_set_pgd_hyper,
31325 + .set_pgd_batched = xen_set_pgd_hyper,
31326
31327 .alloc_pud = xen_alloc_pmd_init,
31328 .release_pud = xen_release_pmd_init,
31329 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31330 index 22c800a..8915f1e 100644
31331 --- a/arch/x86/xen/smp.c
31332 +++ b/arch/x86/xen/smp.c
31333 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31334 {
31335 BUG_ON(smp_processor_id() != 0);
31336 native_smp_prepare_boot_cpu();
31337 -
31338 - /* We've switched to the "real" per-cpu gdt, so make sure the
31339 - old memory can be recycled */
31340 - make_lowmem_page_readwrite(xen_initial_gdt);
31341 -
31342 xen_filter_cpu_maps();
31343 xen_setup_vcpu_info_placement();
31344 }
31345 @@ -303,7 +298,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31346 ctxt->user_regs.ss = __KERNEL_DS;
31347 #ifdef CONFIG_X86_32
31348 ctxt->user_regs.fs = __KERNEL_PERCPU;
31349 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31350 + savesegment(gs, ctxt->user_regs.gs);
31351 #else
31352 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31353 #endif
31354 @@ -313,8 +308,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31355
31356 {
31357 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31358 - ctxt->user_regs.ds = __USER_DS;
31359 - ctxt->user_regs.es = __USER_DS;
31360 + ctxt->user_regs.ds = __KERNEL_DS;
31361 + ctxt->user_regs.es = __KERNEL_DS;
31362
31363 xen_copy_trap_info(ctxt->trap_ctxt);
31364
31365 @@ -359,13 +354,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31366 int rc;
31367
31368 per_cpu(current_task, cpu) = idle;
31369 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31370 #ifdef CONFIG_X86_32
31371 irq_ctx_init(cpu);
31372 #else
31373 clear_tsk_thread_flag(idle, TIF_FORK);
31374 - per_cpu(kernel_stack, cpu) =
31375 - (unsigned long)task_stack_page(idle) -
31376 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31377 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31378 #endif
31379 xen_setup_runstate_info(cpu);
31380 xen_setup_timer(cpu);
31381 @@ -634,7 +628,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31382
31383 void __init xen_smp_init(void)
31384 {
31385 - smp_ops = xen_smp_ops;
31386 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31387 xen_fill_possible_map();
31388 xen_init_spinlocks();
31389 }
31390 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31391 index 33ca6e4..0ded929 100644
31392 --- a/arch/x86/xen/xen-asm_32.S
31393 +++ b/arch/x86/xen/xen-asm_32.S
31394 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31395 ESP_OFFSET=4 # bytes pushed onto stack
31396
31397 /*
31398 - * Store vcpu_info pointer for easy access. Do it this way to
31399 - * avoid having to reload %fs
31400 + * Store vcpu_info pointer for easy access.
31401 */
31402 #ifdef CONFIG_SMP
31403 - GET_THREAD_INFO(%eax)
31404 - movl %ss:TI_cpu(%eax), %eax
31405 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31406 - mov %ss:xen_vcpu(%eax), %eax
31407 + push %fs
31408 + mov $(__KERNEL_PERCPU), %eax
31409 + mov %eax, %fs
31410 + mov PER_CPU_VAR(xen_vcpu), %eax
31411 + pop %fs
31412 #else
31413 movl %ss:xen_vcpu, %eax
31414 #endif
31415 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31416 index 7faed58..ba4427c 100644
31417 --- a/arch/x86/xen/xen-head.S
31418 +++ b/arch/x86/xen/xen-head.S
31419 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31420 #ifdef CONFIG_X86_32
31421 mov %esi,xen_start_info
31422 mov $init_thread_union+THREAD_SIZE,%esp
31423 +#ifdef CONFIG_SMP
31424 + movl $cpu_gdt_table,%edi
31425 + movl $__per_cpu_load,%eax
31426 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31427 + rorl $16,%eax
31428 + movb %al,__KERNEL_PERCPU + 4(%edi)
31429 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31430 + movl $__per_cpu_end - 1,%eax
31431 + subl $__per_cpu_start,%eax
31432 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31433 +#endif
31434 #else
31435 mov %rsi,xen_start_info
31436 mov $init_thread_union+THREAD_SIZE,%rsp
31437 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31438 index a95b417..b6dbd0b 100644
31439 --- a/arch/x86/xen/xen-ops.h
31440 +++ b/arch/x86/xen/xen-ops.h
31441 @@ -10,8 +10,6 @@
31442 extern const char xen_hypervisor_callback[];
31443 extern const char xen_failsafe_callback[];
31444
31445 -extern void *xen_initial_gdt;
31446 -
31447 struct trap_info;
31448 void xen_copy_trap_info(struct trap_info *traps);
31449
31450 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31451 index 525bd3d..ef888b1 100644
31452 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31453 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31454 @@ -119,9 +119,9 @@
31455 ----------------------------------------------------------------------*/
31456
31457 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31458 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31459 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31460 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31461 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31462
31463 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31464 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31465 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31466 index 2f33760..835e50a 100644
31467 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31468 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31469 @@ -11,6 +11,7 @@
31470 #ifndef _XTENSA_CORE_H
31471 #define _XTENSA_CORE_H
31472
31473 +#include <linux/const.h>
31474
31475 /****************************************************************************
31476 Parameters Useful for Any Code, USER or PRIVILEGED
31477 @@ -112,9 +113,9 @@
31478 ----------------------------------------------------------------------*/
31479
31480 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31481 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31482 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31483 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31484 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31485
31486 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31487 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31488 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31489 index af00795..2bb8105 100644
31490 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31491 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31492 @@ -11,6 +11,7 @@
31493 #ifndef _XTENSA_CORE_CONFIGURATION_H
31494 #define _XTENSA_CORE_CONFIGURATION_H
31495
31496 +#include <linux/const.h>
31497
31498 /****************************************************************************
31499 Parameters Useful for Any Code, USER or PRIVILEGED
31500 @@ -118,9 +119,9 @@
31501 ----------------------------------------------------------------------*/
31502
31503 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31504 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31505 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31506 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31507 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31508
31509 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31510 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31511 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31512 index 58916af..eb9dbcf6 100644
31513 --- a/block/blk-iopoll.c
31514 +++ b/block/blk-iopoll.c
31515 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31516 }
31517 EXPORT_SYMBOL(blk_iopoll_complete);
31518
31519 -static void blk_iopoll_softirq(struct softirq_action *h)
31520 +static void blk_iopoll_softirq(void)
31521 {
31522 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31523 int rearm = 0, budget = blk_iopoll_budget;
31524 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31525 return NOTIFY_OK;
31526 }
31527
31528 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31529 +static struct notifier_block blk_iopoll_cpu_notifier = {
31530 .notifier_call = blk_iopoll_cpu_notify,
31531 };
31532
31533 diff --git a/block/blk-map.c b/block/blk-map.c
31534 index 623e1cd..ca1e109 100644
31535 --- a/block/blk-map.c
31536 +++ b/block/blk-map.c
31537 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31538 if (!len || !kbuf)
31539 return -EINVAL;
31540
31541 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31542 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31543 if (do_copy)
31544 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31545 else
31546 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31547 index 467c8de..f3628c5 100644
31548 --- a/block/blk-softirq.c
31549 +++ b/block/blk-softirq.c
31550 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31551 * Softirq action handler - move entries to local list and loop over them
31552 * while passing them to the queue registered handler.
31553 */
31554 -static void blk_done_softirq(struct softirq_action *h)
31555 +static void blk_done_softirq(void)
31556 {
31557 struct list_head *cpu_list, local_list;
31558
31559 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31560 return NOTIFY_OK;
31561 }
31562
31563 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31564 +static struct notifier_block blk_cpu_notifier = {
31565 .notifier_call = blk_cpu_notify,
31566 };
31567
31568 diff --git a/block/bsg.c b/block/bsg.c
31569 index 420a5a9..23834aa 100644
31570 --- a/block/bsg.c
31571 +++ b/block/bsg.c
31572 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31573 struct sg_io_v4 *hdr, struct bsg_device *bd,
31574 fmode_t has_write_perm)
31575 {
31576 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31577 + unsigned char *cmdptr;
31578 +
31579 if (hdr->request_len > BLK_MAX_CDB) {
31580 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31581 if (!rq->cmd)
31582 return -ENOMEM;
31583 - }
31584 + cmdptr = rq->cmd;
31585 + } else
31586 + cmdptr = tmpcmd;
31587
31588 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31589 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31590 hdr->request_len))
31591 return -EFAULT;
31592
31593 + if (cmdptr != rq->cmd)
31594 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31595 +
31596 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31597 if (blk_verify_command(rq->cmd, has_write_perm))
31598 return -EPERM;
31599 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31600 index 7c668c8..db3521c 100644
31601 --- a/block/compat_ioctl.c
31602 +++ b/block/compat_ioctl.c
31603 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31604 err |= __get_user(f->spec1, &uf->spec1);
31605 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31606 err |= __get_user(name, &uf->name);
31607 - f->name = compat_ptr(name);
31608 + f->name = (void __force_kernel *)compat_ptr(name);
31609 if (err) {
31610 err = -EFAULT;
31611 goto out;
31612 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31613 index ff5804e..a88acad 100644
31614 --- a/block/partitions/efi.c
31615 +++ b/block/partitions/efi.c
31616 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31617 if (!gpt)
31618 return NULL;
31619
31620 + if (!le32_to_cpu(gpt->num_partition_entries))
31621 + return NULL;
31622 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31623 + if (!pte)
31624 + return NULL;
31625 +
31626 count = le32_to_cpu(gpt->num_partition_entries) *
31627 le32_to_cpu(gpt->sizeof_partition_entry);
31628 - if (!count)
31629 - return NULL;
31630 - pte = kzalloc(count, GFP_KERNEL);
31631 - if (!pte)
31632 - return NULL;
31633 -
31634 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31635 (u8 *) pte,
31636 count) < count) {
31637 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31638 index 9a87daa..fb17486 100644
31639 --- a/block/scsi_ioctl.c
31640 +++ b/block/scsi_ioctl.c
31641 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31642 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31643 struct sg_io_hdr *hdr, fmode_t mode)
31644 {
31645 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31646 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31647 + unsigned char *cmdptr;
31648 +
31649 + if (rq->cmd != rq->__cmd)
31650 + cmdptr = rq->cmd;
31651 + else
31652 + cmdptr = tmpcmd;
31653 +
31654 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31655 return -EFAULT;
31656 +
31657 + if (cmdptr != rq->cmd)
31658 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31659 +
31660 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31661 return -EPERM;
31662
31663 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31664 int err;
31665 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31666 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31667 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31668 + unsigned char *cmdptr;
31669
31670 if (!sic)
31671 return -EINVAL;
31672 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31673 */
31674 err = -EFAULT;
31675 rq->cmd_len = cmdlen;
31676 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31677 +
31678 + if (rq->cmd != rq->__cmd)
31679 + cmdptr = rq->cmd;
31680 + else
31681 + cmdptr = tmpcmd;
31682 +
31683 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31684 goto error;
31685
31686 + if (rq->cmd != cmdptr)
31687 + memcpy(rq->cmd, cmdptr, cmdlen);
31688 +
31689 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31690 goto error;
31691
31692 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31693 index 7bdd61b..afec999 100644
31694 --- a/crypto/cryptd.c
31695 +++ b/crypto/cryptd.c
31696 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31697
31698 struct cryptd_blkcipher_request_ctx {
31699 crypto_completion_t complete;
31700 -};
31701 +} __no_const;
31702
31703 struct cryptd_hash_ctx {
31704 struct crypto_shash *child;
31705 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31706
31707 struct cryptd_aead_request_ctx {
31708 crypto_completion_t complete;
31709 -};
31710 +} __no_const;
31711
31712 static void cryptd_queue_worker(struct work_struct *work);
31713
31714 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31715 index f220d64..d359ad6 100644
31716 --- a/drivers/acpi/apei/apei-internal.h
31717 +++ b/drivers/acpi/apei/apei-internal.h
31718 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31719 struct apei_exec_ins_type {
31720 u32 flags;
31721 apei_exec_ins_func_t run;
31722 -};
31723 +} __do_const;
31724
31725 struct apei_exec_context {
31726 u32 ip;
31727 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31728 index fefc2ca..12a535d 100644
31729 --- a/drivers/acpi/apei/cper.c
31730 +++ b/drivers/acpi/apei/cper.c
31731 @@ -39,12 +39,12 @@
31732 */
31733 u64 cper_next_record_id(void)
31734 {
31735 - static atomic64_t seq;
31736 + static atomic64_unchecked_t seq;
31737
31738 - if (!atomic64_read(&seq))
31739 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31740 + if (!atomic64_read_unchecked(&seq))
31741 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31742
31743 - return atomic64_inc_return(&seq);
31744 + return atomic64_inc_return_unchecked(&seq);
31745 }
31746 EXPORT_SYMBOL_GPL(cper_next_record_id);
31747
31748 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31749 index be60399..778b33e8 100644
31750 --- a/drivers/acpi/bgrt.c
31751 +++ b/drivers/acpi/bgrt.c
31752 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31753 return -ENODEV;
31754
31755 sysfs_bin_attr_init(&image_attr);
31756 - image_attr.private = bgrt_image;
31757 - image_attr.size = bgrt_image_size;
31758 + pax_open_kernel();
31759 + *(void **)&image_attr.private = bgrt_image;
31760 + *(size_t *)&image_attr.size = bgrt_image_size;
31761 + pax_close_kernel();
31762
31763 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31764 if (!bgrt_kobj)
31765 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31766 index cb96296..b81293b 100644
31767 --- a/drivers/acpi/blacklist.c
31768 +++ b/drivers/acpi/blacklist.c
31769 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31770 u32 is_critical_error;
31771 };
31772
31773 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31774 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31775
31776 /*
31777 * POLICY: If *anything* doesn't work, put it on the blacklist.
31778 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31779 return 0;
31780 }
31781
31782 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31783 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31784 {
31785 .callback = dmi_disable_osi_vista,
31786 .ident = "Fujitsu Siemens",
31787 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31788 index 7586544..636a2f0 100644
31789 --- a/drivers/acpi/ec_sys.c
31790 +++ b/drivers/acpi/ec_sys.c
31791 @@ -12,6 +12,7 @@
31792 #include <linux/acpi.h>
31793 #include <linux/debugfs.h>
31794 #include <linux/module.h>
31795 +#include <linux/uaccess.h>
31796 #include "internal.h"
31797
31798 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31799 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31800 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31801 */
31802 unsigned int size = EC_SPACE_SIZE;
31803 - u8 *data = (u8 *) buf;
31804 + u8 data;
31805 loff_t init_off = *off;
31806 int err = 0;
31807
31808 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31809 size = count;
31810
31811 while (size) {
31812 - err = ec_read(*off, &data[*off - init_off]);
31813 + err = ec_read(*off, &data);
31814 if (err)
31815 return err;
31816 + if (put_user(data, &buf[*off - init_off]))
31817 + return -EFAULT;
31818 *off += 1;
31819 size--;
31820 }
31821 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31822
31823 unsigned int size = count;
31824 loff_t init_off = *off;
31825 - u8 *data = (u8 *) buf;
31826 int err = 0;
31827
31828 if (*off >= EC_SPACE_SIZE)
31829 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31830 }
31831
31832 while (size) {
31833 - u8 byte_write = data[*off - init_off];
31834 + u8 byte_write;
31835 + if (get_user(byte_write, &buf[*off - init_off]))
31836 + return -EFAULT;
31837 err = ec_write(*off, byte_write);
31838 if (err)
31839 return err;
31840 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
31841 index ee255c6..747c68b 100644
31842 --- a/drivers/acpi/processor_idle.c
31843 +++ b/drivers/acpi/processor_idle.c
31844 @@ -986,7 +986,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
31845 {
31846 int i, count = CPUIDLE_DRIVER_STATE_START;
31847 struct acpi_processor_cx *cx;
31848 - struct cpuidle_state *state;
31849 + cpuidle_state_no_const *state;
31850 struct cpuidle_driver *drv = &acpi_idle_driver;
31851
31852 if (!pr->flags.power_setup_done)
31853 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
31854 index 41c0504..f8c0836 100644
31855 --- a/drivers/acpi/sysfs.c
31856 +++ b/drivers/acpi/sysfs.c
31857 @@ -420,11 +420,11 @@ static u32 num_counters;
31858 static struct attribute **all_attrs;
31859 static u32 acpi_gpe_count;
31860
31861 -static struct attribute_group interrupt_stats_attr_group = {
31862 +static attribute_group_no_const interrupt_stats_attr_group = {
31863 .name = "interrupts",
31864 };
31865
31866 -static struct kobj_attribute *counter_attrs;
31867 +static kobj_attribute_no_const *counter_attrs;
31868
31869 static void delete_gpe_attr_array(void)
31870 {
31871 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
31872 index 34c8216..f56c828 100644
31873 --- a/drivers/ata/libahci.c
31874 +++ b/drivers/ata/libahci.c
31875 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
31876 }
31877 EXPORT_SYMBOL_GPL(ahci_kick_engine);
31878
31879 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31880 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31881 struct ata_taskfile *tf, int is_cmd, u16 flags,
31882 unsigned long timeout_msec)
31883 {
31884 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
31885 index 63c743b..0422dc6 100644
31886 --- a/drivers/ata/libata-core.c
31887 +++ b/drivers/ata/libata-core.c
31888 @@ -4786,7 +4786,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
31889 struct ata_port *ap;
31890 unsigned int tag;
31891
31892 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31893 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31894 ap = qc->ap;
31895
31896 qc->flags = 0;
31897 @@ -4802,7 +4802,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
31898 struct ata_port *ap;
31899 struct ata_link *link;
31900
31901 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31902 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31903 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
31904 ap = qc->ap;
31905 link = qc->dev->link;
31906 @@ -5920,6 +5920,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31907 return;
31908
31909 spin_lock(&lock);
31910 + pax_open_kernel();
31911
31912 for (cur = ops->inherits; cur; cur = cur->inherits) {
31913 void **inherit = (void **)cur;
31914 @@ -5933,8 +5934,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31915 if (IS_ERR(*pp))
31916 *pp = NULL;
31917
31918 - ops->inherits = NULL;
31919 + *(struct ata_port_operations **)&ops->inherits = NULL;
31920
31921 + pax_close_kernel();
31922 spin_unlock(&lock);
31923 }
31924
31925 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
31926 index 405022d..fb70e53 100644
31927 --- a/drivers/ata/pata_arasan_cf.c
31928 +++ b/drivers/ata/pata_arasan_cf.c
31929 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
31930 /* Handle platform specific quirks */
31931 if (pdata->quirk) {
31932 if (pdata->quirk & CF_BROKEN_PIO) {
31933 - ap->ops->set_piomode = NULL;
31934 + pax_open_kernel();
31935 + *(void **)&ap->ops->set_piomode = NULL;
31936 + pax_close_kernel();
31937 ap->pio_mask = 0;
31938 }
31939 if (pdata->quirk & CF_BROKEN_MWDMA)
31940 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
31941 index f9b983a..887b9d8 100644
31942 --- a/drivers/atm/adummy.c
31943 +++ b/drivers/atm/adummy.c
31944 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
31945 vcc->pop(vcc, skb);
31946 else
31947 dev_kfree_skb_any(skb);
31948 - atomic_inc(&vcc->stats->tx);
31949 + atomic_inc_unchecked(&vcc->stats->tx);
31950
31951 return 0;
31952 }
31953 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
31954 index 77a7480..05cde58 100644
31955 --- a/drivers/atm/ambassador.c
31956 +++ b/drivers/atm/ambassador.c
31957 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
31958 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
31959
31960 // VC layer stats
31961 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
31962 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
31963
31964 // free the descriptor
31965 kfree (tx_descr);
31966 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31967 dump_skb ("<<<", vc, skb);
31968
31969 // VC layer stats
31970 - atomic_inc(&atm_vcc->stats->rx);
31971 + atomic_inc_unchecked(&atm_vcc->stats->rx);
31972 __net_timestamp(skb);
31973 // end of our responsibility
31974 atm_vcc->push (atm_vcc, skb);
31975 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31976 } else {
31977 PRINTK (KERN_INFO, "dropped over-size frame");
31978 // should we count this?
31979 - atomic_inc(&atm_vcc->stats->rx_drop);
31980 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
31981 }
31982
31983 } else {
31984 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
31985 }
31986
31987 if (check_area (skb->data, skb->len)) {
31988 - atomic_inc(&atm_vcc->stats->tx_err);
31989 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
31990 return -ENOMEM; // ?
31991 }
31992
31993 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
31994 index 0e3f8f9..765a7a5 100644
31995 --- a/drivers/atm/atmtcp.c
31996 +++ b/drivers/atm/atmtcp.c
31997 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31998 if (vcc->pop) vcc->pop(vcc,skb);
31999 else dev_kfree_skb(skb);
32000 if (dev_data) return 0;
32001 - atomic_inc(&vcc->stats->tx_err);
32002 + atomic_inc_unchecked(&vcc->stats->tx_err);
32003 return -ENOLINK;
32004 }
32005 size = skb->len+sizeof(struct atmtcp_hdr);
32006 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32007 if (!new_skb) {
32008 if (vcc->pop) vcc->pop(vcc,skb);
32009 else dev_kfree_skb(skb);
32010 - atomic_inc(&vcc->stats->tx_err);
32011 + atomic_inc_unchecked(&vcc->stats->tx_err);
32012 return -ENOBUFS;
32013 }
32014 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32015 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32016 if (vcc->pop) vcc->pop(vcc,skb);
32017 else dev_kfree_skb(skb);
32018 out_vcc->push(out_vcc,new_skb);
32019 - atomic_inc(&vcc->stats->tx);
32020 - atomic_inc(&out_vcc->stats->rx);
32021 + atomic_inc_unchecked(&vcc->stats->tx);
32022 + atomic_inc_unchecked(&out_vcc->stats->rx);
32023 return 0;
32024 }
32025
32026 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32027 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32028 read_unlock(&vcc_sklist_lock);
32029 if (!out_vcc) {
32030 - atomic_inc(&vcc->stats->tx_err);
32031 + atomic_inc_unchecked(&vcc->stats->tx_err);
32032 goto done;
32033 }
32034 skb_pull(skb,sizeof(struct atmtcp_hdr));
32035 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32036 __net_timestamp(new_skb);
32037 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32038 out_vcc->push(out_vcc,new_skb);
32039 - atomic_inc(&vcc->stats->tx);
32040 - atomic_inc(&out_vcc->stats->rx);
32041 + atomic_inc_unchecked(&vcc->stats->tx);
32042 + atomic_inc_unchecked(&out_vcc->stats->rx);
32043 done:
32044 if (vcc->pop) vcc->pop(vcc,skb);
32045 else dev_kfree_skb(skb);
32046 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32047 index b1955ba..b179940 100644
32048 --- a/drivers/atm/eni.c
32049 +++ b/drivers/atm/eni.c
32050 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32051 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32052 vcc->dev->number);
32053 length = 0;
32054 - atomic_inc(&vcc->stats->rx_err);
32055 + atomic_inc_unchecked(&vcc->stats->rx_err);
32056 }
32057 else {
32058 length = ATM_CELL_SIZE-1; /* no HEC */
32059 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32060 size);
32061 }
32062 eff = length = 0;
32063 - atomic_inc(&vcc->stats->rx_err);
32064 + atomic_inc_unchecked(&vcc->stats->rx_err);
32065 }
32066 else {
32067 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32068 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32069 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32070 vcc->dev->number,vcc->vci,length,size << 2,descr);
32071 length = eff = 0;
32072 - atomic_inc(&vcc->stats->rx_err);
32073 + atomic_inc_unchecked(&vcc->stats->rx_err);
32074 }
32075 }
32076 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32077 @@ -767,7 +767,7 @@ rx_dequeued++;
32078 vcc->push(vcc,skb);
32079 pushed++;
32080 }
32081 - atomic_inc(&vcc->stats->rx);
32082 + atomic_inc_unchecked(&vcc->stats->rx);
32083 }
32084 wake_up(&eni_dev->rx_wait);
32085 }
32086 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32087 PCI_DMA_TODEVICE);
32088 if (vcc->pop) vcc->pop(vcc,skb);
32089 else dev_kfree_skb_irq(skb);
32090 - atomic_inc(&vcc->stats->tx);
32091 + atomic_inc_unchecked(&vcc->stats->tx);
32092 wake_up(&eni_dev->tx_wait);
32093 dma_complete++;
32094 }
32095 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32096 index b41c948..a002b17 100644
32097 --- a/drivers/atm/firestream.c
32098 +++ b/drivers/atm/firestream.c
32099 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32100 }
32101 }
32102
32103 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32104 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32105
32106 fs_dprintk (FS_DEBUG_TXMEM, "i");
32107 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32108 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32109 #endif
32110 skb_put (skb, qe->p1 & 0xffff);
32111 ATM_SKB(skb)->vcc = atm_vcc;
32112 - atomic_inc(&atm_vcc->stats->rx);
32113 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32114 __net_timestamp(skb);
32115 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32116 atm_vcc->push (atm_vcc, skb);
32117 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32118 kfree (pe);
32119 }
32120 if (atm_vcc)
32121 - atomic_inc(&atm_vcc->stats->rx_drop);
32122 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32123 break;
32124 case 0x1f: /* Reassembly abort: no buffers. */
32125 /* Silently increment error counter. */
32126 if (atm_vcc)
32127 - atomic_inc(&atm_vcc->stats->rx_drop);
32128 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32129 break;
32130 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32131 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32132 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32133 index 204814e..cede831 100644
32134 --- a/drivers/atm/fore200e.c
32135 +++ b/drivers/atm/fore200e.c
32136 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32137 #endif
32138 /* check error condition */
32139 if (*entry->status & STATUS_ERROR)
32140 - atomic_inc(&vcc->stats->tx_err);
32141 + atomic_inc_unchecked(&vcc->stats->tx_err);
32142 else
32143 - atomic_inc(&vcc->stats->tx);
32144 + atomic_inc_unchecked(&vcc->stats->tx);
32145 }
32146 }
32147
32148 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32149 if (skb == NULL) {
32150 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32151
32152 - atomic_inc(&vcc->stats->rx_drop);
32153 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32154 return -ENOMEM;
32155 }
32156
32157 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32158
32159 dev_kfree_skb_any(skb);
32160
32161 - atomic_inc(&vcc->stats->rx_drop);
32162 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32163 return -ENOMEM;
32164 }
32165
32166 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32167
32168 vcc->push(vcc, skb);
32169 - atomic_inc(&vcc->stats->rx);
32170 + atomic_inc_unchecked(&vcc->stats->rx);
32171
32172 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32173
32174 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32175 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32176 fore200e->atm_dev->number,
32177 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32178 - atomic_inc(&vcc->stats->rx_err);
32179 + atomic_inc_unchecked(&vcc->stats->rx_err);
32180 }
32181 }
32182
32183 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32184 goto retry_here;
32185 }
32186
32187 - atomic_inc(&vcc->stats->tx_err);
32188 + atomic_inc_unchecked(&vcc->stats->tx_err);
32189
32190 fore200e->tx_sat++;
32191 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32192 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32193 index d689126..e78e412 100644
32194 --- a/drivers/atm/he.c
32195 +++ b/drivers/atm/he.c
32196 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32197
32198 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32199 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32200 - atomic_inc(&vcc->stats->rx_drop);
32201 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32202 goto return_host_buffers;
32203 }
32204
32205 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32206 RBRQ_LEN_ERR(he_dev->rbrq_head)
32207 ? "LEN_ERR" : "",
32208 vcc->vpi, vcc->vci);
32209 - atomic_inc(&vcc->stats->rx_err);
32210 + atomic_inc_unchecked(&vcc->stats->rx_err);
32211 goto return_host_buffers;
32212 }
32213
32214 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32215 vcc->push(vcc, skb);
32216 spin_lock(&he_dev->global_lock);
32217
32218 - atomic_inc(&vcc->stats->rx);
32219 + atomic_inc_unchecked(&vcc->stats->rx);
32220
32221 return_host_buffers:
32222 ++pdus_assembled;
32223 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32224 tpd->vcc->pop(tpd->vcc, tpd->skb);
32225 else
32226 dev_kfree_skb_any(tpd->skb);
32227 - atomic_inc(&tpd->vcc->stats->tx_err);
32228 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32229 }
32230 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32231 return;
32232 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32233 vcc->pop(vcc, skb);
32234 else
32235 dev_kfree_skb_any(skb);
32236 - atomic_inc(&vcc->stats->tx_err);
32237 + atomic_inc_unchecked(&vcc->stats->tx_err);
32238 return -EINVAL;
32239 }
32240
32241 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32242 vcc->pop(vcc, skb);
32243 else
32244 dev_kfree_skb_any(skb);
32245 - atomic_inc(&vcc->stats->tx_err);
32246 + atomic_inc_unchecked(&vcc->stats->tx_err);
32247 return -EINVAL;
32248 }
32249 #endif
32250 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32251 vcc->pop(vcc, skb);
32252 else
32253 dev_kfree_skb_any(skb);
32254 - atomic_inc(&vcc->stats->tx_err);
32255 + atomic_inc_unchecked(&vcc->stats->tx_err);
32256 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32257 return -ENOMEM;
32258 }
32259 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32260 vcc->pop(vcc, skb);
32261 else
32262 dev_kfree_skb_any(skb);
32263 - atomic_inc(&vcc->stats->tx_err);
32264 + atomic_inc_unchecked(&vcc->stats->tx_err);
32265 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32266 return -ENOMEM;
32267 }
32268 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32269 __enqueue_tpd(he_dev, tpd, cid);
32270 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32271
32272 - atomic_inc(&vcc->stats->tx);
32273 + atomic_inc_unchecked(&vcc->stats->tx);
32274
32275 return 0;
32276 }
32277 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32278 index 1dc0519..1aadaf7 100644
32279 --- a/drivers/atm/horizon.c
32280 +++ b/drivers/atm/horizon.c
32281 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32282 {
32283 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32284 // VC layer stats
32285 - atomic_inc(&vcc->stats->rx);
32286 + atomic_inc_unchecked(&vcc->stats->rx);
32287 __net_timestamp(skb);
32288 // end of our responsibility
32289 vcc->push (vcc, skb);
32290 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32291 dev->tx_iovec = NULL;
32292
32293 // VC layer stats
32294 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32295 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32296
32297 // free the skb
32298 hrz_kfree_skb (skb);
32299 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32300 index 272f009..a18ba55 100644
32301 --- a/drivers/atm/idt77252.c
32302 +++ b/drivers/atm/idt77252.c
32303 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32304 else
32305 dev_kfree_skb(skb);
32306
32307 - atomic_inc(&vcc->stats->tx);
32308 + atomic_inc_unchecked(&vcc->stats->tx);
32309 }
32310
32311 atomic_dec(&scq->used);
32312 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32313 if ((sb = dev_alloc_skb(64)) == NULL) {
32314 printk("%s: Can't allocate buffers for aal0.\n",
32315 card->name);
32316 - atomic_add(i, &vcc->stats->rx_drop);
32317 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32318 break;
32319 }
32320 if (!atm_charge(vcc, sb->truesize)) {
32321 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32322 card->name);
32323 - atomic_add(i - 1, &vcc->stats->rx_drop);
32324 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32325 dev_kfree_skb(sb);
32326 break;
32327 }
32328 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32329 ATM_SKB(sb)->vcc = vcc;
32330 __net_timestamp(sb);
32331 vcc->push(vcc, sb);
32332 - atomic_inc(&vcc->stats->rx);
32333 + atomic_inc_unchecked(&vcc->stats->rx);
32334
32335 cell += ATM_CELL_PAYLOAD;
32336 }
32337 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32338 "(CDC: %08x)\n",
32339 card->name, len, rpp->len, readl(SAR_REG_CDC));
32340 recycle_rx_pool_skb(card, rpp);
32341 - atomic_inc(&vcc->stats->rx_err);
32342 + atomic_inc_unchecked(&vcc->stats->rx_err);
32343 return;
32344 }
32345 if (stat & SAR_RSQE_CRC) {
32346 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32347 recycle_rx_pool_skb(card, rpp);
32348 - atomic_inc(&vcc->stats->rx_err);
32349 + atomic_inc_unchecked(&vcc->stats->rx_err);
32350 return;
32351 }
32352 if (skb_queue_len(&rpp->queue) > 1) {
32353 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32354 RXPRINTK("%s: Can't alloc RX skb.\n",
32355 card->name);
32356 recycle_rx_pool_skb(card, rpp);
32357 - atomic_inc(&vcc->stats->rx_err);
32358 + atomic_inc_unchecked(&vcc->stats->rx_err);
32359 return;
32360 }
32361 if (!atm_charge(vcc, skb->truesize)) {
32362 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32363 __net_timestamp(skb);
32364
32365 vcc->push(vcc, skb);
32366 - atomic_inc(&vcc->stats->rx);
32367 + atomic_inc_unchecked(&vcc->stats->rx);
32368
32369 return;
32370 }
32371 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32372 __net_timestamp(skb);
32373
32374 vcc->push(vcc, skb);
32375 - atomic_inc(&vcc->stats->rx);
32376 + atomic_inc_unchecked(&vcc->stats->rx);
32377
32378 if (skb->truesize > SAR_FB_SIZE_3)
32379 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32380 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32381 if (vcc->qos.aal != ATM_AAL0) {
32382 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32383 card->name, vpi, vci);
32384 - atomic_inc(&vcc->stats->rx_drop);
32385 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32386 goto drop;
32387 }
32388
32389 if ((sb = dev_alloc_skb(64)) == NULL) {
32390 printk("%s: Can't allocate buffers for AAL0.\n",
32391 card->name);
32392 - atomic_inc(&vcc->stats->rx_err);
32393 + atomic_inc_unchecked(&vcc->stats->rx_err);
32394 goto drop;
32395 }
32396
32397 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32398 ATM_SKB(sb)->vcc = vcc;
32399 __net_timestamp(sb);
32400 vcc->push(vcc, sb);
32401 - atomic_inc(&vcc->stats->rx);
32402 + atomic_inc_unchecked(&vcc->stats->rx);
32403
32404 drop:
32405 skb_pull(queue, 64);
32406 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32407
32408 if (vc == NULL) {
32409 printk("%s: NULL connection in send().\n", card->name);
32410 - atomic_inc(&vcc->stats->tx_err);
32411 + atomic_inc_unchecked(&vcc->stats->tx_err);
32412 dev_kfree_skb(skb);
32413 return -EINVAL;
32414 }
32415 if (!test_bit(VCF_TX, &vc->flags)) {
32416 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32417 - atomic_inc(&vcc->stats->tx_err);
32418 + atomic_inc_unchecked(&vcc->stats->tx_err);
32419 dev_kfree_skb(skb);
32420 return -EINVAL;
32421 }
32422 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32423 break;
32424 default:
32425 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32426 - atomic_inc(&vcc->stats->tx_err);
32427 + atomic_inc_unchecked(&vcc->stats->tx_err);
32428 dev_kfree_skb(skb);
32429 return -EINVAL;
32430 }
32431
32432 if (skb_shinfo(skb)->nr_frags != 0) {
32433 printk("%s: No scatter-gather yet.\n", card->name);
32434 - atomic_inc(&vcc->stats->tx_err);
32435 + atomic_inc_unchecked(&vcc->stats->tx_err);
32436 dev_kfree_skb(skb);
32437 return -EINVAL;
32438 }
32439 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32440
32441 err = queue_skb(card, vc, skb, oam);
32442 if (err) {
32443 - atomic_inc(&vcc->stats->tx_err);
32444 + atomic_inc_unchecked(&vcc->stats->tx_err);
32445 dev_kfree_skb(skb);
32446 return err;
32447 }
32448 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32449 skb = dev_alloc_skb(64);
32450 if (!skb) {
32451 printk("%s: Out of memory in send_oam().\n", card->name);
32452 - atomic_inc(&vcc->stats->tx_err);
32453 + atomic_inc_unchecked(&vcc->stats->tx_err);
32454 return -ENOMEM;
32455 }
32456 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32457 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32458 index 4217f29..88f547a 100644
32459 --- a/drivers/atm/iphase.c
32460 +++ b/drivers/atm/iphase.c
32461 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32462 status = (u_short) (buf_desc_ptr->desc_mode);
32463 if (status & (RX_CER | RX_PTE | RX_OFL))
32464 {
32465 - atomic_inc(&vcc->stats->rx_err);
32466 + atomic_inc_unchecked(&vcc->stats->rx_err);
32467 IF_ERR(printk("IA: bad packet, dropping it");)
32468 if (status & RX_CER) {
32469 IF_ERR(printk(" cause: packet CRC error\n");)
32470 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32471 len = dma_addr - buf_addr;
32472 if (len > iadev->rx_buf_sz) {
32473 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32474 - atomic_inc(&vcc->stats->rx_err);
32475 + atomic_inc_unchecked(&vcc->stats->rx_err);
32476 goto out_free_desc;
32477 }
32478
32479 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32480 ia_vcc = INPH_IA_VCC(vcc);
32481 if (ia_vcc == NULL)
32482 {
32483 - atomic_inc(&vcc->stats->rx_err);
32484 + atomic_inc_unchecked(&vcc->stats->rx_err);
32485 atm_return(vcc, skb->truesize);
32486 dev_kfree_skb_any(skb);
32487 goto INCR_DLE;
32488 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32489 if ((length > iadev->rx_buf_sz) || (length >
32490 (skb->len - sizeof(struct cpcs_trailer))))
32491 {
32492 - atomic_inc(&vcc->stats->rx_err);
32493 + atomic_inc_unchecked(&vcc->stats->rx_err);
32494 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32495 length, skb->len);)
32496 atm_return(vcc, skb->truesize);
32497 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32498
32499 IF_RX(printk("rx_dle_intr: skb push");)
32500 vcc->push(vcc,skb);
32501 - atomic_inc(&vcc->stats->rx);
32502 + atomic_inc_unchecked(&vcc->stats->rx);
32503 iadev->rx_pkt_cnt++;
32504 }
32505 INCR_DLE:
32506 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32507 {
32508 struct k_sonet_stats *stats;
32509 stats = &PRIV(_ia_dev[board])->sonet_stats;
32510 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32511 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32512 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32513 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32514 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32515 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32516 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32517 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32518 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32519 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32520 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32521 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32522 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32523 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32524 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32525 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32526 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32527 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32528 }
32529 ia_cmds.status = 0;
32530 break;
32531 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32532 if ((desc == 0) || (desc > iadev->num_tx_desc))
32533 {
32534 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32535 - atomic_inc(&vcc->stats->tx);
32536 + atomic_inc_unchecked(&vcc->stats->tx);
32537 if (vcc->pop)
32538 vcc->pop(vcc, skb);
32539 else
32540 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32541 ATM_DESC(skb) = vcc->vci;
32542 skb_queue_tail(&iadev->tx_dma_q, skb);
32543
32544 - atomic_inc(&vcc->stats->tx);
32545 + atomic_inc_unchecked(&vcc->stats->tx);
32546 iadev->tx_pkt_cnt++;
32547 /* Increment transaction counter */
32548 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32549
32550 #if 0
32551 /* add flow control logic */
32552 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32553 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32554 if (iavcc->vc_desc_cnt > 10) {
32555 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32556 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32557 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32558 index fa7d701..1e404c7 100644
32559 --- a/drivers/atm/lanai.c
32560 +++ b/drivers/atm/lanai.c
32561 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32562 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32563 lanai_endtx(lanai, lvcc);
32564 lanai_free_skb(lvcc->tx.atmvcc, skb);
32565 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32566 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32567 }
32568
32569 /* Try to fill the buffer - don't call unless there is backlog */
32570 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32571 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32572 __net_timestamp(skb);
32573 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32574 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32575 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32576 out:
32577 lvcc->rx.buf.ptr = end;
32578 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32579 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32580 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32581 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32582 lanai->stats.service_rxnotaal5++;
32583 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32584 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32585 return 0;
32586 }
32587 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32588 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32589 int bytes;
32590 read_unlock(&vcc_sklist_lock);
32591 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32592 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32593 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32594 lvcc->stats.x.aal5.service_trash++;
32595 bytes = (SERVICE_GET_END(s) * 16) -
32596 (((unsigned long) lvcc->rx.buf.ptr) -
32597 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32598 }
32599 if (s & SERVICE_STREAM) {
32600 read_unlock(&vcc_sklist_lock);
32601 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32602 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32603 lvcc->stats.x.aal5.service_stream++;
32604 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32605 "PDU on VCI %d!\n", lanai->number, vci);
32606 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32607 return 0;
32608 }
32609 DPRINTK("got rx crc error on vci %d\n", vci);
32610 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32611 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32612 lvcc->stats.x.aal5.service_rxcrc++;
32613 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32614 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32615 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32616 index 6587dc2..149833d 100644
32617 --- a/drivers/atm/nicstar.c
32618 +++ b/drivers/atm/nicstar.c
32619 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32620 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32621 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32622 card->index);
32623 - atomic_inc(&vcc->stats->tx_err);
32624 + atomic_inc_unchecked(&vcc->stats->tx_err);
32625 dev_kfree_skb_any(skb);
32626 return -EINVAL;
32627 }
32628 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32629 if (!vc->tx) {
32630 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32631 card->index);
32632 - atomic_inc(&vcc->stats->tx_err);
32633 + atomic_inc_unchecked(&vcc->stats->tx_err);
32634 dev_kfree_skb_any(skb);
32635 return -EINVAL;
32636 }
32637 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32638 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32639 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32640 card->index);
32641 - atomic_inc(&vcc->stats->tx_err);
32642 + atomic_inc_unchecked(&vcc->stats->tx_err);
32643 dev_kfree_skb_any(skb);
32644 return -EINVAL;
32645 }
32646
32647 if (skb_shinfo(skb)->nr_frags != 0) {
32648 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32649 - atomic_inc(&vcc->stats->tx_err);
32650 + atomic_inc_unchecked(&vcc->stats->tx_err);
32651 dev_kfree_skb_any(skb);
32652 return -EINVAL;
32653 }
32654 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32655 }
32656
32657 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32658 - atomic_inc(&vcc->stats->tx_err);
32659 + atomic_inc_unchecked(&vcc->stats->tx_err);
32660 dev_kfree_skb_any(skb);
32661 return -EIO;
32662 }
32663 - atomic_inc(&vcc->stats->tx);
32664 + atomic_inc_unchecked(&vcc->stats->tx);
32665
32666 return 0;
32667 }
32668 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32669 printk
32670 ("nicstar%d: Can't allocate buffers for aal0.\n",
32671 card->index);
32672 - atomic_add(i, &vcc->stats->rx_drop);
32673 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32674 break;
32675 }
32676 if (!atm_charge(vcc, sb->truesize)) {
32677 RXPRINTK
32678 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32679 card->index);
32680 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32681 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32682 dev_kfree_skb_any(sb);
32683 break;
32684 }
32685 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32686 ATM_SKB(sb)->vcc = vcc;
32687 __net_timestamp(sb);
32688 vcc->push(vcc, sb);
32689 - atomic_inc(&vcc->stats->rx);
32690 + atomic_inc_unchecked(&vcc->stats->rx);
32691 cell += ATM_CELL_PAYLOAD;
32692 }
32693
32694 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32695 if (iovb == NULL) {
32696 printk("nicstar%d: Out of iovec buffers.\n",
32697 card->index);
32698 - atomic_inc(&vcc->stats->rx_drop);
32699 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32700 recycle_rx_buf(card, skb);
32701 return;
32702 }
32703 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32704 small or large buffer itself. */
32705 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32706 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32707 - atomic_inc(&vcc->stats->rx_err);
32708 + atomic_inc_unchecked(&vcc->stats->rx_err);
32709 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32710 NS_MAX_IOVECS);
32711 NS_PRV_IOVCNT(iovb) = 0;
32712 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32713 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32714 card->index);
32715 which_list(card, skb);
32716 - atomic_inc(&vcc->stats->rx_err);
32717 + atomic_inc_unchecked(&vcc->stats->rx_err);
32718 recycle_rx_buf(card, skb);
32719 vc->rx_iov = NULL;
32720 recycle_iov_buf(card, iovb);
32721 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32722 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32723 card->index);
32724 which_list(card, skb);
32725 - atomic_inc(&vcc->stats->rx_err);
32726 + atomic_inc_unchecked(&vcc->stats->rx_err);
32727 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32728 NS_PRV_IOVCNT(iovb));
32729 vc->rx_iov = NULL;
32730 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32731 printk(" - PDU size mismatch.\n");
32732 else
32733 printk(".\n");
32734 - atomic_inc(&vcc->stats->rx_err);
32735 + atomic_inc_unchecked(&vcc->stats->rx_err);
32736 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32737 NS_PRV_IOVCNT(iovb));
32738 vc->rx_iov = NULL;
32739 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32740 /* skb points to a small buffer */
32741 if (!atm_charge(vcc, skb->truesize)) {
32742 push_rxbufs(card, skb);
32743 - atomic_inc(&vcc->stats->rx_drop);
32744 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32745 } else {
32746 skb_put(skb, len);
32747 dequeue_sm_buf(card, skb);
32748 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32749 ATM_SKB(skb)->vcc = vcc;
32750 __net_timestamp(skb);
32751 vcc->push(vcc, skb);
32752 - atomic_inc(&vcc->stats->rx);
32753 + atomic_inc_unchecked(&vcc->stats->rx);
32754 }
32755 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32756 struct sk_buff *sb;
32757 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32758 if (len <= NS_SMBUFSIZE) {
32759 if (!atm_charge(vcc, sb->truesize)) {
32760 push_rxbufs(card, sb);
32761 - atomic_inc(&vcc->stats->rx_drop);
32762 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32763 } else {
32764 skb_put(sb, len);
32765 dequeue_sm_buf(card, sb);
32766 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32767 ATM_SKB(sb)->vcc = vcc;
32768 __net_timestamp(sb);
32769 vcc->push(vcc, sb);
32770 - atomic_inc(&vcc->stats->rx);
32771 + atomic_inc_unchecked(&vcc->stats->rx);
32772 }
32773
32774 push_rxbufs(card, skb);
32775 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32776
32777 if (!atm_charge(vcc, skb->truesize)) {
32778 push_rxbufs(card, skb);
32779 - atomic_inc(&vcc->stats->rx_drop);
32780 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32781 } else {
32782 dequeue_lg_buf(card, skb);
32783 #ifdef NS_USE_DESTRUCTORS
32784 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32785 ATM_SKB(skb)->vcc = vcc;
32786 __net_timestamp(skb);
32787 vcc->push(vcc, skb);
32788 - atomic_inc(&vcc->stats->rx);
32789 + atomic_inc_unchecked(&vcc->stats->rx);
32790 }
32791
32792 push_rxbufs(card, sb);
32793 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32794 printk
32795 ("nicstar%d: Out of huge buffers.\n",
32796 card->index);
32797 - atomic_inc(&vcc->stats->rx_drop);
32798 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32799 recycle_iovec_rx_bufs(card,
32800 (struct iovec *)
32801 iovb->data,
32802 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32803 card->hbpool.count++;
32804 } else
32805 dev_kfree_skb_any(hb);
32806 - atomic_inc(&vcc->stats->rx_drop);
32807 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32808 } else {
32809 /* Copy the small buffer to the huge buffer */
32810 sb = (struct sk_buff *)iov->iov_base;
32811 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32812 #endif /* NS_USE_DESTRUCTORS */
32813 __net_timestamp(hb);
32814 vcc->push(vcc, hb);
32815 - atomic_inc(&vcc->stats->rx);
32816 + atomic_inc_unchecked(&vcc->stats->rx);
32817 }
32818 }
32819
32820 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32821 index 32784d1..4a8434a 100644
32822 --- a/drivers/atm/solos-pci.c
32823 +++ b/drivers/atm/solos-pci.c
32824 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32825 }
32826 atm_charge(vcc, skb->truesize);
32827 vcc->push(vcc, skb);
32828 - atomic_inc(&vcc->stats->rx);
32829 + atomic_inc_unchecked(&vcc->stats->rx);
32830 break;
32831
32832 case PKT_STATUS:
32833 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
32834 vcc = SKB_CB(oldskb)->vcc;
32835
32836 if (vcc) {
32837 - atomic_inc(&vcc->stats->tx);
32838 + atomic_inc_unchecked(&vcc->stats->tx);
32839 solos_pop(vcc, oldskb);
32840 } else {
32841 dev_kfree_skb_irq(oldskb);
32842 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
32843 index 0215934..ce9f5b1 100644
32844 --- a/drivers/atm/suni.c
32845 +++ b/drivers/atm/suni.c
32846 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
32847
32848
32849 #define ADD_LIMITED(s,v) \
32850 - atomic_add((v),&stats->s); \
32851 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
32852 + atomic_add_unchecked((v),&stats->s); \
32853 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
32854
32855
32856 static void suni_hz(unsigned long from_timer)
32857 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
32858 index 5120a96..e2572bd 100644
32859 --- a/drivers/atm/uPD98402.c
32860 +++ b/drivers/atm/uPD98402.c
32861 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
32862 struct sonet_stats tmp;
32863 int error = 0;
32864
32865 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32866 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32867 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
32868 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
32869 if (zero && !error) {
32870 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
32871
32872
32873 #define ADD_LIMITED(s,v) \
32874 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
32875 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
32876 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32877 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
32878 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
32879 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32880
32881
32882 static void stat_event(struct atm_dev *dev)
32883 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
32884 if (reason & uPD98402_INT_PFM) stat_event(dev);
32885 if (reason & uPD98402_INT_PCO) {
32886 (void) GET(PCOCR); /* clear interrupt cause */
32887 - atomic_add(GET(HECCT),
32888 + atomic_add_unchecked(GET(HECCT),
32889 &PRIV(dev)->sonet_stats.uncorr_hcs);
32890 }
32891 if ((reason & uPD98402_INT_RFO) &&
32892 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
32893 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
32894 uPD98402_INT_LOS),PIMR); /* enable them */
32895 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
32896 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32897 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
32898 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
32899 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32900 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
32901 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
32902 return 0;
32903 }
32904
32905 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
32906 index 969c3c2..9b72956 100644
32907 --- a/drivers/atm/zatm.c
32908 +++ b/drivers/atm/zatm.c
32909 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32910 }
32911 if (!size) {
32912 dev_kfree_skb_irq(skb);
32913 - if (vcc) atomic_inc(&vcc->stats->rx_err);
32914 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
32915 continue;
32916 }
32917 if (!atm_charge(vcc,skb->truesize)) {
32918 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32919 skb->len = size;
32920 ATM_SKB(skb)->vcc = vcc;
32921 vcc->push(vcc,skb);
32922 - atomic_inc(&vcc->stats->rx);
32923 + atomic_inc_unchecked(&vcc->stats->rx);
32924 }
32925 zout(pos & 0xffff,MTA(mbx));
32926 #if 0 /* probably a stupid idea */
32927 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
32928 skb_queue_head(&zatm_vcc->backlog,skb);
32929 break;
32930 }
32931 - atomic_inc(&vcc->stats->tx);
32932 + atomic_inc_unchecked(&vcc->stats->tx);
32933 wake_up(&zatm_vcc->tx_wait);
32934 }
32935
32936 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
32937 index 519865b..e540db3 100644
32938 --- a/drivers/base/bus.c
32939 +++ b/drivers/base/bus.c
32940 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
32941 return -EINVAL;
32942
32943 mutex_lock(&subsys->p->mutex);
32944 - list_add_tail(&sif->node, &subsys->p->interfaces);
32945 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
32946 if (sif->add_dev) {
32947 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32948 while ((dev = subsys_dev_iter_next(&iter)))
32949 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
32950 subsys = sif->subsys;
32951
32952 mutex_lock(&subsys->p->mutex);
32953 - list_del_init(&sif->node);
32954 + pax_list_del_init((struct list_head *)&sif->node);
32955 if (sif->remove_dev) {
32956 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32957 while ((dev = subsys_dev_iter_next(&iter)))
32958 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
32959 index 01fc5b0..917801f 100644
32960 --- a/drivers/base/devtmpfs.c
32961 +++ b/drivers/base/devtmpfs.c
32962 @@ -348,7 +348,7 @@ int devtmpfs_mount(const char *mntdir)
32963 if (!thread)
32964 return 0;
32965
32966 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
32967 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
32968 if (err)
32969 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
32970 else
32971 @@ -373,11 +373,11 @@ static int devtmpfsd(void *p)
32972 *err = sys_unshare(CLONE_NEWNS);
32973 if (*err)
32974 goto out;
32975 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
32976 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
32977 if (*err)
32978 goto out;
32979 - sys_chdir("/.."); /* will traverse into overmounted root */
32980 - sys_chroot(".");
32981 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
32982 + sys_chroot((char __force_user *)".");
32983 complete(&setup_done);
32984 while (1) {
32985 spin_lock(&req_lock);
32986 diff --git a/drivers/base/node.c b/drivers/base/node.c
32987 index fac124a..66bd4ab 100644
32988 --- a/drivers/base/node.c
32989 +++ b/drivers/base/node.c
32990 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
32991 struct node_attr {
32992 struct device_attribute attr;
32993 enum node_states state;
32994 -};
32995 +} __do_const;
32996
32997 static ssize_t show_node_state(struct device *dev,
32998 struct device_attribute *attr, char *buf)
32999 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33000 index 9a6b05a..2fc8fb9 100644
33001 --- a/drivers/base/power/domain.c
33002 +++ b/drivers/base/power/domain.c
33003 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33004 {
33005 struct cpuidle_driver *cpuidle_drv;
33006 struct gpd_cpu_data *cpu_data;
33007 - struct cpuidle_state *idle_state;
33008 + cpuidle_state_no_const *idle_state;
33009 int ret = 0;
33010
33011 if (IS_ERR_OR_NULL(genpd) || state < 0)
33012 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33013 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33014 {
33015 struct gpd_cpu_data *cpu_data;
33016 - struct cpuidle_state *idle_state;
33017 + cpuidle_state_no_const *idle_state;
33018 int ret = 0;
33019
33020 if (IS_ERR_OR_NULL(genpd))
33021 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33022 index 79715e7..df06b3b 100644
33023 --- a/drivers/base/power/wakeup.c
33024 +++ b/drivers/base/power/wakeup.c
33025 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33026 * They need to be modified together atomically, so it's better to use one
33027 * atomic variable to hold them both.
33028 */
33029 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33030 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33031
33032 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33033 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33034
33035 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33036 {
33037 - unsigned int comb = atomic_read(&combined_event_count);
33038 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33039
33040 *cnt = (comb >> IN_PROGRESS_BITS);
33041 *inpr = comb & MAX_IN_PROGRESS;
33042 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33043 ws->start_prevent_time = ws->last_time;
33044
33045 /* Increment the counter of events in progress. */
33046 - cec = atomic_inc_return(&combined_event_count);
33047 + cec = atomic_inc_return_unchecked(&combined_event_count);
33048
33049 trace_wakeup_source_activate(ws->name, cec);
33050 }
33051 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33052 * Increment the counter of registered wakeup events and decrement the
33053 * couter of wakeup events in progress simultaneously.
33054 */
33055 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33056 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33057 trace_wakeup_source_deactivate(ws->name, cec);
33058
33059 split_counters(&cnt, &inpr);
33060 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33061 index e8d11b6..7b1b36f 100644
33062 --- a/drivers/base/syscore.c
33063 +++ b/drivers/base/syscore.c
33064 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33065 void register_syscore_ops(struct syscore_ops *ops)
33066 {
33067 mutex_lock(&syscore_ops_lock);
33068 - list_add_tail(&ops->node, &syscore_ops_list);
33069 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33070 mutex_unlock(&syscore_ops_lock);
33071 }
33072 EXPORT_SYMBOL_GPL(register_syscore_ops);
33073 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33074 void unregister_syscore_ops(struct syscore_ops *ops)
33075 {
33076 mutex_lock(&syscore_ops_lock);
33077 - list_del(&ops->node);
33078 + pax_list_del((struct list_head *)&ops->node);
33079 mutex_unlock(&syscore_ops_lock);
33080 }
33081 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33082 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33083 index 1c1b8e5..b7fc681 100644
33084 --- a/drivers/block/cciss.c
33085 +++ b/drivers/block/cciss.c
33086 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33087 int err;
33088 u32 cp;
33089
33090 + memset(&arg64, 0, sizeof(arg64));
33091 +
33092 err = 0;
33093 err |=
33094 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33095 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33096 while (!list_empty(&h->reqQ)) {
33097 c = list_entry(h->reqQ.next, CommandList_struct, list);
33098 /* can't do anything if fifo is full */
33099 - if ((h->access.fifo_full(h))) {
33100 + if ((h->access->fifo_full(h))) {
33101 dev_warn(&h->pdev->dev, "fifo full\n");
33102 break;
33103 }
33104 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33105 h->Qdepth--;
33106
33107 /* Tell the controller execute command */
33108 - h->access.submit_command(h, c);
33109 + h->access->submit_command(h, c);
33110
33111 /* Put job onto the completed Q */
33112 addQ(&h->cmpQ, c);
33113 @@ -3441,17 +3443,17 @@ startio:
33114
33115 static inline unsigned long get_next_completion(ctlr_info_t *h)
33116 {
33117 - return h->access.command_completed(h);
33118 + return h->access->command_completed(h);
33119 }
33120
33121 static inline int interrupt_pending(ctlr_info_t *h)
33122 {
33123 - return h->access.intr_pending(h);
33124 + return h->access->intr_pending(h);
33125 }
33126
33127 static inline long interrupt_not_for_us(ctlr_info_t *h)
33128 {
33129 - return ((h->access.intr_pending(h) == 0) ||
33130 + return ((h->access->intr_pending(h) == 0) ||
33131 (h->interrupts_enabled == 0));
33132 }
33133
33134 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33135 u32 a;
33136
33137 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33138 - return h->access.command_completed(h);
33139 + return h->access->command_completed(h);
33140
33141 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33142 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33143 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33144 trans_support & CFGTBL_Trans_use_short_tags);
33145
33146 /* Change the access methods to the performant access methods */
33147 - h->access = SA5_performant_access;
33148 + h->access = &SA5_performant_access;
33149 h->transMethod = CFGTBL_Trans_Performant;
33150
33151 return;
33152 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33153 if (prod_index < 0)
33154 return -ENODEV;
33155 h->product_name = products[prod_index].product_name;
33156 - h->access = *(products[prod_index].access);
33157 + h->access = products[prod_index].access;
33158
33159 if (cciss_board_disabled(h)) {
33160 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33161 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33162 }
33163
33164 /* make sure the board interrupts are off */
33165 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33166 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33167 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33168 if (rc)
33169 goto clean2;
33170 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33171 * fake ones to scoop up any residual completions.
33172 */
33173 spin_lock_irqsave(&h->lock, flags);
33174 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33175 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33176 spin_unlock_irqrestore(&h->lock, flags);
33177 free_irq(h->intr[h->intr_mode], h);
33178 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33179 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33180 dev_info(&h->pdev->dev, "Board READY.\n");
33181 dev_info(&h->pdev->dev,
33182 "Waiting for stale completions to drain.\n");
33183 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33184 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33185 msleep(10000);
33186 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33187 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33188
33189 rc = controller_reset_failed(h->cfgtable);
33190 if (rc)
33191 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33192 cciss_scsi_setup(h);
33193
33194 /* Turn the interrupts on so we can service requests */
33195 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33196 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33197
33198 /* Get the firmware version */
33199 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33200 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33201 kfree(flush_buf);
33202 if (return_code != IO_OK)
33203 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33204 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33205 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33206 free_irq(h->intr[h->intr_mode], h);
33207 }
33208
33209 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33210 index 7fda30e..eb5dfe0 100644
33211 --- a/drivers/block/cciss.h
33212 +++ b/drivers/block/cciss.h
33213 @@ -101,7 +101,7 @@ struct ctlr_info
33214 /* information about each logical volume */
33215 drive_info_struct *drv[CISS_MAX_LUN];
33216
33217 - struct access_method access;
33218 + struct access_method *access;
33219
33220 /* queue and queue Info */
33221 struct list_head reqQ;
33222 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33223 index 3f08713..56a586a 100644
33224 --- a/drivers/block/cpqarray.c
33225 +++ b/drivers/block/cpqarray.c
33226 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33227 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33228 goto Enomem4;
33229 }
33230 - hba[i]->access.set_intr_mask(hba[i], 0);
33231 + hba[i]->access->set_intr_mask(hba[i], 0);
33232 if (request_irq(hba[i]->intr, do_ida_intr,
33233 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33234 {
33235 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33236 add_timer(&hba[i]->timer);
33237
33238 /* Enable IRQ now that spinlock and rate limit timer are set up */
33239 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33240 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33241
33242 for(j=0; j<NWD; j++) {
33243 struct gendisk *disk = ida_gendisk[i][j];
33244 @@ -694,7 +694,7 @@ DBGINFO(
33245 for(i=0; i<NR_PRODUCTS; i++) {
33246 if (board_id == products[i].board_id) {
33247 c->product_name = products[i].product_name;
33248 - c->access = *(products[i].access);
33249 + c->access = products[i].access;
33250 break;
33251 }
33252 }
33253 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33254 hba[ctlr]->intr = intr;
33255 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33256 hba[ctlr]->product_name = products[j].product_name;
33257 - hba[ctlr]->access = *(products[j].access);
33258 + hba[ctlr]->access = products[j].access;
33259 hba[ctlr]->ctlr = ctlr;
33260 hba[ctlr]->board_id = board_id;
33261 hba[ctlr]->pci_dev = NULL; /* not PCI */
33262 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33263
33264 while((c = h->reqQ) != NULL) {
33265 /* Can't do anything if we're busy */
33266 - if (h->access.fifo_full(h) == 0)
33267 + if (h->access->fifo_full(h) == 0)
33268 return;
33269
33270 /* Get the first entry from the request Q */
33271 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33272 h->Qdepth--;
33273
33274 /* Tell the controller to do our bidding */
33275 - h->access.submit_command(h, c);
33276 + h->access->submit_command(h, c);
33277
33278 /* Get onto the completion Q */
33279 addQ(&h->cmpQ, c);
33280 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33281 unsigned long flags;
33282 __u32 a,a1;
33283
33284 - istat = h->access.intr_pending(h);
33285 + istat = h->access->intr_pending(h);
33286 /* Is this interrupt for us? */
33287 if (istat == 0)
33288 return IRQ_NONE;
33289 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33290 */
33291 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33292 if (istat & FIFO_NOT_EMPTY) {
33293 - while((a = h->access.command_completed(h))) {
33294 + while((a = h->access->command_completed(h))) {
33295 a1 = a; a &= ~3;
33296 if ((c = h->cmpQ) == NULL)
33297 {
33298 @@ -1449,11 +1449,11 @@ static int sendcmd(
33299 /*
33300 * Disable interrupt
33301 */
33302 - info_p->access.set_intr_mask(info_p, 0);
33303 + info_p->access->set_intr_mask(info_p, 0);
33304 /* Make sure there is room in the command FIFO */
33305 /* Actually it should be completely empty at this time. */
33306 for (i = 200000; i > 0; i--) {
33307 - temp = info_p->access.fifo_full(info_p);
33308 + temp = info_p->access->fifo_full(info_p);
33309 if (temp != 0) {
33310 break;
33311 }
33312 @@ -1466,7 +1466,7 @@ DBG(
33313 /*
33314 * Send the cmd
33315 */
33316 - info_p->access.submit_command(info_p, c);
33317 + info_p->access->submit_command(info_p, c);
33318 complete = pollcomplete(ctlr);
33319
33320 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33321 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33322 * we check the new geometry. Then turn interrupts back on when
33323 * we're done.
33324 */
33325 - host->access.set_intr_mask(host, 0);
33326 + host->access->set_intr_mask(host, 0);
33327 getgeometry(ctlr);
33328 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33329 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33330
33331 for(i=0; i<NWD; i++) {
33332 struct gendisk *disk = ida_gendisk[ctlr][i];
33333 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33334 /* Wait (up to 2 seconds) for a command to complete */
33335
33336 for (i = 200000; i > 0; i--) {
33337 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33338 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33339 if (done == 0) {
33340 udelay(10); /* a short fixed delay */
33341 } else
33342 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33343 index be73e9d..7fbf140 100644
33344 --- a/drivers/block/cpqarray.h
33345 +++ b/drivers/block/cpqarray.h
33346 @@ -99,7 +99,7 @@ struct ctlr_info {
33347 drv_info_t drv[NWD];
33348 struct proc_dir_entry *proc;
33349
33350 - struct access_method access;
33351 + struct access_method *access;
33352
33353 cmdlist_t *reqQ;
33354 cmdlist_t *cmpQ;
33355 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33356 index 6b51afa..17e1191 100644
33357 --- a/drivers/block/drbd/drbd_int.h
33358 +++ b/drivers/block/drbd/drbd_int.h
33359 @@ -582,7 +582,7 @@ struct drbd_epoch {
33360 struct drbd_tconn *tconn;
33361 struct list_head list;
33362 unsigned int barrier_nr;
33363 - atomic_t epoch_size; /* increased on every request added. */
33364 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33365 atomic_t active; /* increased on every req. added, and dec on every finished. */
33366 unsigned long flags;
33367 };
33368 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33369 int al_tr_cycle;
33370 int al_tr_pos; /* position of the next transaction in the journal */
33371 wait_queue_head_t seq_wait;
33372 - atomic_t packet_seq;
33373 + atomic_unchecked_t packet_seq;
33374 unsigned int peer_seq;
33375 spinlock_t peer_seq_lock;
33376 unsigned int minor;
33377 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33378 char __user *uoptval;
33379 int err;
33380
33381 - uoptval = (char __user __force *)optval;
33382 + uoptval = (char __force_user *)optval;
33383
33384 set_fs(KERNEL_DS);
33385 if (level == SOL_SOCKET)
33386 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33387 index 54d03d4..332f311 100644
33388 --- a/drivers/block/drbd/drbd_main.c
33389 +++ b/drivers/block/drbd/drbd_main.c
33390 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33391 p->sector = sector;
33392 p->block_id = block_id;
33393 p->blksize = blksize;
33394 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33395 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33396 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33397 }
33398
33399 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33400 return -EIO;
33401 p->sector = cpu_to_be64(req->i.sector);
33402 p->block_id = (unsigned long)req;
33403 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33404 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33405 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33406 if (mdev->state.conn >= C_SYNC_SOURCE &&
33407 mdev->state.conn <= C_PAUSED_SYNC_T)
33408 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33409 {
33410 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33411
33412 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33413 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33414 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33415 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33416 kfree(tconn->current_epoch);
33417
33418 idr_destroy(&tconn->volumes);
33419 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33420 index 2f5fffd..b22a1ae 100644
33421 --- a/drivers/block/drbd/drbd_receiver.c
33422 +++ b/drivers/block/drbd/drbd_receiver.c
33423 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33424 {
33425 int err;
33426
33427 - atomic_set(&mdev->packet_seq, 0);
33428 + atomic_set_unchecked(&mdev->packet_seq, 0);
33429 mdev->peer_seq = 0;
33430
33431 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33432 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33433 do {
33434 next_epoch = NULL;
33435
33436 - epoch_size = atomic_read(&epoch->epoch_size);
33437 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33438
33439 switch (ev & ~EV_CLEANUP) {
33440 case EV_PUT:
33441 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33442 rv = FE_DESTROYED;
33443 } else {
33444 epoch->flags = 0;
33445 - atomic_set(&epoch->epoch_size, 0);
33446 + atomic_set_unchecked(&epoch->epoch_size, 0);
33447 /* atomic_set(&epoch->active, 0); is already zero */
33448 if (rv == FE_STILL_LIVE)
33449 rv = FE_RECYCLED;
33450 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33451 conn_wait_active_ee_empty(tconn);
33452 drbd_flush(tconn);
33453
33454 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33455 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33456 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33457 if (epoch)
33458 break;
33459 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33460 }
33461
33462 epoch->flags = 0;
33463 - atomic_set(&epoch->epoch_size, 0);
33464 + atomic_set_unchecked(&epoch->epoch_size, 0);
33465 atomic_set(&epoch->active, 0);
33466
33467 spin_lock(&tconn->epoch_lock);
33468 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33469 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33470 list_add(&epoch->list, &tconn->current_epoch->list);
33471 tconn->current_epoch = epoch;
33472 tconn->epochs++;
33473 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33474
33475 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33476 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33477 - atomic_inc(&tconn->current_epoch->epoch_size);
33478 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33479 err2 = drbd_drain_block(mdev, pi->size);
33480 if (!err)
33481 err = err2;
33482 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33483
33484 spin_lock(&tconn->epoch_lock);
33485 peer_req->epoch = tconn->current_epoch;
33486 - atomic_inc(&peer_req->epoch->epoch_size);
33487 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33488 atomic_inc(&peer_req->epoch->active);
33489 spin_unlock(&tconn->epoch_lock);
33490
33491 @@ -4345,7 +4345,7 @@ struct data_cmd {
33492 int expect_payload;
33493 size_t pkt_size;
33494 int (*fn)(struct drbd_tconn *, struct packet_info *);
33495 -};
33496 +} __do_const;
33497
33498 static struct data_cmd drbd_cmd_handler[] = {
33499 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33500 @@ -4465,7 +4465,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33501 if (!list_empty(&tconn->current_epoch->list))
33502 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33503 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33504 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33505 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33506 tconn->send.seen_any_write_yet = false;
33507
33508 conn_info(tconn, "Connection closed\n");
33509 @@ -5221,7 +5221,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33510 struct asender_cmd {
33511 size_t pkt_size;
33512 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33513 -};
33514 +} __do_const;
33515
33516 static struct asender_cmd asender_tbl[] = {
33517 [P_PING] = { 0, got_Ping },
33518 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33519 index dfe7583..83768bb 100644
33520 --- a/drivers/block/loop.c
33521 +++ b/drivers/block/loop.c
33522 @@ -231,7 +231,7 @@ static int __do_lo_send_write(struct file *file,
33523 mm_segment_t old_fs = get_fs();
33524
33525 set_fs(get_ds());
33526 - bw = file->f_op->write(file, buf, len, &pos);
33527 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33528 set_fs(old_fs);
33529 if (likely(bw == len))
33530 return 0;
33531 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33532 index 2e7de7a..ed86dc0 100644
33533 --- a/drivers/block/pktcdvd.c
33534 +++ b/drivers/block/pktcdvd.c
33535 @@ -83,7 +83,7 @@
33536
33537 #define MAX_SPEED 0xffff
33538
33539 -#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
33540 +#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1UL))
33541
33542 static DEFINE_MUTEX(pktcdvd_mutex);
33543 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33544 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33545 index d620b44..587561e 100644
33546 --- a/drivers/cdrom/cdrom.c
33547 +++ b/drivers/cdrom/cdrom.c
33548 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33549 ENSURE(reset, CDC_RESET);
33550 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33551 cdi->mc_flags = 0;
33552 - cdo->n_minors = 0;
33553 cdi->options = CDO_USE_FFLAGS;
33554
33555 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33556 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33557 else
33558 cdi->cdda_method = CDDA_OLD;
33559
33560 - if (!cdo->generic_packet)
33561 - cdo->generic_packet = cdrom_dummy_generic_packet;
33562 + if (!cdo->generic_packet) {
33563 + pax_open_kernel();
33564 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33565 + pax_close_kernel();
33566 + }
33567
33568 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33569 mutex_lock(&cdrom_mutex);
33570 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33571 if (cdi->exit)
33572 cdi->exit(cdi);
33573
33574 - cdi->ops->n_minors--;
33575 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33576 }
33577
33578 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33579 index d59cdcb..11afddf 100644
33580 --- a/drivers/cdrom/gdrom.c
33581 +++ b/drivers/cdrom/gdrom.c
33582 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33583 .audio_ioctl = gdrom_audio_ioctl,
33584 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33585 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33586 - .n_minors = 1,
33587 };
33588
33589 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33590 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33591 index 3bb6fa3..34013fb 100644
33592 --- a/drivers/char/Kconfig
33593 +++ b/drivers/char/Kconfig
33594 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33595
33596 config DEVKMEM
33597 bool "/dev/kmem virtual device support"
33598 - default y
33599 + default n
33600 + depends on !GRKERNSEC_KMEM
33601 help
33602 Say Y here if you want to support the /dev/kmem device. The
33603 /dev/kmem device is rarely used, but can be used for certain
33604 @@ -582,6 +583,7 @@ config DEVPORT
33605 bool
33606 depends on !M68K
33607 depends on ISA || PCI
33608 + depends on !GRKERNSEC_KMEM
33609 default y
33610
33611 source "drivers/s390/char/Kconfig"
33612 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
33613 index a48e05b..6bac831 100644
33614 --- a/drivers/char/agp/compat_ioctl.c
33615 +++ b/drivers/char/agp/compat_ioctl.c
33616 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
33617 return -ENOMEM;
33618 }
33619
33620 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
33621 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
33622 sizeof(*usegment) * ureserve.seg_count)) {
33623 kfree(usegment);
33624 kfree(ksegment);
33625 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33626 index 2e04433..771f2cc 100644
33627 --- a/drivers/char/agp/frontend.c
33628 +++ b/drivers/char/agp/frontend.c
33629 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33630 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33631 return -EFAULT;
33632
33633 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33634 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33635 return -EFAULT;
33636
33637 client = agp_find_client_by_pid(reserve.pid);
33638 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33639 if (segment == NULL)
33640 return -ENOMEM;
33641
33642 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
33643 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
33644 sizeof(struct agp_segment) * reserve.seg_count)) {
33645 kfree(segment);
33646 return -EFAULT;
33647 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33648 index 21cb980..f15107c 100644
33649 --- a/drivers/char/genrtc.c
33650 +++ b/drivers/char/genrtc.c
33651 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33652 switch (cmd) {
33653
33654 case RTC_PLL_GET:
33655 + memset(&pll, 0, sizeof(pll));
33656 if (get_rtc_pll(&pll))
33657 return -EINVAL;
33658 else
33659 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33660 index d784650..e8bfd69 100644
33661 --- a/drivers/char/hpet.c
33662 +++ b/drivers/char/hpet.c
33663 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33664 }
33665
33666 static int
33667 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33668 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33669 struct hpet_info *info)
33670 {
33671 struct hpet_timer __iomem *timer;
33672 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33673 index 053201b0..8335cce 100644
33674 --- a/drivers/char/ipmi/ipmi_msghandler.c
33675 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33676 @@ -420,7 +420,7 @@ struct ipmi_smi {
33677 struct proc_dir_entry *proc_dir;
33678 char proc_dir_name[10];
33679
33680 - atomic_t stats[IPMI_NUM_STATS];
33681 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33682
33683 /*
33684 * run_to_completion duplicate of smb_info, smi_info
33685 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33686
33687
33688 #define ipmi_inc_stat(intf, stat) \
33689 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33690 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33691 #define ipmi_get_stat(intf, stat) \
33692 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33693 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33694
33695 static int is_lan_addr(struct ipmi_addr *addr)
33696 {
33697 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33698 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33699 init_waitqueue_head(&intf->waitq);
33700 for (i = 0; i < IPMI_NUM_STATS; i++)
33701 - atomic_set(&intf->stats[i], 0);
33702 + atomic_set_unchecked(&intf->stats[i], 0);
33703
33704 intf->proc_dir = NULL;
33705
33706 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33707 index 0ac9b45..6179fb5 100644
33708 --- a/drivers/char/ipmi/ipmi_si_intf.c
33709 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33710 @@ -275,7 +275,7 @@ struct smi_info {
33711 unsigned char slave_addr;
33712
33713 /* Counters and things for the proc filesystem. */
33714 - atomic_t stats[SI_NUM_STATS];
33715 + atomic_unchecked_t stats[SI_NUM_STATS];
33716
33717 struct task_struct *thread;
33718
33719 @@ -284,9 +284,9 @@ struct smi_info {
33720 };
33721
33722 #define smi_inc_stat(smi, stat) \
33723 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33724 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33725 #define smi_get_stat(smi, stat) \
33726 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33727 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33728
33729 #define SI_MAX_PARMS 4
33730
33731 @@ -3254,7 +3254,7 @@ static int try_smi_init(struct smi_info *new_smi)
33732 atomic_set(&new_smi->req_events, 0);
33733 new_smi->run_to_completion = 0;
33734 for (i = 0; i < SI_NUM_STATS; i++)
33735 - atomic_set(&new_smi->stats[i], 0);
33736 + atomic_set_unchecked(&new_smi->stats[i], 0);
33737
33738 new_smi->interrupt_disabled = 1;
33739 atomic_set(&new_smi->stop_operation, 0);
33740 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33741 index 2c644af..d4d7f17 100644
33742 --- a/drivers/char/mem.c
33743 +++ b/drivers/char/mem.c
33744 @@ -18,6 +18,7 @@
33745 #include <linux/raw.h>
33746 #include <linux/tty.h>
33747 #include <linux/capability.h>
33748 +#include <linux/security.h>
33749 #include <linux/ptrace.h>
33750 #include <linux/device.h>
33751 #include <linux/highmem.h>
33752 @@ -37,6 +38,10 @@
33753
33754 #define DEVPORT_MINOR 4
33755
33756 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33757 +extern const struct file_operations grsec_fops;
33758 +#endif
33759 +
33760 static inline unsigned long size_inside_page(unsigned long start,
33761 unsigned long size)
33762 {
33763 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33764
33765 while (cursor < to) {
33766 if (!devmem_is_allowed(pfn)) {
33767 +#ifdef CONFIG_GRKERNSEC_KMEM
33768 + gr_handle_mem_readwrite(from, to);
33769 +#else
33770 printk(KERN_INFO
33771 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
33772 current->comm, from, to);
33773 +#endif
33774 return 0;
33775 }
33776 cursor += PAGE_SIZE;
33777 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33778 }
33779 return 1;
33780 }
33781 +#elif defined(CONFIG_GRKERNSEC_KMEM)
33782 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33783 +{
33784 + return 0;
33785 +}
33786 #else
33787 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33788 {
33789 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33790
33791 while (count > 0) {
33792 unsigned long remaining;
33793 + char *temp;
33794
33795 sz = size_inside_page(p, count);
33796
33797 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33798 if (!ptr)
33799 return -EFAULT;
33800
33801 - remaining = copy_to_user(buf, ptr, sz);
33802 +#ifdef CONFIG_PAX_USERCOPY
33803 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33804 + if (!temp) {
33805 + unxlate_dev_mem_ptr(p, ptr);
33806 + return -ENOMEM;
33807 + }
33808 + memcpy(temp, ptr, sz);
33809 +#else
33810 + temp = ptr;
33811 +#endif
33812 +
33813 + remaining = copy_to_user(buf, temp, sz);
33814 +
33815 +#ifdef CONFIG_PAX_USERCOPY
33816 + kfree(temp);
33817 +#endif
33818 +
33819 unxlate_dev_mem_ptr(p, ptr);
33820 if (remaining)
33821 return -EFAULT;
33822 @@ -378,7 +409,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
33823 else
33824 csize = count;
33825
33826 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
33827 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
33828 if (rc < 0)
33829 return rc;
33830 buf += csize;
33831 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33832 size_t count, loff_t *ppos)
33833 {
33834 unsigned long p = *ppos;
33835 - ssize_t low_count, read, sz;
33836 + ssize_t low_count, read, sz, err = 0;
33837 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
33838 - int err = 0;
33839
33840 read = 0;
33841 if (p < (unsigned long) high_memory) {
33842 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33843 }
33844 #endif
33845 while (low_count > 0) {
33846 + char *temp;
33847 +
33848 sz = size_inside_page(p, low_count);
33849
33850 /*
33851 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33852 */
33853 kbuf = xlate_dev_kmem_ptr((char *)p);
33854
33855 - if (copy_to_user(buf, kbuf, sz))
33856 +#ifdef CONFIG_PAX_USERCOPY
33857 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33858 + if (!temp)
33859 + return -ENOMEM;
33860 + memcpy(temp, kbuf, sz);
33861 +#else
33862 + temp = kbuf;
33863 +#endif
33864 +
33865 + err = copy_to_user(buf, temp, sz);
33866 +
33867 +#ifdef CONFIG_PAX_USERCOPY
33868 + kfree(temp);
33869 +#endif
33870 +
33871 + if (err)
33872 return -EFAULT;
33873 buf += sz;
33874 p += sz;
33875 @@ -833,6 +880,9 @@ static const struct memdev {
33876 #ifdef CONFIG_CRASH_DUMP
33877 [12] = { "oldmem", 0, &oldmem_fops, NULL },
33878 #endif
33879 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33880 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
33881 +#endif
33882 };
33883
33884 static int memory_open(struct inode *inode, struct file *filp)
33885 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
33886 index 9df78e2..01ba9ae 100644
33887 --- a/drivers/char/nvram.c
33888 +++ b/drivers/char/nvram.c
33889 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
33890
33891 spin_unlock_irq(&rtc_lock);
33892
33893 - if (copy_to_user(buf, contents, tmp - contents))
33894 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
33895 return -EFAULT;
33896
33897 *ppos = i;
33898 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
33899 index 5c5cc00..ac9edb7 100644
33900 --- a/drivers/char/pcmcia/synclink_cs.c
33901 +++ b/drivers/char/pcmcia/synclink_cs.c
33902 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33903
33904 if (debug_level >= DEBUG_LEVEL_INFO)
33905 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
33906 - __FILE__, __LINE__, info->device_name, port->count);
33907 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
33908
33909 - WARN_ON(!port->count);
33910 + WARN_ON(!atomic_read(&port->count));
33911
33912 if (tty_port_close_start(port, tty, filp) == 0)
33913 goto cleanup;
33914 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33915 cleanup:
33916 if (debug_level >= DEBUG_LEVEL_INFO)
33917 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
33918 - tty->driver->name, port->count);
33919 + tty->driver->name, atomic_read(&port->count));
33920 }
33921
33922 /* Wait until the transmitter is empty.
33923 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33924
33925 if (debug_level >= DEBUG_LEVEL_INFO)
33926 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
33927 - __FILE__, __LINE__, tty->driver->name, port->count);
33928 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
33929
33930 /* If port is closing, signal caller to try again */
33931 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
33932 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33933 goto cleanup;
33934 }
33935 spin_lock(&port->lock);
33936 - port->count++;
33937 + atomic_inc(&port->count);
33938 spin_unlock(&port->lock);
33939 spin_unlock_irqrestore(&info->netlock, flags);
33940
33941 - if (port->count == 1) {
33942 + if (atomic_read(&port->count) == 1) {
33943 /* 1st open on this device, init hardware */
33944 retval = startup(info, tty);
33945 if (retval < 0)
33946 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
33947 unsigned short new_crctype;
33948
33949 /* return error if TTY interface open */
33950 - if (info->port.count)
33951 + if (atomic_read(&info->port.count))
33952 return -EBUSY;
33953
33954 switch (encoding)
33955 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
33956
33957 /* arbitrate between network and tty opens */
33958 spin_lock_irqsave(&info->netlock, flags);
33959 - if (info->port.count != 0 || info->netcount != 0) {
33960 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
33961 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
33962 spin_unlock_irqrestore(&info->netlock, flags);
33963 return -EBUSY;
33964 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
33965 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
33966
33967 /* return error if TTY interface open */
33968 - if (info->port.count)
33969 + if (atomic_read(&info->port.count))
33970 return -EBUSY;
33971
33972 if (cmd != SIOCWANDEV)
33973 diff --git a/drivers/char/random.c b/drivers/char/random.c
33974 index 32a6c57..98038d5 100644
33975 --- a/drivers/char/random.c
33976 +++ b/drivers/char/random.c
33977 @@ -272,8 +272,13 @@
33978 /*
33979 * Configuration information
33980 */
33981 +#ifdef CONFIG_GRKERNSEC_RANDNET
33982 +#define INPUT_POOL_WORDS 512
33983 +#define OUTPUT_POOL_WORDS 128
33984 +#else
33985 #define INPUT_POOL_WORDS 128
33986 #define OUTPUT_POOL_WORDS 32
33987 +#endif
33988 #define SEC_XFER_SIZE 512
33989 #define EXTRACT_SIZE 10
33990
33991 @@ -313,10 +318,17 @@ static struct poolinfo {
33992 int poolwords;
33993 int tap1, tap2, tap3, tap4, tap5;
33994 } poolinfo_table[] = {
33995 +#ifdef CONFIG_GRKERNSEC_RANDNET
33996 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
33997 + { 512, 411, 308, 208, 104, 1 },
33998 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
33999 + { 128, 103, 76, 51, 25, 1 },
34000 +#else
34001 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34002 { 128, 103, 76, 51, 25, 1 },
34003 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34004 { 32, 26, 20, 14, 7, 1 },
34005 +#endif
34006 #if 0
34007 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34008 { 2048, 1638, 1231, 819, 411, 1 },
34009 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34010 input_rotate += i ? 7 : 14;
34011 }
34012
34013 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34014 - ACCESS_ONCE(r->add_ptr) = i;
34015 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34016 + ACCESS_ONCE_RW(r->add_ptr) = i;
34017 smp_wmb();
34018
34019 if (out)
34020 @@ -865,16 +877,24 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
34021 if (r->entropy_count / 8 < min + reserved) {
34022 nbytes = 0;
34023 } else {
34024 + int entropy_count, orig;
34025 +retry:
34026 + entropy_count = orig = ACCESS_ONCE(r->entropy_count);
34027 /* If limited, never pull more than available */
34028 - if (r->limit && nbytes + reserved >= r->entropy_count / 8)
34029 - nbytes = r->entropy_count/8 - reserved;
34030 + if (r->limit && nbytes + reserved >= entropy_count / 8)
34031 + nbytes = entropy_count/8 - reserved;
34032
34033 - if (r->entropy_count / 8 >= nbytes + reserved)
34034 - r->entropy_count -= nbytes*8;
34035 - else
34036 - r->entropy_count = reserved;
34037 + if (entropy_count / 8 >= nbytes + reserved) {
34038 + entropy_count -= nbytes*8;
34039 + if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
34040 + goto retry;
34041 + } else {
34042 + entropy_count = reserved;
34043 + if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
34044 + goto retry;
34045 + }
34046
34047 - if (r->entropy_count < random_write_wakeup_thresh)
34048 + if (entropy_count < random_write_wakeup_thresh)
34049 wakeup_write = 1;
34050 }
34051
34052 @@ -957,10 +977,23 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
34053 {
34054 ssize_t ret = 0, i;
34055 __u8 tmp[EXTRACT_SIZE];
34056 + unsigned long flags;
34057
34058 /* if last_data isn't primed, we need EXTRACT_SIZE extra bytes */
34059 - if (fips_enabled && !r->last_data_init)
34060 - nbytes += EXTRACT_SIZE;
34061 + if (fips_enabled) {
34062 + spin_lock_irqsave(&r->lock, flags);
34063 + if (!r->last_data_init) {
34064 + r->last_data_init = true;
34065 + spin_unlock_irqrestore(&r->lock, flags);
34066 + trace_extract_entropy(r->name, EXTRACT_SIZE,
34067 + r->entropy_count, _RET_IP_);
34068 + xfer_secondary_pool(r, EXTRACT_SIZE);
34069 + extract_buf(r, tmp);
34070 + spin_lock_irqsave(&r->lock, flags);
34071 + memcpy(r->last_data, tmp, EXTRACT_SIZE);
34072 + }
34073 + spin_unlock_irqrestore(&r->lock, flags);
34074 + }
34075
34076 trace_extract_entropy(r->name, nbytes, r->entropy_count, _RET_IP_);
34077 xfer_secondary_pool(r, nbytes);
34078 @@ -970,19 +1003,6 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
34079 extract_buf(r, tmp);
34080
34081 if (fips_enabled) {
34082 - unsigned long flags;
34083 -
34084 -
34085 - /* prime last_data value if need be, per fips 140-2 */
34086 - if (!r->last_data_init) {
34087 - spin_lock_irqsave(&r->lock, flags);
34088 - memcpy(r->last_data, tmp, EXTRACT_SIZE);
34089 - r->last_data_init = true;
34090 - nbytes -= EXTRACT_SIZE;
34091 - spin_unlock_irqrestore(&r->lock, flags);
34092 - extract_buf(r, tmp);
34093 - }
34094 -
34095 spin_lock_irqsave(&r->lock, flags);
34096 if (!memcmp(tmp, r->last_data, EXTRACT_SIZE))
34097 panic("Hardware RNG duplicated output!\n");
34098 @@ -1024,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34099
34100 extract_buf(r, tmp);
34101 i = min_t(int, nbytes, EXTRACT_SIZE);
34102 - if (copy_to_user(buf, tmp, i)) {
34103 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34104 ret = -EFAULT;
34105 break;
34106 }
34107 @@ -1360,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34108 #include <linux/sysctl.h>
34109
34110 static int min_read_thresh = 8, min_write_thresh;
34111 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34112 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34113 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34114 static char sysctl_bootid[16];
34115
34116 @@ -1376,7 +1396,7 @@ static char sysctl_bootid[16];
34117 static int proc_do_uuid(ctl_table *table, int write,
34118 void __user *buffer, size_t *lenp, loff_t *ppos)
34119 {
34120 - ctl_table fake_table;
34121 + ctl_table_no_const fake_table;
34122 unsigned char buf[64], tmp_uuid[16], *uuid;
34123
34124 uuid = table->data;
34125 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34126 index bf2349db..5456d53 100644
34127 --- a/drivers/char/sonypi.c
34128 +++ b/drivers/char/sonypi.c
34129 @@ -54,6 +54,7 @@
34130
34131 #include <asm/uaccess.h>
34132 #include <asm/io.h>
34133 +#include <asm/local.h>
34134
34135 #include <linux/sonypi.h>
34136
34137 @@ -490,7 +491,7 @@ static struct sonypi_device {
34138 spinlock_t fifo_lock;
34139 wait_queue_head_t fifo_proc_list;
34140 struct fasync_struct *fifo_async;
34141 - int open_count;
34142 + local_t open_count;
34143 int model;
34144 struct input_dev *input_jog_dev;
34145 struct input_dev *input_key_dev;
34146 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34147 static int sonypi_misc_release(struct inode *inode, struct file *file)
34148 {
34149 mutex_lock(&sonypi_device.lock);
34150 - sonypi_device.open_count--;
34151 + local_dec(&sonypi_device.open_count);
34152 mutex_unlock(&sonypi_device.lock);
34153 return 0;
34154 }
34155 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34156 {
34157 mutex_lock(&sonypi_device.lock);
34158 /* Flush input queue on first open */
34159 - if (!sonypi_device.open_count)
34160 + if (!local_read(&sonypi_device.open_count))
34161 kfifo_reset(&sonypi_device.fifo);
34162 - sonypi_device.open_count++;
34163 + local_inc(&sonypi_device.open_count);
34164 mutex_unlock(&sonypi_device.lock);
34165
34166 return 0;
34167 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34168 index 64420b3..5c40b56 100644
34169 --- a/drivers/char/tpm/tpm_acpi.c
34170 +++ b/drivers/char/tpm/tpm_acpi.c
34171 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34172 virt = acpi_os_map_memory(start, len);
34173 if (!virt) {
34174 kfree(log->bios_event_log);
34175 + log->bios_event_log = NULL;
34176 printk("%s: ERROR - Unable to map memory\n", __func__);
34177 return -EIO;
34178 }
34179
34180 - memcpy_fromio(log->bios_event_log, virt, len);
34181 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34182
34183 acpi_os_unmap_memory(virt, len);
34184 return 0;
34185 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34186 index 84ddc55..1d32f1e 100644
34187 --- a/drivers/char/tpm/tpm_eventlog.c
34188 +++ b/drivers/char/tpm/tpm_eventlog.c
34189 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34190 event = addr;
34191
34192 if ((event->event_type == 0 && event->event_size == 0) ||
34193 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34194 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34195 return NULL;
34196
34197 return addr;
34198 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34199 return NULL;
34200
34201 if ((event->event_type == 0 && event->event_size == 0) ||
34202 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34203 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34204 return NULL;
34205
34206 (*pos)++;
34207 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34208 int i;
34209
34210 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34211 - seq_putc(m, data[i]);
34212 + if (!seq_putc(m, data[i]))
34213 + return -EFAULT;
34214
34215 return 0;
34216 }
34217 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34218 index ce5f3fc..e2d3e55 100644
34219 --- a/drivers/char/virtio_console.c
34220 +++ b/drivers/char/virtio_console.c
34221 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34222 if (to_user) {
34223 ssize_t ret;
34224
34225 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34226 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34227 if (ret)
34228 return -EFAULT;
34229 } else {
34230 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34231 if (!port_has_data(port) && !port->host_connected)
34232 return 0;
34233
34234 - return fill_readbuf(port, ubuf, count, true);
34235 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34236 }
34237
34238 static int wait_port_writable(struct port *port, bool nonblock)
34239 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34240 index d7ad425..3e3f81f 100644
34241 --- a/drivers/clocksource/arm_arch_timer.c
34242 +++ b/drivers/clocksource/arm_arch_timer.c
34243 @@ -262,7 +262,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34244 return NOTIFY_OK;
34245 }
34246
34247 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34248 +static struct notifier_block arch_timer_cpu_nb = {
34249 .notifier_call = arch_timer_cpu_notify,
34250 };
34251
34252 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34253 index ade7513..069445f 100644
34254 --- a/drivers/clocksource/metag_generic.c
34255 +++ b/drivers/clocksource/metag_generic.c
34256 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34257 return NOTIFY_OK;
34258 }
34259
34260 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34261 +static struct notifier_block arch_timer_cpu_nb = {
34262 .notifier_call = arch_timer_cpu_notify,
34263 };
34264
34265 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34266 index 57a8774..545e993 100644
34267 --- a/drivers/cpufreq/acpi-cpufreq.c
34268 +++ b/drivers/cpufreq/acpi-cpufreq.c
34269 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34270 return sprintf(buf, "%u\n", boost_enabled);
34271 }
34272
34273 -static struct global_attr global_boost = __ATTR(boost, 0644,
34274 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34275 show_global_boost,
34276 store_global_boost);
34277
34278 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34279 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34280 per_cpu(acfreq_data, cpu) = data;
34281
34282 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34283 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34284 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34285 + pax_open_kernel();
34286 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34287 + pax_close_kernel();
34288 + }
34289
34290 result = acpi_processor_register_performance(data->acpi_data, cpu);
34291 if (result)
34292 @@ -839,7 +842,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34293 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34294 break;
34295 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34296 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34297 + pax_open_kernel();
34298 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34299 + pax_close_kernel();
34300 policy->cur = get_cur_freq_on_cpu(cpu);
34301 break;
34302 default:
34303 @@ -850,8 +855,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34304 acpi_processor_notify_smm(THIS_MODULE);
34305
34306 /* Check for APERF/MPERF support in hardware */
34307 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34308 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34309 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34310 + pax_open_kernel();
34311 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34312 + pax_close_kernel();
34313 + }
34314
34315 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34316 for (i = 0; i < perf->state_count; i++)
34317 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34318 index b02824d..51e44aa 100644
34319 --- a/drivers/cpufreq/cpufreq.c
34320 +++ b/drivers/cpufreq/cpufreq.c
34321 @@ -1813,7 +1813,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34322 return NOTIFY_OK;
34323 }
34324
34325 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34326 +static struct notifier_block cpufreq_cpu_notifier = {
34327 .notifier_call = cpufreq_cpu_callback,
34328 };
34329
34330 @@ -1845,8 +1845,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34331
34332 pr_debug("trying to register driver %s\n", driver_data->name);
34333
34334 - if (driver_data->setpolicy)
34335 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34336 + if (driver_data->setpolicy) {
34337 + pax_open_kernel();
34338 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34339 + pax_close_kernel();
34340 + }
34341
34342 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34343 if (cpufreq_driver) {
34344 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34345 index 5a76086..0f4d394 100644
34346 --- a/drivers/cpufreq/cpufreq_governor.c
34347 +++ b/drivers/cpufreq/cpufreq_governor.c
34348 @@ -201,8 +201,8 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34349 {
34350 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34351 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34352 - struct cs_ops *cs_ops = NULL;
34353 - struct od_ops *od_ops = NULL;
34354 + const struct cs_ops *cs_ops = NULL;
34355 + const struct od_ops *od_ops = NULL;
34356 struct od_dbs_tuners *od_tuners = dbs_data->tuners;
34357 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
34358 struct cpu_dbs_common_info *cpu_cdbs;
34359 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34360 index cc4bd2f..ad142bc 100644
34361 --- a/drivers/cpufreq/cpufreq_governor.h
34362 +++ b/drivers/cpufreq/cpufreq_governor.h
34363 @@ -142,7 +142,7 @@ struct dbs_data {
34364 void (*gov_check_cpu)(int cpu, unsigned int load);
34365
34366 /* Governor specific ops, see below */
34367 - void *gov_ops;
34368 + const void *gov_ops;
34369 };
34370
34371 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34372 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34373 index bfd6273..e39dd63 100644
34374 --- a/drivers/cpufreq/cpufreq_stats.c
34375 +++ b/drivers/cpufreq/cpufreq_stats.c
34376 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34377 }
34378
34379 /* priority=1 so this will get called before cpufreq_remove_dev */
34380 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34381 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34382 .notifier_call = cpufreq_stat_cpu_callback,
34383 .priority = 1,
34384 };
34385 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34386 index 827629c9..0bc6a03 100644
34387 --- a/drivers/cpufreq/p4-clockmod.c
34388 +++ b/drivers/cpufreq/p4-clockmod.c
34389 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34390 case 0x0F: /* Core Duo */
34391 case 0x16: /* Celeron Core */
34392 case 0x1C: /* Atom */
34393 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34394 + pax_open_kernel();
34395 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34396 + pax_close_kernel();
34397 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34398 case 0x0D: /* Pentium M (Dothan) */
34399 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34400 + pax_open_kernel();
34401 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34402 + pax_close_kernel();
34403 /* fall through */
34404 case 0x09: /* Pentium M (Banias) */
34405 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34406 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34407
34408 /* on P-4s, the TSC runs with constant frequency independent whether
34409 * throttling is active or not. */
34410 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34411 + pax_open_kernel();
34412 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34413 + pax_close_kernel();
34414
34415 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34416 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34417 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34418 index 3a953d5..f5993f6 100644
34419 --- a/drivers/cpufreq/speedstep-centrino.c
34420 +++ b/drivers/cpufreq/speedstep-centrino.c
34421 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34422 !cpu_has(cpu, X86_FEATURE_EST))
34423 return -ENODEV;
34424
34425 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34426 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34427 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34428 + pax_open_kernel();
34429 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34430 + pax_close_kernel();
34431 + }
34432
34433 if (policy->cpu != 0)
34434 return -ENODEV;
34435 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34436 index eba6929..0f53baf 100644
34437 --- a/drivers/cpuidle/cpuidle.c
34438 +++ b/drivers/cpuidle/cpuidle.c
34439 @@ -277,7 +277,7 @@ static int poll_idle(struct cpuidle_device *dev,
34440
34441 static void poll_idle_init(struct cpuidle_driver *drv)
34442 {
34443 - struct cpuidle_state *state = &drv->states[0];
34444 + cpuidle_state_no_const *state = &drv->states[0];
34445
34446 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34447 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34448 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34449 index ea2f8e7..70ac501 100644
34450 --- a/drivers/cpuidle/governor.c
34451 +++ b/drivers/cpuidle/governor.c
34452 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34453 mutex_lock(&cpuidle_lock);
34454 if (__cpuidle_find_governor(gov->name) == NULL) {
34455 ret = 0;
34456 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34457 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34458 if (!cpuidle_curr_governor ||
34459 cpuidle_curr_governor->rating < gov->rating)
34460 cpuidle_switch_governor(gov);
34461 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34462 new_gov = cpuidle_replace_governor(gov->rating);
34463 cpuidle_switch_governor(new_gov);
34464 }
34465 - list_del(&gov->governor_list);
34466 + pax_list_del((struct list_head *)&gov->governor_list);
34467 mutex_unlock(&cpuidle_lock);
34468 }
34469
34470 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34471 index 428754a..8bdf9cc 100644
34472 --- a/drivers/cpuidle/sysfs.c
34473 +++ b/drivers/cpuidle/sysfs.c
34474 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34475 NULL
34476 };
34477
34478 -static struct attribute_group cpuidle_attr_group = {
34479 +static attribute_group_no_const cpuidle_attr_group = {
34480 .attrs = cpuidle_default_attrs,
34481 .name = "cpuidle",
34482 };
34483 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34484 index 3b36797..289c16a 100644
34485 --- a/drivers/devfreq/devfreq.c
34486 +++ b/drivers/devfreq/devfreq.c
34487 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34488 goto err_out;
34489 }
34490
34491 - list_add(&governor->node, &devfreq_governor_list);
34492 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34493
34494 list_for_each_entry(devfreq, &devfreq_list, node) {
34495 int ret = 0;
34496 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34497 }
34498 }
34499
34500 - list_del(&governor->node);
34501 + pax_list_del((struct list_head *)&governor->node);
34502 err_out:
34503 mutex_unlock(&devfreq_list_lock);
34504
34505 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34506 index b70709b..1d8d02a 100644
34507 --- a/drivers/dma/sh/shdma.c
34508 +++ b/drivers/dma/sh/shdma.c
34509 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34510 return ret;
34511 }
34512
34513 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34514 +static struct notifier_block sh_dmae_nmi_notifier = {
34515 .notifier_call = sh_dmae_nmi_handler,
34516
34517 /* Run before NMI debug handler and KGDB */
34518 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34519 index 769d92e..a3dcc1e 100644
34520 --- a/drivers/edac/edac_mc_sysfs.c
34521 +++ b/drivers/edac/edac_mc_sysfs.c
34522 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34523 struct dev_ch_attribute {
34524 struct device_attribute attr;
34525 int channel;
34526 -};
34527 +} __do_const;
34528
34529 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34530 struct dev_ch_attribute dev_attr_legacy_##_name = \
34531 @@ -1003,14 +1003,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34532 }
34533
34534 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34535 + pax_open_kernel();
34536 if (mci->get_sdram_scrub_rate) {
34537 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34538 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34539 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34540 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34541 }
34542 if (mci->set_sdram_scrub_rate) {
34543 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34544 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34545 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34546 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34547 }
34548 + pax_close_kernel();
34549 err = device_create_file(&mci->dev,
34550 &dev_attr_sdram_scrub_rate);
34551 if (err) {
34552 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34553 index e8658e4..22746d6 100644
34554 --- a/drivers/edac/edac_pci_sysfs.c
34555 +++ b/drivers/edac/edac_pci_sysfs.c
34556 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34557 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34558 static int edac_pci_poll_msec = 1000; /* one second workq period */
34559
34560 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34561 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34562 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34563 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34564
34565 static struct kobject *edac_pci_top_main_kobj;
34566 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34567 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34568 void *value;
34569 ssize_t(*show) (void *, char *);
34570 ssize_t(*store) (void *, const char *, size_t);
34571 -};
34572 +} __do_const;
34573
34574 /* Set of show/store abstract level functions for PCI Parity object */
34575 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34576 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34577 edac_printk(KERN_CRIT, EDAC_PCI,
34578 "Signaled System Error on %s\n",
34579 pci_name(dev));
34580 - atomic_inc(&pci_nonparity_count);
34581 + atomic_inc_unchecked(&pci_nonparity_count);
34582 }
34583
34584 if (status & (PCI_STATUS_PARITY)) {
34585 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34586 "Master Data Parity Error on %s\n",
34587 pci_name(dev));
34588
34589 - atomic_inc(&pci_parity_count);
34590 + atomic_inc_unchecked(&pci_parity_count);
34591 }
34592
34593 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34594 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34595 "Detected Parity Error on %s\n",
34596 pci_name(dev));
34597
34598 - atomic_inc(&pci_parity_count);
34599 + atomic_inc_unchecked(&pci_parity_count);
34600 }
34601 }
34602
34603 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34604 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34605 "Signaled System Error on %s\n",
34606 pci_name(dev));
34607 - atomic_inc(&pci_nonparity_count);
34608 + atomic_inc_unchecked(&pci_nonparity_count);
34609 }
34610
34611 if (status & (PCI_STATUS_PARITY)) {
34612 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34613 "Master Data Parity Error on "
34614 "%s\n", pci_name(dev));
34615
34616 - atomic_inc(&pci_parity_count);
34617 + atomic_inc_unchecked(&pci_parity_count);
34618 }
34619
34620 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34621 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34622 "Detected Parity Error on %s\n",
34623 pci_name(dev));
34624
34625 - atomic_inc(&pci_parity_count);
34626 + atomic_inc_unchecked(&pci_parity_count);
34627 }
34628 }
34629 }
34630 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34631 if (!check_pci_errors)
34632 return;
34633
34634 - before_count = atomic_read(&pci_parity_count);
34635 + before_count = atomic_read_unchecked(&pci_parity_count);
34636
34637 /* scan all PCI devices looking for a Parity Error on devices and
34638 * bridges.
34639 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34640 /* Only if operator has selected panic on PCI Error */
34641 if (edac_pci_get_panic_on_pe()) {
34642 /* If the count is different 'after' from 'before' */
34643 - if (before_count != atomic_read(&pci_parity_count))
34644 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34645 panic("EDAC: PCI Parity Error");
34646 }
34647 }
34648 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34649 index 51b7e3a..aa8a3e8 100644
34650 --- a/drivers/edac/mce_amd.h
34651 +++ b/drivers/edac/mce_amd.h
34652 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
34653 bool (*mc0_mce)(u16, u8);
34654 bool (*mc1_mce)(u16, u8);
34655 bool (*mc2_mce)(u16, u8);
34656 -};
34657 +} __no_const;
34658
34659 void amd_report_gart_errors(bool);
34660 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34661 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34662 index 57ea7f4..789e3c3 100644
34663 --- a/drivers/firewire/core-card.c
34664 +++ b/drivers/firewire/core-card.c
34665 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34666
34667 void fw_core_remove_card(struct fw_card *card)
34668 {
34669 - struct fw_card_driver dummy_driver = dummy_driver_template;
34670 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34671
34672 card->driver->update_phy_reg(card, 4,
34673 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34674 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34675 index 27ac423..13573e8 100644
34676 --- a/drivers/firewire/core-cdev.c
34677 +++ b/drivers/firewire/core-cdev.c
34678 @@ -1366,8 +1366,7 @@ static int init_iso_resource(struct client *client,
34679 int ret;
34680
34681 if ((request->channels == 0 && request->bandwidth == 0) ||
34682 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34683 - request->bandwidth < 0)
34684 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34685 return -EINVAL;
34686
34687 r = kmalloc(sizeof(*r), GFP_KERNEL);
34688 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34689 index 03ce7d9..b70f5da 100644
34690 --- a/drivers/firewire/core-device.c
34691 +++ b/drivers/firewire/core-device.c
34692 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34693 struct config_rom_attribute {
34694 struct device_attribute attr;
34695 u32 key;
34696 -};
34697 +} __do_const;
34698
34699 static ssize_t show_immediate(struct device *dev,
34700 struct device_attribute *dattr, char *buf)
34701 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34702 index 28a94c7..58da63a 100644
34703 --- a/drivers/firewire/core-transaction.c
34704 +++ b/drivers/firewire/core-transaction.c
34705 @@ -38,6 +38,7 @@
34706 #include <linux/timer.h>
34707 #include <linux/types.h>
34708 #include <linux/workqueue.h>
34709 +#include <linux/sched.h>
34710
34711 #include <asm/byteorder.h>
34712
34713 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34714 index 515a42c..5ecf3ba 100644
34715 --- a/drivers/firewire/core.h
34716 +++ b/drivers/firewire/core.h
34717 @@ -111,6 +111,7 @@ struct fw_card_driver {
34718
34719 int (*stop_iso)(struct fw_iso_context *ctx);
34720 };
34721 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34722
34723 void fw_card_initialize(struct fw_card *card,
34724 const struct fw_card_driver *driver, struct device *device);
34725 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34726 index 94a58a0..f5eba42 100644
34727 --- a/drivers/firmware/dmi-id.c
34728 +++ b/drivers/firmware/dmi-id.c
34729 @@ -16,7 +16,7 @@
34730 struct dmi_device_attribute{
34731 struct device_attribute dev_attr;
34732 int field;
34733 -};
34734 +} __do_const;
34735 #define to_dmi_dev_attr(_dev_attr) \
34736 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34737
34738 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34739 index 4cd392d..4b629e1 100644
34740 --- a/drivers/firmware/dmi_scan.c
34741 +++ b/drivers/firmware/dmi_scan.c
34742 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34743 }
34744 }
34745 else {
34746 - /*
34747 - * no iounmap() for that ioremap(); it would be a no-op, but
34748 - * it's so early in setup that sucker gets confused into doing
34749 - * what it shouldn't if we actually call it.
34750 - */
34751 p = dmi_ioremap(0xF0000, 0x10000);
34752 if (p == NULL)
34753 goto error;
34754 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34755 if (buf == NULL)
34756 return -1;
34757
34758 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34759 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34760
34761 iounmap(buf);
34762 return 0;
34763 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
34764 index f4baa11..7970c3a 100644
34765 --- a/drivers/firmware/efivars.c
34766 +++ b/drivers/firmware/efivars.c
34767 @@ -139,7 +139,7 @@ struct efivar_attribute {
34768 };
34769
34770 static struct efivars __efivars;
34771 -static struct efivar_operations ops;
34772 +static efivar_operations_no_const ops __read_only;
34773
34774 #define PSTORE_EFI_ATTRIBUTES \
34775 (EFI_VARIABLE_NON_VOLATILE | \
34776 @@ -1844,7 +1844,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
34777 static int
34778 create_efivars_bin_attributes(struct efivars *efivars)
34779 {
34780 - struct bin_attribute *attr;
34781 + bin_attribute_no_const *attr;
34782 int error;
34783
34784 /* new_var */
34785 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
34786 index 2a90ba6..07f3733 100644
34787 --- a/drivers/firmware/google/memconsole.c
34788 +++ b/drivers/firmware/google/memconsole.c
34789 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
34790 if (!found_memconsole())
34791 return -ENODEV;
34792
34793 - memconsole_bin_attr.size = memconsole_length;
34794 + pax_open_kernel();
34795 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
34796 + pax_close_kernel();
34797
34798 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
34799
34800 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
34801 index de3c317..b7cd029 100644
34802 --- a/drivers/gpio/gpio-ich.c
34803 +++ b/drivers/gpio/gpio-ich.c
34804 @@ -69,7 +69,7 @@ struct ichx_desc {
34805 /* Some chipsets have quirks, let these use their own request/get */
34806 int (*request)(struct gpio_chip *chip, unsigned offset);
34807 int (*get)(struct gpio_chip *chip, unsigned offset);
34808 -};
34809 +} __do_const;
34810
34811 static struct {
34812 spinlock_t lock;
34813 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
34814 index 9902732..64b62dd 100644
34815 --- a/drivers/gpio/gpio-vr41xx.c
34816 +++ b/drivers/gpio/gpio-vr41xx.c
34817 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
34818 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
34819 maskl, pendl, maskh, pendh);
34820
34821 - atomic_inc(&irq_err_count);
34822 + atomic_inc_unchecked(&irq_err_count);
34823
34824 return -EINVAL;
34825 }
34826 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
34827 index 7b2d378..cc947ea 100644
34828 --- a/drivers/gpu/drm/drm_crtc_helper.c
34829 +++ b/drivers/gpu/drm/drm_crtc_helper.c
34830 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
34831 struct drm_crtc *tmp;
34832 int crtc_mask = 1;
34833
34834 - WARN(!crtc, "checking null crtc?\n");
34835 + BUG_ON(!crtc);
34836
34837 dev = crtc->dev;
34838
34839 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
34840 index 25f91cd..a376f55 100644
34841 --- a/drivers/gpu/drm/drm_drv.c
34842 +++ b/drivers/gpu/drm/drm_drv.c
34843 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
34844 /**
34845 * Copy and IOCTL return string to user space
34846 */
34847 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
34848 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
34849 {
34850 int len;
34851
34852 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
34853 struct drm_file *file_priv = filp->private_data;
34854 struct drm_device *dev;
34855 struct drm_ioctl_desc *ioctl;
34856 - drm_ioctl_t *func;
34857 + drm_ioctl_no_const_t func;
34858 unsigned int nr = DRM_IOCTL_NR(cmd);
34859 int retcode = -EINVAL;
34860 char stack_kdata[128];
34861 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
34862 return -ENODEV;
34863
34864 atomic_inc(&dev->ioctl_count);
34865 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
34866 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
34867 ++file_priv->ioctl_count;
34868
34869 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
34870 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
34871 index 429e07d..e681a2c 100644
34872 --- a/drivers/gpu/drm/drm_fops.c
34873 +++ b/drivers/gpu/drm/drm_fops.c
34874 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
34875 }
34876
34877 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
34878 - atomic_set(&dev->counts[i], 0);
34879 + atomic_set_unchecked(&dev->counts[i], 0);
34880
34881 dev->sigdata.lock = NULL;
34882
34883 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
34884 if (drm_device_is_unplugged(dev))
34885 return -ENODEV;
34886
34887 - if (!dev->open_count++)
34888 + if (local_inc_return(&dev->open_count) == 1)
34889 need_setup = 1;
34890 mutex_lock(&dev->struct_mutex);
34891 old_imapping = inode->i_mapping;
34892 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
34893 retcode = drm_open_helper(inode, filp, dev);
34894 if (retcode)
34895 goto err_undo;
34896 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
34897 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
34898 if (need_setup) {
34899 retcode = drm_setup(dev);
34900 if (retcode)
34901 @@ -166,7 +166,7 @@ err_undo:
34902 iput(container_of(dev->dev_mapping, struct inode, i_data));
34903 dev->dev_mapping = old_mapping;
34904 mutex_unlock(&dev->struct_mutex);
34905 - dev->open_count--;
34906 + local_dec(&dev->open_count);
34907 return retcode;
34908 }
34909 EXPORT_SYMBOL(drm_open);
34910 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
34911
34912 mutex_lock(&drm_global_mutex);
34913
34914 - DRM_DEBUG("open_count = %d\n", dev->open_count);
34915 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
34916
34917 if (dev->driver->preclose)
34918 dev->driver->preclose(dev, file_priv);
34919 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
34920 * Begin inline drm_release
34921 */
34922
34923 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
34924 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
34925 task_pid_nr(current),
34926 (long)old_encode_dev(file_priv->minor->device),
34927 - dev->open_count);
34928 + local_read(&dev->open_count));
34929
34930 /* Release any auth tokens that might point to this file_priv,
34931 (do that under the drm_global_mutex) */
34932 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
34933 * End inline drm_release
34934 */
34935
34936 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
34937 - if (!--dev->open_count) {
34938 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
34939 + if (local_dec_and_test(&dev->open_count)) {
34940 if (atomic_read(&dev->ioctl_count)) {
34941 DRM_ERROR("Device busy: %d\n",
34942 atomic_read(&dev->ioctl_count));
34943 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
34944 index f731116..629842c 100644
34945 --- a/drivers/gpu/drm/drm_global.c
34946 +++ b/drivers/gpu/drm/drm_global.c
34947 @@ -36,7 +36,7 @@
34948 struct drm_global_item {
34949 struct mutex mutex;
34950 void *object;
34951 - int refcount;
34952 + atomic_t refcount;
34953 };
34954
34955 static struct drm_global_item glob[DRM_GLOBAL_NUM];
34956 @@ -49,7 +49,7 @@ void drm_global_init(void)
34957 struct drm_global_item *item = &glob[i];
34958 mutex_init(&item->mutex);
34959 item->object = NULL;
34960 - item->refcount = 0;
34961 + atomic_set(&item->refcount, 0);
34962 }
34963 }
34964
34965 @@ -59,7 +59,7 @@ void drm_global_release(void)
34966 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
34967 struct drm_global_item *item = &glob[i];
34968 BUG_ON(item->object != NULL);
34969 - BUG_ON(item->refcount != 0);
34970 + BUG_ON(atomic_read(&item->refcount) != 0);
34971 }
34972 }
34973
34974 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34975 void *object;
34976
34977 mutex_lock(&item->mutex);
34978 - if (item->refcount == 0) {
34979 + if (atomic_read(&item->refcount) == 0) {
34980 item->object = kzalloc(ref->size, GFP_KERNEL);
34981 if (unlikely(item->object == NULL)) {
34982 ret = -ENOMEM;
34983 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34984 goto out_err;
34985
34986 }
34987 - ++item->refcount;
34988 + atomic_inc(&item->refcount);
34989 ref->object = item->object;
34990 object = item->object;
34991 mutex_unlock(&item->mutex);
34992 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
34993 struct drm_global_item *item = &glob[ref->global_type];
34994
34995 mutex_lock(&item->mutex);
34996 - BUG_ON(item->refcount == 0);
34997 + BUG_ON(atomic_read(&item->refcount) == 0);
34998 BUG_ON(ref->object != item->object);
34999 - if (--item->refcount == 0) {
35000 + if (atomic_dec_and_test(&item->refcount)) {
35001 ref->release(ref);
35002 item->object = NULL;
35003 }
35004 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35005 index d4b20ce..77a8d41 100644
35006 --- a/drivers/gpu/drm/drm_info.c
35007 +++ b/drivers/gpu/drm/drm_info.c
35008 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35009 struct drm_local_map *map;
35010 struct drm_map_list *r_list;
35011
35012 - /* Hardcoded from _DRM_FRAME_BUFFER,
35013 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35014 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35015 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35016 + static const char * const types[] = {
35017 + [_DRM_FRAME_BUFFER] = "FB",
35018 + [_DRM_REGISTERS] = "REG",
35019 + [_DRM_SHM] = "SHM",
35020 + [_DRM_AGP] = "AGP",
35021 + [_DRM_SCATTER_GATHER] = "SG",
35022 + [_DRM_CONSISTENT] = "PCI",
35023 + [_DRM_GEM] = "GEM" };
35024 const char *type;
35025 int i;
35026
35027 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35028 map = r_list->map;
35029 if (!map)
35030 continue;
35031 - if (map->type < 0 || map->type > 5)
35032 + if (map->type >= ARRAY_SIZE(types))
35033 type = "??";
35034 else
35035 type = types[map->type];
35036 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35037 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35038 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35039 vma->vm_flags & VM_IO ? 'i' : '-',
35040 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35041 + 0);
35042 +#else
35043 vma->vm_pgoff);
35044 +#endif
35045
35046 #if defined(__i386__)
35047 pgprot = pgprot_val(vma->vm_page_prot);
35048 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35049 index 2f4c434..dd12cd2 100644
35050 --- a/drivers/gpu/drm/drm_ioc32.c
35051 +++ b/drivers/gpu/drm/drm_ioc32.c
35052 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35053 request = compat_alloc_user_space(nbytes);
35054 if (!access_ok(VERIFY_WRITE, request, nbytes))
35055 return -EFAULT;
35056 - list = (struct drm_buf_desc *) (request + 1);
35057 + list = (struct drm_buf_desc __user *) (request + 1);
35058
35059 if (__put_user(count, &request->count)
35060 || __put_user(list, &request->list))
35061 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35062 request = compat_alloc_user_space(nbytes);
35063 if (!access_ok(VERIFY_WRITE, request, nbytes))
35064 return -EFAULT;
35065 - list = (struct drm_buf_pub *) (request + 1);
35066 + list = (struct drm_buf_pub __user *) (request + 1);
35067
35068 if (__put_user(count, &request->count)
35069 || __put_user(list, &request->list))
35070 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35071 return 0;
35072 }
35073
35074 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35075 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35076 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35077 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35078 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35079 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35080 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35081 {
35082 unsigned int nr = DRM_IOCTL_NR(cmd);
35083 - drm_ioctl_compat_t *fn;
35084 int ret;
35085
35086 /* Assume that ioctls without an explicit compat routine will just
35087 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35088 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35089 return drm_ioctl(filp, cmd, arg);
35090
35091 - fn = drm_compat_ioctls[nr];
35092 -
35093 - if (fn != NULL)
35094 - ret = (*fn) (filp, cmd, arg);
35095 + if (drm_compat_ioctls[nr] != NULL)
35096 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35097 else
35098 ret = drm_ioctl(filp, cmd, arg);
35099
35100 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35101 index e77bd8b..1571b85 100644
35102 --- a/drivers/gpu/drm/drm_ioctl.c
35103 +++ b/drivers/gpu/drm/drm_ioctl.c
35104 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35105 stats->data[i].value =
35106 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35107 else
35108 - stats->data[i].value = atomic_read(&dev->counts[i]);
35109 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35110 stats->data[i].type = dev->types[i];
35111 }
35112
35113 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35114 index d752c96..fe08455 100644
35115 --- a/drivers/gpu/drm/drm_lock.c
35116 +++ b/drivers/gpu/drm/drm_lock.c
35117 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35118 if (drm_lock_take(&master->lock, lock->context)) {
35119 master->lock.file_priv = file_priv;
35120 master->lock.lock_time = jiffies;
35121 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35122 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35123 break; /* Got lock */
35124 }
35125
35126 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35127 return -EINVAL;
35128 }
35129
35130 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35131 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35132
35133 if (drm_lock_free(&master->lock, lock->context)) {
35134 /* FIXME: Should really bail out here. */
35135 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35136 index 7d30802..42c6cbb 100644
35137 --- a/drivers/gpu/drm/drm_stub.c
35138 +++ b/drivers/gpu/drm/drm_stub.c
35139 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
35140
35141 drm_device_set_unplugged(dev);
35142
35143 - if (dev->open_count == 0) {
35144 + if (local_read(&dev->open_count) == 0) {
35145 drm_put_dev(dev);
35146 }
35147 mutex_unlock(&drm_global_mutex);
35148 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35149 index 004ecdf..db1f6e0 100644
35150 --- a/drivers/gpu/drm/i810/i810_dma.c
35151 +++ b/drivers/gpu/drm/i810/i810_dma.c
35152 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35153 dma->buflist[vertex->idx],
35154 vertex->discard, vertex->used);
35155
35156 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35157 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35158 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35159 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35160 sarea_priv->last_enqueue = dev_priv->counter - 1;
35161 sarea_priv->last_dispatch = (int)hw_status[5];
35162
35163 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35164 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35165 mc->last_render);
35166
35167 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35168 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35169 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35170 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35171 sarea_priv->last_enqueue = dev_priv->counter - 1;
35172 sarea_priv->last_dispatch = (int)hw_status[5];
35173
35174 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35175 index 6e0acad..93c8289 100644
35176 --- a/drivers/gpu/drm/i810/i810_drv.h
35177 +++ b/drivers/gpu/drm/i810/i810_drv.h
35178 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35179 int page_flipping;
35180
35181 wait_queue_head_t irq_queue;
35182 - atomic_t irq_received;
35183 - atomic_t irq_emitted;
35184 + atomic_unchecked_t irq_received;
35185 + atomic_unchecked_t irq_emitted;
35186
35187 int front_offset;
35188 } drm_i810_private_t;
35189 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35190 index 7299ea4..5314487 100644
35191 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35192 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35193 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35194 I915_READ(GTIMR));
35195 }
35196 seq_printf(m, "Interrupts received: %d\n",
35197 - atomic_read(&dev_priv->irq_received));
35198 + atomic_read_unchecked(&dev_priv->irq_received));
35199 for_each_ring(ring, dev_priv, i) {
35200 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35201 seq_printf(m,
35202 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35203 index 4fa6beb..f930fec 100644
35204 --- a/drivers/gpu/drm/i915/i915_dma.c
35205 +++ b/drivers/gpu/drm/i915/i915_dma.c
35206 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35207 bool can_switch;
35208
35209 spin_lock(&dev->count_lock);
35210 - can_switch = (dev->open_count == 0);
35211 + can_switch = (local_read(&dev->open_count) == 0);
35212 spin_unlock(&dev->count_lock);
35213 return can_switch;
35214 }
35215 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35216 index ef99b1c..09ce7fb 100644
35217 --- a/drivers/gpu/drm/i915/i915_drv.h
35218 +++ b/drivers/gpu/drm/i915/i915_drv.h
35219 @@ -893,7 +893,7 @@ typedef struct drm_i915_private {
35220 drm_dma_handle_t *status_page_dmah;
35221 struct resource mch_res;
35222
35223 - atomic_t irq_received;
35224 + atomic_unchecked_t irq_received;
35225
35226 /* protects the irq masks */
35227 spinlock_t irq_lock;
35228 @@ -1775,7 +1775,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35229 struct drm_i915_private *dev_priv, unsigned port);
35230 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35231 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35232 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35233 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35234 {
35235 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35236 }
35237 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35238 index 9a48e1a..f0cbc3e 100644
35239 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35240 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35241 @@ -729,9 +729,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35242
35243 static int
35244 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35245 - int count)
35246 + unsigned int count)
35247 {
35248 - int i;
35249 + unsigned int i;
35250 int relocs_total = 0;
35251 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35252
35253 @@ -1195,7 +1195,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35254 return -ENOMEM;
35255 }
35256 ret = copy_from_user(exec2_list,
35257 - (struct drm_i915_relocation_entry __user *)
35258 + (struct drm_i915_gem_exec_object2 __user *)
35259 (uintptr_t) args->buffers_ptr,
35260 sizeof(*exec2_list) * args->buffer_count);
35261 if (ret != 0) {
35262 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35263 index 3c59584..500f2e9 100644
35264 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35265 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35266 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35267 (unsigned long)request);
35268 }
35269
35270 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35271 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35272 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35273 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35274 [DRM_I915_GETPARAM] = compat_i915_getparam,
35275 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35276 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35277 {
35278 unsigned int nr = DRM_IOCTL_NR(cmd);
35279 - drm_ioctl_compat_t *fn = NULL;
35280 int ret;
35281
35282 if (nr < DRM_COMMAND_BASE)
35283 return drm_compat_ioctl(filp, cmd, arg);
35284
35285 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35286 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35287 -
35288 - if (fn != NULL)
35289 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35290 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35291 ret = (*fn) (filp, cmd, arg);
35292 - else
35293 + } else
35294 ret = drm_ioctl(filp, cmd, arg);
35295
35296 return ret;
35297 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35298 index 3c7bb04..182e049 100644
35299 --- a/drivers/gpu/drm/i915/i915_irq.c
35300 +++ b/drivers/gpu/drm/i915/i915_irq.c
35301 @@ -549,7 +549,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35302 int pipe;
35303 u32 pipe_stats[I915_MAX_PIPES];
35304
35305 - atomic_inc(&dev_priv->irq_received);
35306 + atomic_inc_unchecked(&dev_priv->irq_received);
35307
35308 while (true) {
35309 iir = I915_READ(VLV_IIR);
35310 @@ -705,7 +705,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35311 irqreturn_t ret = IRQ_NONE;
35312 int i;
35313
35314 - atomic_inc(&dev_priv->irq_received);
35315 + atomic_inc_unchecked(&dev_priv->irq_received);
35316
35317 /* disable master interrupt before clearing iir */
35318 de_ier = I915_READ(DEIER);
35319 @@ -791,7 +791,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35320 int ret = IRQ_NONE;
35321 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35322
35323 - atomic_inc(&dev_priv->irq_received);
35324 + atomic_inc_unchecked(&dev_priv->irq_received);
35325
35326 /* disable master interrupt before clearing iir */
35327 de_ier = I915_READ(DEIER);
35328 @@ -1886,7 +1886,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35329 {
35330 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35331
35332 - atomic_set(&dev_priv->irq_received, 0);
35333 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35334
35335 I915_WRITE(HWSTAM, 0xeffe);
35336
35337 @@ -1912,7 +1912,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35338 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35339 int pipe;
35340
35341 - atomic_set(&dev_priv->irq_received, 0);
35342 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35343
35344 /* VLV magic */
35345 I915_WRITE(VLV_IMR, 0);
35346 @@ -2208,7 +2208,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35347 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35348 int pipe;
35349
35350 - atomic_set(&dev_priv->irq_received, 0);
35351 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35352
35353 for_each_pipe(pipe)
35354 I915_WRITE(PIPESTAT(pipe), 0);
35355 @@ -2259,7 +2259,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35356 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35357 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35358
35359 - atomic_inc(&dev_priv->irq_received);
35360 + atomic_inc_unchecked(&dev_priv->irq_received);
35361
35362 iir = I915_READ16(IIR);
35363 if (iir == 0)
35364 @@ -2344,7 +2344,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35365 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35366 int pipe;
35367
35368 - atomic_set(&dev_priv->irq_received, 0);
35369 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35370
35371 if (I915_HAS_HOTPLUG(dev)) {
35372 I915_WRITE(PORT_HOTPLUG_EN, 0);
35373 @@ -2448,7 +2448,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35374 };
35375 int pipe, ret = IRQ_NONE;
35376
35377 - atomic_inc(&dev_priv->irq_received);
35378 + atomic_inc_unchecked(&dev_priv->irq_received);
35379
35380 iir = I915_READ(IIR);
35381 do {
35382 @@ -2574,7 +2574,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35383 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35384 int pipe;
35385
35386 - atomic_set(&dev_priv->irq_received, 0);
35387 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35388
35389 I915_WRITE(PORT_HOTPLUG_EN, 0);
35390 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35391 @@ -2690,7 +2690,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35392 int irq_received;
35393 int ret = IRQ_NONE, pipe;
35394
35395 - atomic_inc(&dev_priv->irq_received);
35396 + atomic_inc_unchecked(&dev_priv->irq_received);
35397
35398 iir = I915_READ(IIR);
35399
35400 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35401 index c2d173a..f4357cc 100644
35402 --- a/drivers/gpu/drm/i915/intel_display.c
35403 +++ b/drivers/gpu/drm/i915/intel_display.c
35404 @@ -8722,13 +8722,13 @@ struct intel_quirk {
35405 int subsystem_vendor;
35406 int subsystem_device;
35407 void (*hook)(struct drm_device *dev);
35408 -};
35409 +} __do_const;
35410
35411 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35412 struct intel_dmi_quirk {
35413 void (*hook)(struct drm_device *dev);
35414 const struct dmi_system_id (*dmi_id_list)[];
35415 -};
35416 +} __do_const;
35417
35418 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35419 {
35420 @@ -8736,18 +8736,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35421 return 1;
35422 }
35423
35424 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35425 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35426 {
35427 - .dmi_id_list = &(const struct dmi_system_id[]) {
35428 - {
35429 - .callback = intel_dmi_reverse_brightness,
35430 - .ident = "NCR Corporation",
35431 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35432 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35433 - },
35434 - },
35435 - { } /* terminating entry */
35436 + .callback = intel_dmi_reverse_brightness,
35437 + .ident = "NCR Corporation",
35438 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35439 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35440 },
35441 + },
35442 + { } /* terminating entry */
35443 +};
35444 +
35445 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35446 + {
35447 + .dmi_id_list = &intel_dmi_quirks_table,
35448 .hook = quirk_invert_brightness,
35449 },
35450 };
35451 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35452 index 54558a0..2d97005 100644
35453 --- a/drivers/gpu/drm/mga/mga_drv.h
35454 +++ b/drivers/gpu/drm/mga/mga_drv.h
35455 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35456 u32 clear_cmd;
35457 u32 maccess;
35458
35459 - atomic_t vbl_received; /**< Number of vblanks received. */
35460 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35461 wait_queue_head_t fence_queue;
35462 - atomic_t last_fence_retired;
35463 + atomic_unchecked_t last_fence_retired;
35464 u32 next_fence_to_post;
35465
35466 unsigned int fb_cpp;
35467 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35468 index 709e90d..89a1c0d 100644
35469 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35470 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35471 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35472 return 0;
35473 }
35474
35475 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35476 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35477 [DRM_MGA_INIT] = compat_mga_init,
35478 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35479 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35480 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35481 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35482 {
35483 unsigned int nr = DRM_IOCTL_NR(cmd);
35484 - drm_ioctl_compat_t *fn = NULL;
35485 int ret;
35486
35487 if (nr < DRM_COMMAND_BASE)
35488 return drm_compat_ioctl(filp, cmd, arg);
35489
35490 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35491 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35492 -
35493 - if (fn != NULL)
35494 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35495 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35496 ret = (*fn) (filp, cmd, arg);
35497 - else
35498 + } else
35499 ret = drm_ioctl(filp, cmd, arg);
35500
35501 return ret;
35502 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35503 index 598c281..60d590e 100644
35504 --- a/drivers/gpu/drm/mga/mga_irq.c
35505 +++ b/drivers/gpu/drm/mga/mga_irq.c
35506 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35507 if (crtc != 0)
35508 return 0;
35509
35510 - return atomic_read(&dev_priv->vbl_received);
35511 + return atomic_read_unchecked(&dev_priv->vbl_received);
35512 }
35513
35514
35515 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35516 /* VBLANK interrupt */
35517 if (status & MGA_VLINEPEN) {
35518 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35519 - atomic_inc(&dev_priv->vbl_received);
35520 + atomic_inc_unchecked(&dev_priv->vbl_received);
35521 drm_handle_vblank(dev, 0);
35522 handled = 1;
35523 }
35524 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35525 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35526 MGA_WRITE(MGA_PRIMEND, prim_end);
35527
35528 - atomic_inc(&dev_priv->last_fence_retired);
35529 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35530 DRM_WAKEUP(&dev_priv->fence_queue);
35531 handled = 1;
35532 }
35533 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35534 * using fences.
35535 */
35536 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35537 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35538 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35539 - *sequence) <= (1 << 23)));
35540
35541 *sequence = cur_fence;
35542 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35543 index 50a6dd0..ea66ed8 100644
35544 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35545 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35546 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35547 struct bit_table {
35548 const char id;
35549 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35550 -};
35551 +} __no_const;
35552
35553 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35554
35555 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35556 index 9c39baf..30a22be 100644
35557 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35558 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35559 @@ -81,7 +81,7 @@ struct nouveau_drm {
35560 struct drm_global_reference mem_global_ref;
35561 struct ttm_bo_global_ref bo_global_ref;
35562 struct ttm_bo_device bdev;
35563 - atomic_t validate_sequence;
35564 + atomic_unchecked_t validate_sequence;
35565 int (*move)(struct nouveau_channel *,
35566 struct ttm_buffer_object *,
35567 struct ttm_mem_reg *, struct ttm_mem_reg *);
35568 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35569 index b4b4d0c..b7edc15 100644
35570 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35571 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35572 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35573 int ret, i;
35574 struct nouveau_bo *res_bo = NULL;
35575
35576 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35577 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35578 retry:
35579 if (++trycnt > 100000) {
35580 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
35581 @@ -359,7 +359,7 @@ retry:
35582 if (ret) {
35583 validate_fini(op, NULL);
35584 if (unlikely(ret == -EAGAIN)) {
35585 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35586 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35587 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
35588 sequence);
35589 if (!ret)
35590 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35591 index 08214bc..9208577 100644
35592 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35593 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35594 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35595 unsigned long arg)
35596 {
35597 unsigned int nr = DRM_IOCTL_NR(cmd);
35598 - drm_ioctl_compat_t *fn = NULL;
35599 + drm_ioctl_compat_t fn = NULL;
35600 int ret;
35601
35602 if (nr < DRM_COMMAND_BASE)
35603 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35604 index 25d3495..d81aaf6 100644
35605 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35606 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35607 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35608 bool can_switch;
35609
35610 spin_lock(&dev->count_lock);
35611 - can_switch = (dev->open_count == 0);
35612 + can_switch = (local_read(&dev->open_count) == 0);
35613 spin_unlock(&dev->count_lock);
35614 return can_switch;
35615 }
35616 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35617 index d4660cf..70dbe65 100644
35618 --- a/drivers/gpu/drm/r128/r128_cce.c
35619 +++ b/drivers/gpu/drm/r128/r128_cce.c
35620 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35621
35622 /* GH: Simple idle check.
35623 */
35624 - atomic_set(&dev_priv->idle_count, 0);
35625 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35626
35627 /* We don't support anything other than bus-mastering ring mode,
35628 * but the ring can be in either AGP or PCI space for the ring
35629 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35630 index 930c71b..499aded 100644
35631 --- a/drivers/gpu/drm/r128/r128_drv.h
35632 +++ b/drivers/gpu/drm/r128/r128_drv.h
35633 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35634 int is_pci;
35635 unsigned long cce_buffers_offset;
35636
35637 - atomic_t idle_count;
35638 + atomic_unchecked_t idle_count;
35639
35640 int page_flipping;
35641 int current_page;
35642 u32 crtc_offset;
35643 u32 crtc_offset_cntl;
35644
35645 - atomic_t vbl_received;
35646 + atomic_unchecked_t vbl_received;
35647
35648 u32 color_fmt;
35649 unsigned int front_offset;
35650 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35651 index a954c54..9cc595c 100644
35652 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35653 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35654 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35655 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35656 }
35657
35658 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35659 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35660 [DRM_R128_INIT] = compat_r128_init,
35661 [DRM_R128_DEPTH] = compat_r128_depth,
35662 [DRM_R128_STIPPLE] = compat_r128_stipple,
35663 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35664 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35665 {
35666 unsigned int nr = DRM_IOCTL_NR(cmd);
35667 - drm_ioctl_compat_t *fn = NULL;
35668 int ret;
35669
35670 if (nr < DRM_COMMAND_BASE)
35671 return drm_compat_ioctl(filp, cmd, arg);
35672
35673 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35674 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35675 -
35676 - if (fn != NULL)
35677 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35678 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35679 ret = (*fn) (filp, cmd, arg);
35680 - else
35681 + } else
35682 ret = drm_ioctl(filp, cmd, arg);
35683
35684 return ret;
35685 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35686 index 2ea4f09..d391371 100644
35687 --- a/drivers/gpu/drm/r128/r128_irq.c
35688 +++ b/drivers/gpu/drm/r128/r128_irq.c
35689 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35690 if (crtc != 0)
35691 return 0;
35692
35693 - return atomic_read(&dev_priv->vbl_received);
35694 + return atomic_read_unchecked(&dev_priv->vbl_received);
35695 }
35696
35697 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35698 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35699 /* VBLANK interrupt */
35700 if (status & R128_CRTC_VBLANK_INT) {
35701 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
35702 - atomic_inc(&dev_priv->vbl_received);
35703 + atomic_inc_unchecked(&dev_priv->vbl_received);
35704 drm_handle_vblank(dev, 0);
35705 return IRQ_HANDLED;
35706 }
35707 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
35708 index 19bb7e6..de7e2a2 100644
35709 --- a/drivers/gpu/drm/r128/r128_state.c
35710 +++ b/drivers/gpu/drm/r128/r128_state.c
35711 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
35712
35713 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
35714 {
35715 - if (atomic_read(&dev_priv->idle_count) == 0)
35716 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
35717 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
35718 else
35719 - atomic_set(&dev_priv->idle_count, 0);
35720 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35721 }
35722
35723 #endif
35724 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
35725 index 5a82b6b..9e69c73 100644
35726 --- a/drivers/gpu/drm/radeon/mkregtable.c
35727 +++ b/drivers/gpu/drm/radeon/mkregtable.c
35728 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
35729 regex_t mask_rex;
35730 regmatch_t match[4];
35731 char buf[1024];
35732 - size_t end;
35733 + long end;
35734 int len;
35735 int done = 0;
35736 int r;
35737 unsigned o;
35738 struct offset *offset;
35739 char last_reg_s[10];
35740 - int last_reg;
35741 + unsigned long last_reg;
35742
35743 if (regcomp
35744 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
35745 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
35746 index 44b8034..cc722fd 100644
35747 --- a/drivers/gpu/drm/radeon/radeon_device.c
35748 +++ b/drivers/gpu/drm/radeon/radeon_device.c
35749 @@ -977,7 +977,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
35750 bool can_switch;
35751
35752 spin_lock(&dev->count_lock);
35753 - can_switch = (dev->open_count == 0);
35754 + can_switch = (local_read(&dev->open_count) == 0);
35755 spin_unlock(&dev->count_lock);
35756 return can_switch;
35757 }
35758 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
35759 index b369d42..8dd04eb 100644
35760 --- a/drivers/gpu/drm/radeon/radeon_drv.h
35761 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
35762 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
35763
35764 /* SW interrupt */
35765 wait_queue_head_t swi_queue;
35766 - atomic_t swi_emitted;
35767 + atomic_unchecked_t swi_emitted;
35768 int vblank_crtc;
35769 uint32_t irq_enable_reg;
35770 uint32_t r500_disp_irq_reg;
35771 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
35772 index c180df8..5fd8186 100644
35773 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
35774 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
35775 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35776 request = compat_alloc_user_space(sizeof(*request));
35777 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
35778 || __put_user(req32.param, &request->param)
35779 - || __put_user((void __user *)(unsigned long)req32.value,
35780 + || __put_user((unsigned long)req32.value,
35781 &request->value))
35782 return -EFAULT;
35783
35784 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35785 #define compat_radeon_cp_setparam NULL
35786 #endif /* X86_64 || IA64 */
35787
35788 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35789 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
35790 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
35791 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
35792 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
35793 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35794 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35795 {
35796 unsigned int nr = DRM_IOCTL_NR(cmd);
35797 - drm_ioctl_compat_t *fn = NULL;
35798 int ret;
35799
35800 if (nr < DRM_COMMAND_BASE)
35801 return drm_compat_ioctl(filp, cmd, arg);
35802
35803 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
35804 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35805 -
35806 - if (fn != NULL)
35807 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
35808 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35809 ret = (*fn) (filp, cmd, arg);
35810 - else
35811 + } else
35812 ret = drm_ioctl(filp, cmd, arg);
35813
35814 return ret;
35815 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
35816 index 8d68e97..9dcfed8 100644
35817 --- a/drivers/gpu/drm/radeon/radeon_irq.c
35818 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
35819 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
35820 unsigned int ret;
35821 RING_LOCALS;
35822
35823 - atomic_inc(&dev_priv->swi_emitted);
35824 - ret = atomic_read(&dev_priv->swi_emitted);
35825 + atomic_inc_unchecked(&dev_priv->swi_emitted);
35826 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
35827
35828 BEGIN_RING(4);
35829 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
35830 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
35831 drm_radeon_private_t *dev_priv =
35832 (drm_radeon_private_t *) dev->dev_private;
35833
35834 - atomic_set(&dev_priv->swi_emitted, 0);
35835 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
35836 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
35837
35838 dev->max_vblank_count = 0x001fffff;
35839 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
35840 index 4d20910..6726b6d 100644
35841 --- a/drivers/gpu/drm/radeon/radeon_state.c
35842 +++ b/drivers/gpu/drm/radeon/radeon_state.c
35843 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
35844 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
35845 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
35846
35847 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35848 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35849 sarea_priv->nbox * sizeof(depth_boxes[0])))
35850 return -EFAULT;
35851
35852 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
35853 {
35854 drm_radeon_private_t *dev_priv = dev->dev_private;
35855 drm_radeon_getparam_t *param = data;
35856 - int value;
35857 + int value = 0;
35858
35859 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
35860
35861 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
35862 index 6c0ce89..66f6d65 100644
35863 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
35864 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
35865 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
35866 man->size = size >> PAGE_SHIFT;
35867 }
35868
35869 -static struct vm_operations_struct radeon_ttm_vm_ops;
35870 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
35871 static const struct vm_operations_struct *ttm_vm_ops = NULL;
35872
35873 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
35874 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
35875 }
35876 if (unlikely(ttm_vm_ops == NULL)) {
35877 ttm_vm_ops = vma->vm_ops;
35878 + pax_open_kernel();
35879 radeon_ttm_vm_ops = *ttm_vm_ops;
35880 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
35881 + pax_close_kernel();
35882 }
35883 vma->vm_ops = &radeon_ttm_vm_ops;
35884 return 0;
35885 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
35886 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
35887 else
35888 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
35889 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35890 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35891 - radeon_mem_types_list[i].driver_features = 0;
35892 + pax_open_kernel();
35893 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35894 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35895 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35896 if (i == 0)
35897 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35898 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35899 else
35900 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35901 -
35902 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35903 + pax_close_kernel();
35904 }
35905 /* Add ttm page pool to debugfs */
35906 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
35907 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35908 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35909 - radeon_mem_types_list[i].driver_features = 0;
35910 - radeon_mem_types_list[i++].data = NULL;
35911 + pax_open_kernel();
35912 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35913 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35914 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35915 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35916 + pax_close_kernel();
35917 #ifdef CONFIG_SWIOTLB
35918 if (swiotlb_nr_tbl()) {
35919 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
35920 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35921 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35922 - radeon_mem_types_list[i].driver_features = 0;
35923 - radeon_mem_types_list[i++].data = NULL;
35924 + pax_open_kernel();
35925 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35926 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35927 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35928 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35929 + pax_close_kernel();
35930 }
35931 #endif
35932 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
35933 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
35934 index 5706d2a..17aedaa 100644
35935 --- a/drivers/gpu/drm/radeon/rs690.c
35936 +++ b/drivers/gpu/drm/radeon/rs690.c
35937 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
35938 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
35939 rdev->pm.sideport_bandwidth.full)
35940 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
35941 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
35942 + read_delay_latency.full = dfixed_const(800 * 1000);
35943 read_delay_latency.full = dfixed_div(read_delay_latency,
35944 rdev->pm.igp_sideport_mclk);
35945 + a.full = dfixed_const(370);
35946 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
35947 } else {
35948 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
35949 rdev->pm.k8_bandwidth.full)
35950 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35951 index bd2a3b4..122d9ad 100644
35952 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
35953 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35954 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
35955 static int ttm_pool_mm_shrink(struct shrinker *shrink,
35956 struct shrink_control *sc)
35957 {
35958 - static atomic_t start_pool = ATOMIC_INIT(0);
35959 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
35960 unsigned i;
35961 - unsigned pool_offset = atomic_add_return(1, &start_pool);
35962 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
35963 struct ttm_page_pool *pool;
35964 int shrink_pages = sc->nr_to_scan;
35965
35966 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
35967 index 9f4be3d..cbc9fcc 100644
35968 --- a/drivers/gpu/drm/udl/udl_fb.c
35969 +++ b/drivers/gpu/drm/udl/udl_fb.c
35970 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
35971 fb_deferred_io_cleanup(info);
35972 kfree(info->fbdefio);
35973 info->fbdefio = NULL;
35974 - info->fbops->fb_mmap = udl_fb_mmap;
35975 }
35976
35977 pr_warn("released /dev/fb%d user=%d count=%d\n",
35978 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
35979 index 893a650..6190d3b 100644
35980 --- a/drivers/gpu/drm/via/via_drv.h
35981 +++ b/drivers/gpu/drm/via/via_drv.h
35982 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
35983 typedef uint32_t maskarray_t[5];
35984
35985 typedef struct drm_via_irq {
35986 - atomic_t irq_received;
35987 + atomic_unchecked_t irq_received;
35988 uint32_t pending_mask;
35989 uint32_t enable_mask;
35990 wait_queue_head_t irq_queue;
35991 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
35992 struct timeval last_vblank;
35993 int last_vblank_valid;
35994 unsigned usec_per_vblank;
35995 - atomic_t vbl_received;
35996 + atomic_unchecked_t vbl_received;
35997 drm_via_state_t hc_state;
35998 char pci_buf[VIA_PCI_BUF_SIZE];
35999 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36000 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36001 index ac98964..5dbf512 100644
36002 --- a/drivers/gpu/drm/via/via_irq.c
36003 +++ b/drivers/gpu/drm/via/via_irq.c
36004 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36005 if (crtc != 0)
36006 return 0;
36007
36008 - return atomic_read(&dev_priv->vbl_received);
36009 + return atomic_read_unchecked(&dev_priv->vbl_received);
36010 }
36011
36012 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36013 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36014
36015 status = VIA_READ(VIA_REG_INTERRUPT);
36016 if (status & VIA_IRQ_VBLANK_PENDING) {
36017 - atomic_inc(&dev_priv->vbl_received);
36018 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36019 + atomic_inc_unchecked(&dev_priv->vbl_received);
36020 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36021 do_gettimeofday(&cur_vblank);
36022 if (dev_priv->last_vblank_valid) {
36023 dev_priv->usec_per_vblank =
36024 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36025 dev_priv->last_vblank = cur_vblank;
36026 dev_priv->last_vblank_valid = 1;
36027 }
36028 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36029 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36030 DRM_DEBUG("US per vblank is: %u\n",
36031 dev_priv->usec_per_vblank);
36032 }
36033 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36034
36035 for (i = 0; i < dev_priv->num_irqs; ++i) {
36036 if (status & cur_irq->pending_mask) {
36037 - atomic_inc(&cur_irq->irq_received);
36038 + atomic_inc_unchecked(&cur_irq->irq_received);
36039 DRM_WAKEUP(&cur_irq->irq_queue);
36040 handled = 1;
36041 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36042 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36043 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36044 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36045 masks[irq][4]));
36046 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36047 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36048 } else {
36049 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36050 (((cur_irq_sequence =
36051 - atomic_read(&cur_irq->irq_received)) -
36052 + atomic_read_unchecked(&cur_irq->irq_received)) -
36053 *sequence) <= (1 << 23)));
36054 }
36055 *sequence = cur_irq_sequence;
36056 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36057 }
36058
36059 for (i = 0; i < dev_priv->num_irqs; ++i) {
36060 - atomic_set(&cur_irq->irq_received, 0);
36061 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36062 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36063 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36064 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36065 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36066 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36067 case VIA_IRQ_RELATIVE:
36068 irqwait->request.sequence +=
36069 - atomic_read(&cur_irq->irq_received);
36070 + atomic_read_unchecked(&cur_irq->irq_received);
36071 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36072 case VIA_IRQ_ABSOLUTE:
36073 break;
36074 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36075 index 13aeda7..4a952d1 100644
36076 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36077 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36078 @@ -290,7 +290,7 @@ struct vmw_private {
36079 * Fencing and IRQs.
36080 */
36081
36082 - atomic_t marker_seq;
36083 + atomic_unchecked_t marker_seq;
36084 wait_queue_head_t fence_queue;
36085 wait_queue_head_t fifo_queue;
36086 int fence_queue_waiters; /* Protected by hw_mutex */
36087 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36088 index 3eb1486..0a47ee9 100644
36089 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36090 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36091 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36092 (unsigned int) min,
36093 (unsigned int) fifo->capabilities);
36094
36095 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36096 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36097 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36098 vmw_marker_queue_init(&fifo->marker_queue);
36099 return vmw_fifo_send_fence(dev_priv, &dummy);
36100 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36101 if (reserveable)
36102 iowrite32(bytes, fifo_mem +
36103 SVGA_FIFO_RESERVED);
36104 - return fifo_mem + (next_cmd >> 2);
36105 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36106 } else {
36107 need_bounce = true;
36108 }
36109 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36110
36111 fm = vmw_fifo_reserve(dev_priv, bytes);
36112 if (unlikely(fm == NULL)) {
36113 - *seqno = atomic_read(&dev_priv->marker_seq);
36114 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36115 ret = -ENOMEM;
36116 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36117 false, 3*HZ);
36118 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36119 }
36120
36121 do {
36122 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36123 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36124 } while (*seqno == 0);
36125
36126 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36127 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36128 index c509d40..3b640c3 100644
36129 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36130 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36131 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
36132 int ret;
36133
36134 num_clips = arg->num_clips;
36135 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36136 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36137
36138 if (unlikely(num_clips == 0))
36139 return 0;
36140 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
36141 int ret;
36142
36143 num_clips = arg->num_clips;
36144 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36145 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36146
36147 if (unlikely(num_clips == 0))
36148 return 0;
36149 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36150 index 4640adb..e1384ed 100644
36151 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36152 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36153 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36154 * emitted. Then the fence is stale and signaled.
36155 */
36156
36157 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36158 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36159 > VMW_FENCE_WRAP);
36160
36161 return ret;
36162 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36163
36164 if (fifo_idle)
36165 down_read(&fifo_state->rwsem);
36166 - signal_seq = atomic_read(&dev_priv->marker_seq);
36167 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36168 ret = 0;
36169
36170 for (;;) {
36171 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36172 index 8a8725c2..afed796 100644
36173 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36174 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36175 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36176 while (!vmw_lag_lt(queue, us)) {
36177 spin_lock(&queue->lock);
36178 if (list_empty(&queue->head))
36179 - seqno = atomic_read(&dev_priv->marker_seq);
36180 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36181 else {
36182 marker = list_first_entry(&queue->head,
36183 struct vmw_marker, head);
36184 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36185 index e6dbf09..3dd2540 100644
36186 --- a/drivers/hid/hid-core.c
36187 +++ b/drivers/hid/hid-core.c
36188 @@ -2268,7 +2268,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36189
36190 int hid_add_device(struct hid_device *hdev)
36191 {
36192 - static atomic_t id = ATOMIC_INIT(0);
36193 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36194 int ret;
36195
36196 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36197 @@ -2302,7 +2302,7 @@ int hid_add_device(struct hid_device *hdev)
36198 /* XXX hack, any other cleaner solution after the driver core
36199 * is converted to allow more than 20 bytes as the device name? */
36200 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36201 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36202 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36203
36204 hid_debug_register(hdev, dev_name(&hdev->dev));
36205 ret = device_add(&hdev->dev);
36206 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36207 index 90124ff..3761764 100644
36208 --- a/drivers/hid/hid-wiimote-debug.c
36209 +++ b/drivers/hid/hid-wiimote-debug.c
36210 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36211 else if (size == 0)
36212 return -EIO;
36213
36214 - if (copy_to_user(u, buf, size))
36215 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36216 return -EFAULT;
36217
36218 *off += size;
36219 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36220 index 0b122f8..b1d8160 100644
36221 --- a/drivers/hv/channel.c
36222 +++ b/drivers/hv/channel.c
36223 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36224 int ret = 0;
36225 int t;
36226
36227 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36228 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36229 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36230 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36231
36232 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36233 if (ret)
36234 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36235 index 7311589..861e9ef 100644
36236 --- a/drivers/hv/hv.c
36237 +++ b/drivers/hv/hv.c
36238 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36239 u64 output_address = (output) ? virt_to_phys(output) : 0;
36240 u32 output_address_hi = output_address >> 32;
36241 u32 output_address_lo = output_address & 0xFFFFFFFF;
36242 - void *hypercall_page = hv_context.hypercall_page;
36243 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36244
36245 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36246 "=a"(hv_status_lo) : "d" (control_hi),
36247 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36248 index 12f2f9e..679603c 100644
36249 --- a/drivers/hv/hyperv_vmbus.h
36250 +++ b/drivers/hv/hyperv_vmbus.h
36251 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36252 struct vmbus_connection {
36253 enum vmbus_connect_state conn_state;
36254
36255 - atomic_t next_gpadl_handle;
36256 + atomic_unchecked_t next_gpadl_handle;
36257
36258 /*
36259 * Represents channel interrupts. Each bit position represents a
36260 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36261 index bf421e0..ce2c897 100644
36262 --- a/drivers/hv/vmbus_drv.c
36263 +++ b/drivers/hv/vmbus_drv.c
36264 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36265 {
36266 int ret = 0;
36267
36268 - static atomic_t device_num = ATOMIC_INIT(0);
36269 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36270
36271 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36272 - atomic_inc_return(&device_num));
36273 + atomic_inc_return_unchecked(&device_num));
36274
36275 child_device_obj->device.bus = &hv_bus;
36276 child_device_obj->device.parent = &hv_acpi_dev->dev;
36277 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36278 index 6351aba..dc4aaf4 100644
36279 --- a/drivers/hwmon/acpi_power_meter.c
36280 +++ b/drivers/hwmon/acpi_power_meter.c
36281 @@ -117,7 +117,7 @@ struct sensor_template {
36282 struct device_attribute *devattr,
36283 const char *buf, size_t count);
36284 int index;
36285 -};
36286 +} __do_const;
36287
36288 /* Averaging interval */
36289 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36290 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36291 struct sensor_template *attrs)
36292 {
36293 struct device *dev = &resource->acpi_dev->dev;
36294 - struct sensor_device_attribute *sensors =
36295 + sensor_device_attribute_no_const *sensors =
36296 &resource->sensors[resource->num_sensors];
36297 int res = 0;
36298
36299 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36300 index b41baff..4953e4d 100644
36301 --- a/drivers/hwmon/applesmc.c
36302 +++ b/drivers/hwmon/applesmc.c
36303 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36304 {
36305 struct applesmc_node_group *grp;
36306 struct applesmc_dev_attr *node;
36307 - struct attribute *attr;
36308 + attribute_no_const *attr;
36309 int ret, i;
36310
36311 for (grp = groups; grp->format; grp++) {
36312 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36313 index b25c643..a13460d 100644
36314 --- a/drivers/hwmon/asus_atk0110.c
36315 +++ b/drivers/hwmon/asus_atk0110.c
36316 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36317 struct atk_sensor_data {
36318 struct list_head list;
36319 struct atk_data *data;
36320 - struct device_attribute label_attr;
36321 - struct device_attribute input_attr;
36322 - struct device_attribute limit1_attr;
36323 - struct device_attribute limit2_attr;
36324 + device_attribute_no_const label_attr;
36325 + device_attribute_no_const input_attr;
36326 + device_attribute_no_const limit1_attr;
36327 + device_attribute_no_const limit2_attr;
36328 char label_attr_name[ATTR_NAME_SIZE];
36329 char input_attr_name[ATTR_NAME_SIZE];
36330 char limit1_attr_name[ATTR_NAME_SIZE];
36331 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36332 static struct device_attribute atk_name_attr =
36333 __ATTR(name, 0444, atk_name_show, NULL);
36334
36335 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36336 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36337 sysfs_show_func show)
36338 {
36339 sysfs_attr_init(&attr->attr);
36340 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36341 index 3f1e297..a6cafb5 100644
36342 --- a/drivers/hwmon/coretemp.c
36343 +++ b/drivers/hwmon/coretemp.c
36344 @@ -791,7 +791,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36345 return NOTIFY_OK;
36346 }
36347
36348 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36349 +static struct notifier_block coretemp_cpu_notifier = {
36350 .notifier_call = coretemp_cpu_callback,
36351 };
36352
36353 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36354 index a14f634..2916ee2 100644
36355 --- a/drivers/hwmon/ibmaem.c
36356 +++ b/drivers/hwmon/ibmaem.c
36357 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36358 struct aem_rw_sensor_template *rw)
36359 {
36360 struct device *dev = &data->pdev->dev;
36361 - struct sensor_device_attribute *sensors = data->sensors;
36362 + sensor_device_attribute_no_const *sensors = data->sensors;
36363 int err;
36364
36365 /* Set up read-only sensors */
36366 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36367 index 9add6092..ee7ba3f 100644
36368 --- a/drivers/hwmon/pmbus/pmbus_core.c
36369 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36370 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
36371 return 0;
36372 }
36373
36374 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36375 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
36376 const char *name,
36377 umode_t mode,
36378 ssize_t (*show)(struct device *dev,
36379 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36380 dev_attr->store = store;
36381 }
36382
36383 -static void pmbus_attr_init(struct sensor_device_attribute *a,
36384 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
36385 const char *name,
36386 umode_t mode,
36387 ssize_t (*show)(struct device *dev,
36388 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
36389 u16 reg, u8 mask)
36390 {
36391 struct pmbus_boolean *boolean;
36392 - struct sensor_device_attribute *a;
36393 + sensor_device_attribute_no_const *a;
36394
36395 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
36396 if (!boolean)
36397 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
36398 bool update, bool readonly)
36399 {
36400 struct pmbus_sensor *sensor;
36401 - struct device_attribute *a;
36402 + device_attribute_no_const *a;
36403
36404 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
36405 if (!sensor)
36406 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
36407 const char *lstring, int index)
36408 {
36409 struct pmbus_label *label;
36410 - struct device_attribute *a;
36411 + device_attribute_no_const *a;
36412
36413 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
36414 if (!label)
36415 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36416 index 2507f90..1645765 100644
36417 --- a/drivers/hwmon/sht15.c
36418 +++ b/drivers/hwmon/sht15.c
36419 @@ -169,7 +169,7 @@ struct sht15_data {
36420 int supply_uv;
36421 bool supply_uv_valid;
36422 struct work_struct update_supply_work;
36423 - atomic_t interrupt_handled;
36424 + atomic_unchecked_t interrupt_handled;
36425 };
36426
36427 /**
36428 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36429 ret = gpio_direction_input(data->pdata->gpio_data);
36430 if (ret)
36431 return ret;
36432 - atomic_set(&data->interrupt_handled, 0);
36433 + atomic_set_unchecked(&data->interrupt_handled, 0);
36434
36435 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36436 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36437 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36438 /* Only relevant if the interrupt hasn't occurred. */
36439 - if (!atomic_read(&data->interrupt_handled))
36440 + if (!atomic_read_unchecked(&data->interrupt_handled))
36441 schedule_work(&data->read_work);
36442 }
36443 ret = wait_event_timeout(data->wait_queue,
36444 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36445
36446 /* First disable the interrupt */
36447 disable_irq_nosync(irq);
36448 - atomic_inc(&data->interrupt_handled);
36449 + atomic_inc_unchecked(&data->interrupt_handled);
36450 /* Then schedule a reading work struct */
36451 if (data->state != SHT15_READING_NOTHING)
36452 schedule_work(&data->read_work);
36453 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36454 * If not, then start the interrupt again - care here as could
36455 * have gone low in meantime so verify it hasn't!
36456 */
36457 - atomic_set(&data->interrupt_handled, 0);
36458 + atomic_set_unchecked(&data->interrupt_handled, 0);
36459 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36460 /* If still not occurred or another handler was scheduled */
36461 if (gpio_get_value(data->pdata->gpio_data)
36462 - || atomic_read(&data->interrupt_handled))
36463 + || atomic_read_unchecked(&data->interrupt_handled))
36464 return;
36465 }
36466
36467 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36468 index 76f157b..9c0db1b 100644
36469 --- a/drivers/hwmon/via-cputemp.c
36470 +++ b/drivers/hwmon/via-cputemp.c
36471 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36472 return NOTIFY_OK;
36473 }
36474
36475 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36476 +static struct notifier_block via_cputemp_cpu_notifier = {
36477 .notifier_call = via_cputemp_cpu_callback,
36478 };
36479
36480 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36481 index 378fcb5..5e91fa8 100644
36482 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36483 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36484 @@ -43,7 +43,7 @@
36485 extern struct i2c_adapter amd756_smbus;
36486
36487 static struct i2c_adapter *s4882_adapter;
36488 -static struct i2c_algorithm *s4882_algo;
36489 +static i2c_algorithm_no_const *s4882_algo;
36490
36491 /* Wrapper access functions for multiplexed SMBus */
36492 static DEFINE_MUTEX(amd756_lock);
36493 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36494 index 29015eb..af2d8e9 100644
36495 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36496 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36497 @@ -41,7 +41,7 @@
36498 extern struct i2c_adapter *nforce2_smbus;
36499
36500 static struct i2c_adapter *s4985_adapter;
36501 -static struct i2c_algorithm *s4985_algo;
36502 +static i2c_algorithm_no_const *s4985_algo;
36503
36504 /* Wrapper access functions for multiplexed SMBus */
36505 static DEFINE_MUTEX(nforce2_lock);
36506 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
36507 index c3ccdea..5b3dc1a 100644
36508 --- a/drivers/i2c/i2c-dev.c
36509 +++ b/drivers/i2c/i2c-dev.c
36510 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
36511 break;
36512 }
36513
36514 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
36515 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
36516 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
36517 if (IS_ERR(rdwr_pa[i].buf)) {
36518 res = PTR_ERR(rdwr_pa[i].buf);
36519 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36520 index 8126824..55a2798 100644
36521 --- a/drivers/ide/ide-cd.c
36522 +++ b/drivers/ide/ide-cd.c
36523 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36524 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36525 if ((unsigned long)buf & alignment
36526 || blk_rq_bytes(rq) & q->dma_pad_mask
36527 - || object_is_on_stack(buf))
36528 + || object_starts_on_stack(buf))
36529 drive->dma = 0;
36530 }
36531 }
36532 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36533 index 8848f16..f8e6dd8 100644
36534 --- a/drivers/iio/industrialio-core.c
36535 +++ b/drivers/iio/industrialio-core.c
36536 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36537 }
36538
36539 static
36540 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36541 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36542 const char *postfix,
36543 struct iio_chan_spec const *chan,
36544 ssize_t (*readfunc)(struct device *dev,
36545 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36546 index 784b97c..c9ceadf 100644
36547 --- a/drivers/infiniband/core/cm.c
36548 +++ b/drivers/infiniband/core/cm.c
36549 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36550
36551 struct cm_counter_group {
36552 struct kobject obj;
36553 - atomic_long_t counter[CM_ATTR_COUNT];
36554 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36555 };
36556
36557 struct cm_counter_attribute {
36558 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36559 struct ib_mad_send_buf *msg = NULL;
36560 int ret;
36561
36562 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36563 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36564 counter[CM_REQ_COUNTER]);
36565
36566 /* Quick state check to discard duplicate REQs. */
36567 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36568 if (!cm_id_priv)
36569 return;
36570
36571 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36572 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36573 counter[CM_REP_COUNTER]);
36574 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36575 if (ret)
36576 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
36577 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36578 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36579 spin_unlock_irq(&cm_id_priv->lock);
36580 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36581 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36582 counter[CM_RTU_COUNTER]);
36583 goto out;
36584 }
36585 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
36586 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36587 dreq_msg->local_comm_id);
36588 if (!cm_id_priv) {
36589 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36590 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36591 counter[CM_DREQ_COUNTER]);
36592 cm_issue_drep(work->port, work->mad_recv_wc);
36593 return -EINVAL;
36594 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
36595 case IB_CM_MRA_REP_RCVD:
36596 break;
36597 case IB_CM_TIMEWAIT:
36598 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36599 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36600 counter[CM_DREQ_COUNTER]);
36601 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36602 goto unlock;
36603 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
36604 cm_free_msg(msg);
36605 goto deref;
36606 case IB_CM_DREQ_RCVD:
36607 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36608 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36609 counter[CM_DREQ_COUNTER]);
36610 goto unlock;
36611 default:
36612 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
36613 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36614 cm_id_priv->msg, timeout)) {
36615 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36616 - atomic_long_inc(&work->port->
36617 + atomic_long_inc_unchecked(&work->port->
36618 counter_group[CM_RECV_DUPLICATES].
36619 counter[CM_MRA_COUNTER]);
36620 goto out;
36621 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
36622 break;
36623 case IB_CM_MRA_REQ_RCVD:
36624 case IB_CM_MRA_REP_RCVD:
36625 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36626 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36627 counter[CM_MRA_COUNTER]);
36628 /* fall through */
36629 default:
36630 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
36631 case IB_CM_LAP_IDLE:
36632 break;
36633 case IB_CM_MRA_LAP_SENT:
36634 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36635 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36636 counter[CM_LAP_COUNTER]);
36637 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36638 goto unlock;
36639 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
36640 cm_free_msg(msg);
36641 goto deref;
36642 case IB_CM_LAP_RCVD:
36643 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36644 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36645 counter[CM_LAP_COUNTER]);
36646 goto unlock;
36647 default:
36648 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36649 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36650 if (cur_cm_id_priv) {
36651 spin_unlock_irq(&cm.lock);
36652 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36653 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36654 counter[CM_SIDR_REQ_COUNTER]);
36655 goto out; /* Duplicate message. */
36656 }
36657 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36658 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36659 msg->retries = 1;
36660
36661 - atomic_long_add(1 + msg->retries,
36662 + atomic_long_add_unchecked(1 + msg->retries,
36663 &port->counter_group[CM_XMIT].counter[attr_index]);
36664 if (msg->retries)
36665 - atomic_long_add(msg->retries,
36666 + atomic_long_add_unchecked(msg->retries,
36667 &port->counter_group[CM_XMIT_RETRIES].
36668 counter[attr_index]);
36669
36670 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36671 }
36672
36673 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36674 - atomic_long_inc(&port->counter_group[CM_RECV].
36675 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36676 counter[attr_id - CM_ATTR_ID_OFFSET]);
36677
36678 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36679 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36680 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36681
36682 return sprintf(buf, "%ld\n",
36683 - atomic_long_read(&group->counter[cm_attr->index]));
36684 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36685 }
36686
36687 static const struct sysfs_ops cm_counter_ops = {
36688 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36689 index 9f5ad7c..588cd84 100644
36690 --- a/drivers/infiniband/core/fmr_pool.c
36691 +++ b/drivers/infiniband/core/fmr_pool.c
36692 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36693
36694 struct task_struct *thread;
36695
36696 - atomic_t req_ser;
36697 - atomic_t flush_ser;
36698 + atomic_unchecked_t req_ser;
36699 + atomic_unchecked_t flush_ser;
36700
36701 wait_queue_head_t force_wait;
36702 };
36703 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36704 struct ib_fmr_pool *pool = pool_ptr;
36705
36706 do {
36707 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36708 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36709 ib_fmr_batch_release(pool);
36710
36711 - atomic_inc(&pool->flush_ser);
36712 + atomic_inc_unchecked(&pool->flush_ser);
36713 wake_up_interruptible(&pool->force_wait);
36714
36715 if (pool->flush_function)
36716 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36717 }
36718
36719 set_current_state(TASK_INTERRUPTIBLE);
36720 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36721 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36722 !kthread_should_stop())
36723 schedule();
36724 __set_current_state(TASK_RUNNING);
36725 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36726 pool->dirty_watermark = params->dirty_watermark;
36727 pool->dirty_len = 0;
36728 spin_lock_init(&pool->pool_lock);
36729 - atomic_set(&pool->req_ser, 0);
36730 - atomic_set(&pool->flush_ser, 0);
36731 + atomic_set_unchecked(&pool->req_ser, 0);
36732 + atomic_set_unchecked(&pool->flush_ser, 0);
36733 init_waitqueue_head(&pool->force_wait);
36734
36735 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36736 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36737 }
36738 spin_unlock_irq(&pool->pool_lock);
36739
36740 - serial = atomic_inc_return(&pool->req_ser);
36741 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36742 wake_up_process(pool->thread);
36743
36744 if (wait_event_interruptible(pool->force_wait,
36745 - atomic_read(&pool->flush_ser) - serial >= 0))
36746 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
36747 return -EINTR;
36748
36749 return 0;
36750 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
36751 } else {
36752 list_add_tail(&fmr->list, &pool->dirty_list);
36753 if (++pool->dirty_len >= pool->dirty_watermark) {
36754 - atomic_inc(&pool->req_ser);
36755 + atomic_inc_unchecked(&pool->req_ser);
36756 wake_up_process(pool->thread);
36757 }
36758 }
36759 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
36760 index 903a92d..9262548 100644
36761 --- a/drivers/infiniband/hw/cxgb4/mem.c
36762 +++ b/drivers/infiniband/hw/cxgb4/mem.c
36763 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36764 int err;
36765 struct fw_ri_tpte tpt;
36766 u32 stag_idx;
36767 - static atomic_t key;
36768 + static atomic_unchecked_t key;
36769
36770 if (c4iw_fatal_error(rdev))
36771 return -EIO;
36772 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36773 if (rdev->stats.stag.cur > rdev->stats.stag.max)
36774 rdev->stats.stag.max = rdev->stats.stag.cur;
36775 mutex_unlock(&rdev->stats.lock);
36776 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
36777 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
36778 }
36779 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
36780 __func__, stag_state, type, pdid, stag_idx);
36781 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
36782 index 79b3dbc..96e5fcc 100644
36783 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
36784 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
36785 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36786 struct ib_atomic_eth *ateth;
36787 struct ipath_ack_entry *e;
36788 u64 vaddr;
36789 - atomic64_t *maddr;
36790 + atomic64_unchecked_t *maddr;
36791 u64 sdata;
36792 u32 rkey;
36793 u8 next;
36794 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36795 IB_ACCESS_REMOTE_ATOMIC)))
36796 goto nack_acc_unlck;
36797 /* Perform atomic OP and save result. */
36798 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36799 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36800 sdata = be64_to_cpu(ateth->swap_data);
36801 e = &qp->s_ack_queue[qp->r_head_ack_queue];
36802 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
36803 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36804 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36805 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36806 be64_to_cpu(ateth->compare_data),
36807 sdata);
36808 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
36809 index 1f95bba..9530f87 100644
36810 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
36811 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
36812 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
36813 unsigned long flags;
36814 struct ib_wc wc;
36815 u64 sdata;
36816 - atomic64_t *maddr;
36817 + atomic64_unchecked_t *maddr;
36818 enum ib_wc_status send_status;
36819
36820 /*
36821 @@ -382,11 +382,11 @@ again:
36822 IB_ACCESS_REMOTE_ATOMIC)))
36823 goto acc_err;
36824 /* Perform atomic OP and save result. */
36825 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36826 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36827 sdata = wqe->wr.wr.atomic.compare_add;
36828 *(u64 *) sqp->s_sge.sge.vaddr =
36829 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
36830 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36831 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36832 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36833 sdata, wqe->wr.wr.atomic.swap);
36834 goto send_comp;
36835 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
36836 index 9d3e5c1..d9afe4a 100644
36837 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
36838 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
36839 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
36840 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
36841 }
36842
36843 -int mthca_QUERY_FW(struct mthca_dev *dev)
36844 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
36845 {
36846 struct mthca_mailbox *mailbox;
36847 u32 *outbox;
36848 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
36849 index ed9a989..e0c5871 100644
36850 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
36851 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
36852 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
36853 return key;
36854 }
36855
36856 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36857 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36858 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
36859 {
36860 struct mthca_mailbox *mailbox;
36861 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
36862 index 4291410..d2ab1fb 100644
36863 --- a/drivers/infiniband/hw/nes/nes.c
36864 +++ b/drivers/infiniband/hw/nes/nes.c
36865 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
36866 LIST_HEAD(nes_adapter_list);
36867 static LIST_HEAD(nes_dev_list);
36868
36869 -atomic_t qps_destroyed;
36870 +atomic_unchecked_t qps_destroyed;
36871
36872 static unsigned int ee_flsh_adapter;
36873 static unsigned int sysfs_nonidx_addr;
36874 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
36875 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
36876 struct nes_adapter *nesadapter = nesdev->nesadapter;
36877
36878 - atomic_inc(&qps_destroyed);
36879 + atomic_inc_unchecked(&qps_destroyed);
36880
36881 /* Free the control structures */
36882
36883 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
36884 index 33cc589..3bd6538 100644
36885 --- a/drivers/infiniband/hw/nes/nes.h
36886 +++ b/drivers/infiniband/hw/nes/nes.h
36887 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
36888 extern unsigned int wqm_quanta;
36889 extern struct list_head nes_adapter_list;
36890
36891 -extern atomic_t cm_connects;
36892 -extern atomic_t cm_accepts;
36893 -extern atomic_t cm_disconnects;
36894 -extern atomic_t cm_closes;
36895 -extern atomic_t cm_connecteds;
36896 -extern atomic_t cm_connect_reqs;
36897 -extern atomic_t cm_rejects;
36898 -extern atomic_t mod_qp_timouts;
36899 -extern atomic_t qps_created;
36900 -extern atomic_t qps_destroyed;
36901 -extern atomic_t sw_qps_destroyed;
36902 +extern atomic_unchecked_t cm_connects;
36903 +extern atomic_unchecked_t cm_accepts;
36904 +extern atomic_unchecked_t cm_disconnects;
36905 +extern atomic_unchecked_t cm_closes;
36906 +extern atomic_unchecked_t cm_connecteds;
36907 +extern atomic_unchecked_t cm_connect_reqs;
36908 +extern atomic_unchecked_t cm_rejects;
36909 +extern atomic_unchecked_t mod_qp_timouts;
36910 +extern atomic_unchecked_t qps_created;
36911 +extern atomic_unchecked_t qps_destroyed;
36912 +extern atomic_unchecked_t sw_qps_destroyed;
36913 extern u32 mh_detected;
36914 extern u32 mh_pauses_sent;
36915 extern u32 cm_packets_sent;
36916 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
36917 extern u32 cm_packets_received;
36918 extern u32 cm_packets_dropped;
36919 extern u32 cm_packets_retrans;
36920 -extern atomic_t cm_listens_created;
36921 -extern atomic_t cm_listens_destroyed;
36922 +extern atomic_unchecked_t cm_listens_created;
36923 +extern atomic_unchecked_t cm_listens_destroyed;
36924 extern u32 cm_backlog_drops;
36925 -extern atomic_t cm_loopbacks;
36926 -extern atomic_t cm_nodes_created;
36927 -extern atomic_t cm_nodes_destroyed;
36928 -extern atomic_t cm_accel_dropped_pkts;
36929 -extern atomic_t cm_resets_recvd;
36930 -extern atomic_t pau_qps_created;
36931 -extern atomic_t pau_qps_destroyed;
36932 +extern atomic_unchecked_t cm_loopbacks;
36933 +extern atomic_unchecked_t cm_nodes_created;
36934 +extern atomic_unchecked_t cm_nodes_destroyed;
36935 +extern atomic_unchecked_t cm_accel_dropped_pkts;
36936 +extern atomic_unchecked_t cm_resets_recvd;
36937 +extern atomic_unchecked_t pau_qps_created;
36938 +extern atomic_unchecked_t pau_qps_destroyed;
36939
36940 extern u32 int_mod_timer_init;
36941 extern u32 int_mod_cq_depth_256;
36942 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
36943 index 24b9f1a..00fd004 100644
36944 --- a/drivers/infiniband/hw/nes/nes_cm.c
36945 +++ b/drivers/infiniband/hw/nes/nes_cm.c
36946 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
36947 u32 cm_packets_retrans;
36948 u32 cm_packets_created;
36949 u32 cm_packets_received;
36950 -atomic_t cm_listens_created;
36951 -atomic_t cm_listens_destroyed;
36952 +atomic_unchecked_t cm_listens_created;
36953 +atomic_unchecked_t cm_listens_destroyed;
36954 u32 cm_backlog_drops;
36955 -atomic_t cm_loopbacks;
36956 -atomic_t cm_nodes_created;
36957 -atomic_t cm_nodes_destroyed;
36958 -atomic_t cm_accel_dropped_pkts;
36959 -atomic_t cm_resets_recvd;
36960 +atomic_unchecked_t cm_loopbacks;
36961 +atomic_unchecked_t cm_nodes_created;
36962 +atomic_unchecked_t cm_nodes_destroyed;
36963 +atomic_unchecked_t cm_accel_dropped_pkts;
36964 +atomic_unchecked_t cm_resets_recvd;
36965
36966 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
36967 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
36968 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
36969
36970 static struct nes_cm_core *g_cm_core;
36971
36972 -atomic_t cm_connects;
36973 -atomic_t cm_accepts;
36974 -atomic_t cm_disconnects;
36975 -atomic_t cm_closes;
36976 -atomic_t cm_connecteds;
36977 -atomic_t cm_connect_reqs;
36978 -atomic_t cm_rejects;
36979 +atomic_unchecked_t cm_connects;
36980 +atomic_unchecked_t cm_accepts;
36981 +atomic_unchecked_t cm_disconnects;
36982 +atomic_unchecked_t cm_closes;
36983 +atomic_unchecked_t cm_connecteds;
36984 +atomic_unchecked_t cm_connect_reqs;
36985 +atomic_unchecked_t cm_rejects;
36986
36987 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
36988 {
36989 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
36990 kfree(listener);
36991 listener = NULL;
36992 ret = 0;
36993 - atomic_inc(&cm_listens_destroyed);
36994 + atomic_inc_unchecked(&cm_listens_destroyed);
36995 } else {
36996 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
36997 }
36998 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
36999 cm_node->rem_mac);
37000
37001 add_hte_node(cm_core, cm_node);
37002 - atomic_inc(&cm_nodes_created);
37003 + atomic_inc_unchecked(&cm_nodes_created);
37004
37005 return cm_node;
37006 }
37007 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37008 }
37009
37010 atomic_dec(&cm_core->node_cnt);
37011 - atomic_inc(&cm_nodes_destroyed);
37012 + atomic_inc_unchecked(&cm_nodes_destroyed);
37013 nesqp = cm_node->nesqp;
37014 if (nesqp) {
37015 nesqp->cm_node = NULL;
37016 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37017
37018 static void drop_packet(struct sk_buff *skb)
37019 {
37020 - atomic_inc(&cm_accel_dropped_pkts);
37021 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37022 dev_kfree_skb_any(skb);
37023 }
37024
37025 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37026 {
37027
37028 int reset = 0; /* whether to send reset in case of err.. */
37029 - atomic_inc(&cm_resets_recvd);
37030 + atomic_inc_unchecked(&cm_resets_recvd);
37031 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37032 " refcnt=%d\n", cm_node, cm_node->state,
37033 atomic_read(&cm_node->ref_count));
37034 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37035 rem_ref_cm_node(cm_node->cm_core, cm_node);
37036 return NULL;
37037 }
37038 - atomic_inc(&cm_loopbacks);
37039 + atomic_inc_unchecked(&cm_loopbacks);
37040 loopbackremotenode->loopbackpartner = cm_node;
37041 loopbackremotenode->tcp_cntxt.rcv_wscale =
37042 NES_CM_DEFAULT_RCV_WND_SCALE;
37043 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37044 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37045 else {
37046 rem_ref_cm_node(cm_core, cm_node);
37047 - atomic_inc(&cm_accel_dropped_pkts);
37048 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37049 dev_kfree_skb_any(skb);
37050 }
37051 break;
37052 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37053
37054 if ((cm_id) && (cm_id->event_handler)) {
37055 if (issue_disconn) {
37056 - atomic_inc(&cm_disconnects);
37057 + atomic_inc_unchecked(&cm_disconnects);
37058 cm_event.event = IW_CM_EVENT_DISCONNECT;
37059 cm_event.status = disconn_status;
37060 cm_event.local_addr = cm_id->local_addr;
37061 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37062 }
37063
37064 if (issue_close) {
37065 - atomic_inc(&cm_closes);
37066 + atomic_inc_unchecked(&cm_closes);
37067 nes_disconnect(nesqp, 1);
37068
37069 cm_id->provider_data = nesqp;
37070 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37071
37072 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37073 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37074 - atomic_inc(&cm_accepts);
37075 + atomic_inc_unchecked(&cm_accepts);
37076
37077 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37078 netdev_refcnt_read(nesvnic->netdev));
37079 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37080 struct nes_cm_core *cm_core;
37081 u8 *start_buff;
37082
37083 - atomic_inc(&cm_rejects);
37084 + atomic_inc_unchecked(&cm_rejects);
37085 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37086 loopback = cm_node->loopbackpartner;
37087 cm_core = cm_node->cm_core;
37088 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37089 ntohl(cm_id->local_addr.sin_addr.s_addr),
37090 ntohs(cm_id->local_addr.sin_port));
37091
37092 - atomic_inc(&cm_connects);
37093 + atomic_inc_unchecked(&cm_connects);
37094 nesqp->active_conn = 1;
37095
37096 /* cache the cm_id in the qp */
37097 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37098 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37099 return err;
37100 }
37101 - atomic_inc(&cm_listens_created);
37102 + atomic_inc_unchecked(&cm_listens_created);
37103 }
37104
37105 cm_id->add_ref(cm_id);
37106 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37107
37108 if (nesqp->destroyed)
37109 return;
37110 - atomic_inc(&cm_connecteds);
37111 + atomic_inc_unchecked(&cm_connecteds);
37112 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37113 " local port 0x%04X. jiffies = %lu.\n",
37114 nesqp->hwqp.qp_id,
37115 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37116
37117 cm_id->add_ref(cm_id);
37118 ret = cm_id->event_handler(cm_id, &cm_event);
37119 - atomic_inc(&cm_closes);
37120 + atomic_inc_unchecked(&cm_closes);
37121 cm_event.event = IW_CM_EVENT_CLOSE;
37122 cm_event.status = 0;
37123 cm_event.provider_data = cm_id->provider_data;
37124 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37125 return;
37126 cm_id = cm_node->cm_id;
37127
37128 - atomic_inc(&cm_connect_reqs);
37129 + atomic_inc_unchecked(&cm_connect_reqs);
37130 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37131 cm_node, cm_id, jiffies);
37132
37133 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37134 return;
37135 cm_id = cm_node->cm_id;
37136
37137 - atomic_inc(&cm_connect_reqs);
37138 + atomic_inc_unchecked(&cm_connect_reqs);
37139 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37140 cm_node, cm_id, jiffies);
37141
37142 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37143 index 4166452..fc952c3 100644
37144 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37145 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37146 @@ -40,8 +40,8 @@
37147 #include "nes.h"
37148 #include "nes_mgt.h"
37149
37150 -atomic_t pau_qps_created;
37151 -atomic_t pau_qps_destroyed;
37152 +atomic_unchecked_t pau_qps_created;
37153 +atomic_unchecked_t pau_qps_destroyed;
37154
37155 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37156 {
37157 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37158 {
37159 struct sk_buff *skb;
37160 unsigned long flags;
37161 - atomic_inc(&pau_qps_destroyed);
37162 + atomic_inc_unchecked(&pau_qps_destroyed);
37163
37164 /* Free packets that have not yet been forwarded */
37165 /* Lock is acquired by skb_dequeue when removing the skb */
37166 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37167 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37168 skb_queue_head_init(&nesqp->pau_list);
37169 spin_lock_init(&nesqp->pau_lock);
37170 - atomic_inc(&pau_qps_created);
37171 + atomic_inc_unchecked(&pau_qps_created);
37172 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37173 }
37174
37175 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37176 index 85cf4d1..05d8e71 100644
37177 --- a/drivers/infiniband/hw/nes/nes_nic.c
37178 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37179 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37180 target_stat_values[++index] = mh_detected;
37181 target_stat_values[++index] = mh_pauses_sent;
37182 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37183 - target_stat_values[++index] = atomic_read(&cm_connects);
37184 - target_stat_values[++index] = atomic_read(&cm_accepts);
37185 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37186 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37187 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37188 - target_stat_values[++index] = atomic_read(&cm_rejects);
37189 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37190 - target_stat_values[++index] = atomic_read(&qps_created);
37191 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37192 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37193 - target_stat_values[++index] = atomic_read(&cm_closes);
37194 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37195 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37196 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37197 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37198 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37199 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37200 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37201 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37202 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37203 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37204 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37205 target_stat_values[++index] = cm_packets_sent;
37206 target_stat_values[++index] = cm_packets_bounced;
37207 target_stat_values[++index] = cm_packets_created;
37208 target_stat_values[++index] = cm_packets_received;
37209 target_stat_values[++index] = cm_packets_dropped;
37210 target_stat_values[++index] = cm_packets_retrans;
37211 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37212 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37213 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37214 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37215 target_stat_values[++index] = cm_backlog_drops;
37216 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37217 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37218 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37219 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37220 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37221 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37222 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37223 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37224 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37225 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37226 target_stat_values[++index] = nesadapter->free_4kpbl;
37227 target_stat_values[++index] = nesadapter->free_256pbl;
37228 target_stat_values[++index] = int_mod_timer_init;
37229 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37230 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37231 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37232 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37233 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37234 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37235 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37236 }
37237
37238 /**
37239 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37240 index 8f67fe2..8960859 100644
37241 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37242 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37243 @@ -46,9 +46,9 @@
37244
37245 #include <rdma/ib_umem.h>
37246
37247 -atomic_t mod_qp_timouts;
37248 -atomic_t qps_created;
37249 -atomic_t sw_qps_destroyed;
37250 +atomic_unchecked_t mod_qp_timouts;
37251 +atomic_unchecked_t qps_created;
37252 +atomic_unchecked_t sw_qps_destroyed;
37253
37254 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37255
37256 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37257 if (init_attr->create_flags)
37258 return ERR_PTR(-EINVAL);
37259
37260 - atomic_inc(&qps_created);
37261 + atomic_inc_unchecked(&qps_created);
37262 switch (init_attr->qp_type) {
37263 case IB_QPT_RC:
37264 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37265 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37266 struct iw_cm_event cm_event;
37267 int ret = 0;
37268
37269 - atomic_inc(&sw_qps_destroyed);
37270 + atomic_inc_unchecked(&sw_qps_destroyed);
37271 nesqp->destroyed = 1;
37272
37273 /* Blow away the connection if it exists. */
37274 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37275 index 4d11575..3e890e5 100644
37276 --- a/drivers/infiniband/hw/qib/qib.h
37277 +++ b/drivers/infiniband/hw/qib/qib.h
37278 @@ -51,6 +51,7 @@
37279 #include <linux/completion.h>
37280 #include <linux/kref.h>
37281 #include <linux/sched.h>
37282 +#include <linux/slab.h>
37283
37284 #include "qib_common.h"
37285 #include "qib_verbs.h"
37286 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37287 index da739d9..da1c7f4 100644
37288 --- a/drivers/input/gameport/gameport.c
37289 +++ b/drivers/input/gameport/gameport.c
37290 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37291 */
37292 static void gameport_init_port(struct gameport *gameport)
37293 {
37294 - static atomic_t gameport_no = ATOMIC_INIT(0);
37295 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37296
37297 __module_get(THIS_MODULE);
37298
37299 mutex_init(&gameport->drv_mutex);
37300 device_initialize(&gameport->dev);
37301 dev_set_name(&gameport->dev, "gameport%lu",
37302 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37303 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37304 gameport->dev.bus = &gameport_bus;
37305 gameport->dev.release = gameport_release_port;
37306 if (gameport->parent)
37307 diff --git a/drivers/input/input.c b/drivers/input/input.c
37308 index c044699..174d71a 100644
37309 --- a/drivers/input/input.c
37310 +++ b/drivers/input/input.c
37311 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37312 */
37313 int input_register_device(struct input_dev *dev)
37314 {
37315 - static atomic_t input_no = ATOMIC_INIT(0);
37316 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37317 struct input_devres *devres = NULL;
37318 struct input_handler *handler;
37319 unsigned int packet_size;
37320 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37321 dev->setkeycode = input_default_setkeycode;
37322
37323 dev_set_name(&dev->dev, "input%ld",
37324 - (unsigned long) atomic_inc_return(&input_no) - 1);
37325 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37326
37327 error = device_add(&dev->dev);
37328 if (error)
37329 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37330 index 04c69af..5f92d00 100644
37331 --- a/drivers/input/joystick/sidewinder.c
37332 +++ b/drivers/input/joystick/sidewinder.c
37333 @@ -30,6 +30,7 @@
37334 #include <linux/kernel.h>
37335 #include <linux/module.h>
37336 #include <linux/slab.h>
37337 +#include <linux/sched.h>
37338 #include <linux/init.h>
37339 #include <linux/input.h>
37340 #include <linux/gameport.h>
37341 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37342 index d6cbfe9..6225402 100644
37343 --- a/drivers/input/joystick/xpad.c
37344 +++ b/drivers/input/joystick/xpad.c
37345 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37346
37347 static int xpad_led_probe(struct usb_xpad *xpad)
37348 {
37349 - static atomic_t led_seq = ATOMIC_INIT(0);
37350 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37351 long led_no;
37352 struct xpad_led *led;
37353 struct led_classdev *led_cdev;
37354 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37355 if (!led)
37356 return -ENOMEM;
37357
37358 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37359 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37360
37361 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37362 led->xpad = xpad;
37363 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37364 index 2f0b39d..7370f13 100644
37365 --- a/drivers/input/mouse/psmouse.h
37366 +++ b/drivers/input/mouse/psmouse.h
37367 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37368 ssize_t (*set)(struct psmouse *psmouse, void *data,
37369 const char *buf, size_t count);
37370 bool protect;
37371 -};
37372 +} __do_const;
37373 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37374
37375 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37376 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37377 index 4c842c3..590b0bf 100644
37378 --- a/drivers/input/mousedev.c
37379 +++ b/drivers/input/mousedev.c
37380 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37381
37382 spin_unlock_irq(&client->packet_lock);
37383
37384 - if (copy_to_user(buffer, data, count))
37385 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37386 return -EFAULT;
37387
37388 return count;
37389 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37390 index 25fc597..558bf3b3 100644
37391 --- a/drivers/input/serio/serio.c
37392 +++ b/drivers/input/serio/serio.c
37393 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37394 */
37395 static void serio_init_port(struct serio *serio)
37396 {
37397 - static atomic_t serio_no = ATOMIC_INIT(0);
37398 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37399
37400 __module_get(THIS_MODULE);
37401
37402 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37403 mutex_init(&serio->drv_mutex);
37404 device_initialize(&serio->dev);
37405 dev_set_name(&serio->dev, "serio%ld",
37406 - (long)atomic_inc_return(&serio_no) - 1);
37407 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37408 serio->dev.bus = &serio_bus;
37409 serio->dev.release = serio_release_port;
37410 serio->dev.groups = serio_device_attr_groups;
37411 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37412 index b972d43..8943713 100644
37413 --- a/drivers/iommu/iommu.c
37414 +++ b/drivers/iommu/iommu.c
37415 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37416 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37417 {
37418 bus_register_notifier(bus, &iommu_bus_nb);
37419 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37420 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37421 }
37422
37423 /**
37424 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37425 index 7c11ff3..5b2d7a7 100644
37426 --- a/drivers/iommu/irq_remapping.c
37427 +++ b/drivers/iommu/irq_remapping.c
37428 @@ -369,10 +369,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
37429
37430 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
37431 {
37432 - chip->irq_print_chip = ir_print_prefix;
37433 - chip->irq_ack = ir_ack_apic_edge;
37434 - chip->irq_eoi = ir_ack_apic_level;
37435 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37436 + pax_open_kernel();
37437 + *(void **)&chip->irq_print_chip = ir_print_prefix;
37438 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
37439 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
37440 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37441 + pax_close_kernel();
37442 }
37443
37444 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
37445 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
37446 index fc6aebf..762c5f5 100644
37447 --- a/drivers/irqchip/irq-gic.c
37448 +++ b/drivers/irqchip/irq-gic.c
37449 @@ -83,7 +83,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
37450 * Supported arch specific GIC irq extension.
37451 * Default make them NULL.
37452 */
37453 -struct irq_chip gic_arch_extn = {
37454 +irq_chip_no_const gic_arch_extn = {
37455 .irq_eoi = NULL,
37456 .irq_mask = NULL,
37457 .irq_unmask = NULL,
37458 @@ -332,7 +332,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
37459 chained_irq_exit(chip, desc);
37460 }
37461
37462 -static struct irq_chip gic_chip = {
37463 +static irq_chip_no_const gic_chip __read_only = {
37464 .name = "GIC",
37465 .irq_mask = gic_mask_irq,
37466 .irq_unmask = gic_unmask_irq,
37467 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37468 index 89562a8..218999b 100644
37469 --- a/drivers/isdn/capi/capi.c
37470 +++ b/drivers/isdn/capi/capi.c
37471 @@ -81,8 +81,8 @@ struct capiminor {
37472
37473 struct capi20_appl *ap;
37474 u32 ncci;
37475 - atomic_t datahandle;
37476 - atomic_t msgid;
37477 + atomic_unchecked_t datahandle;
37478 + atomic_unchecked_t msgid;
37479
37480 struct tty_port port;
37481 int ttyinstop;
37482 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37483 capimsg_setu16(s, 2, mp->ap->applid);
37484 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37485 capimsg_setu8 (s, 5, CAPI_RESP);
37486 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37487 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37488 capimsg_setu32(s, 8, mp->ncci);
37489 capimsg_setu16(s, 12, datahandle);
37490 }
37491 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37492 mp->outbytes -= len;
37493 spin_unlock_bh(&mp->outlock);
37494
37495 - datahandle = atomic_inc_return(&mp->datahandle);
37496 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37497 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37498 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37499 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37500 capimsg_setu16(skb->data, 2, mp->ap->applid);
37501 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37502 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37503 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37504 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37505 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37506 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37507 capimsg_setu16(skb->data, 16, len); /* Data length */
37508 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37509 index e2b5396..c5486dc 100644
37510 --- a/drivers/isdn/gigaset/interface.c
37511 +++ b/drivers/isdn/gigaset/interface.c
37512 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37513 }
37514 tty->driver_data = cs;
37515
37516 - ++cs->port.count;
37517 + atomic_inc(&cs->port.count);
37518
37519 - if (cs->port.count == 1) {
37520 + if (atomic_read(&cs->port.count) == 1) {
37521 tty_port_tty_set(&cs->port, tty);
37522 cs->port.low_latency = 1;
37523 }
37524 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37525
37526 if (!cs->connected)
37527 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37528 - else if (!cs->port.count)
37529 + else if (!atomic_read(&cs->port.count))
37530 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37531 - else if (!--cs->port.count)
37532 + else if (!atomic_dec_return(&cs->port.count))
37533 tty_port_tty_set(&cs->port, NULL);
37534
37535 mutex_unlock(&cs->mutex);
37536 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37537 index 821f7ac..28d4030 100644
37538 --- a/drivers/isdn/hardware/avm/b1.c
37539 +++ b/drivers/isdn/hardware/avm/b1.c
37540 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37541 }
37542 if (left) {
37543 if (t4file->user) {
37544 - if (copy_from_user(buf, dp, left))
37545 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37546 return -EFAULT;
37547 } else {
37548 memcpy(buf, dp, left);
37549 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37550 }
37551 if (left) {
37552 if (config->user) {
37553 - if (copy_from_user(buf, dp, left))
37554 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37555 return -EFAULT;
37556 } else {
37557 memcpy(buf, dp, left);
37558 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37559 index ebaebdf..acd4405 100644
37560 --- a/drivers/isdn/i4l/isdn_tty.c
37561 +++ b/drivers/isdn/i4l/isdn_tty.c
37562 @@ -1511,9 +1511,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37563
37564 #ifdef ISDN_DEBUG_MODEM_OPEN
37565 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37566 - port->count);
37567 + atomic_read(&port->count));
37568 #endif
37569 - port->count++;
37570 + atomic_inc(&port->count);
37571 port->tty = tty;
37572 /*
37573 * Start up serial port
37574 @@ -1557,7 +1557,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37575 #endif
37576 return;
37577 }
37578 - if ((tty->count == 1) && (port->count != 1)) {
37579 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37580 /*
37581 * Uh, oh. tty->count is 1, which means that the tty
37582 * structure will be freed. Info->count should always
37583 @@ -1566,15 +1566,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37584 * serial port won't be shutdown.
37585 */
37586 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37587 - "info->count is %d\n", port->count);
37588 - port->count = 1;
37589 + "info->count is %d\n", atomic_read(&port->count));
37590 + atomic_set(&port->count, 1);
37591 }
37592 - if (--port->count < 0) {
37593 + if (atomic_dec_return(&port->count) < 0) {
37594 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37595 - info->line, port->count);
37596 - port->count = 0;
37597 + info->line, atomic_read(&port->count));
37598 + atomic_set(&port->count, 0);
37599 }
37600 - if (port->count) {
37601 + if (atomic_read(&port->count)) {
37602 #ifdef ISDN_DEBUG_MODEM_OPEN
37603 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37604 #endif
37605 @@ -1628,7 +1628,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37606 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37607 return;
37608 isdn_tty_shutdown(info);
37609 - port->count = 0;
37610 + atomic_set(&port->count, 0);
37611 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37612 port->tty = NULL;
37613 wake_up_interruptible(&port->open_wait);
37614 @@ -1973,7 +1973,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37615 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37616 modem_info *info = &dev->mdm.info[i];
37617
37618 - if (info->port.count == 0)
37619 + if (atomic_read(&info->port.count) == 0)
37620 continue;
37621 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37622 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37623 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37624 index e74df7c..03a03ba 100644
37625 --- a/drivers/isdn/icn/icn.c
37626 +++ b/drivers/isdn/icn/icn.c
37627 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37628 if (count > len)
37629 count = len;
37630 if (user) {
37631 - if (copy_from_user(msg, buf, count))
37632 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37633 return -EFAULT;
37634 } else
37635 memcpy(msg, buf, count);
37636 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37637 index 6a8405d..0bd1c7e 100644
37638 --- a/drivers/leds/leds-clevo-mail.c
37639 +++ b/drivers/leds/leds-clevo-mail.c
37640 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37641 * detected as working, but in reality it is not) as low as
37642 * possible.
37643 */
37644 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37645 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37646 {
37647 .callback = clevo_mail_led_dmi_callback,
37648 .ident = "Clevo D410J",
37649 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37650 index 64e204e..c6bf189 100644
37651 --- a/drivers/leds/leds-ss4200.c
37652 +++ b/drivers/leds/leds-ss4200.c
37653 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37654 * detected as working, but in reality it is not) as low as
37655 * possible.
37656 */
37657 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37658 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37659 {
37660 .callback = ss4200_led_dmi_callback,
37661 .ident = "Intel SS4200-E",
37662 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37663 index a5ebc00..982886f 100644
37664 --- a/drivers/lguest/core.c
37665 +++ b/drivers/lguest/core.c
37666 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37667 * it's worked so far. The end address needs +1 because __get_vm_area
37668 * allocates an extra guard page, so we need space for that.
37669 */
37670 +
37671 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37672 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37673 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37674 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37675 +#else
37676 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37677 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37678 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37679 +#endif
37680 +
37681 if (!switcher_vma) {
37682 err = -ENOMEM;
37683 printk("lguest: could not map switcher pages high\n");
37684 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37685 * Now the Switcher is mapped at the right address, we can't fail!
37686 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37687 */
37688 - memcpy(switcher_vma->addr, start_switcher_text,
37689 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37690 end_switcher_text - start_switcher_text);
37691
37692 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37693 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37694 index 3b62be16..e33134a 100644
37695 --- a/drivers/lguest/page_tables.c
37696 +++ b/drivers/lguest/page_tables.c
37697 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37698 /*:*/
37699
37700 #ifdef CONFIG_X86_PAE
37701 -static void release_pmd(pmd_t *spmd)
37702 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37703 {
37704 /* If the entry's not present, there's nothing to release. */
37705 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37706 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37707 index 4af12e1..0e89afe 100644
37708 --- a/drivers/lguest/x86/core.c
37709 +++ b/drivers/lguest/x86/core.c
37710 @@ -59,7 +59,7 @@ static struct {
37711 /* Offset from where switcher.S was compiled to where we've copied it */
37712 static unsigned long switcher_offset(void)
37713 {
37714 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37715 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37716 }
37717
37718 /* This cpu's struct lguest_pages. */
37719 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37720 * These copies are pretty cheap, so we do them unconditionally: */
37721 /* Save the current Host top-level page directory.
37722 */
37723 +
37724 +#ifdef CONFIG_PAX_PER_CPU_PGD
37725 + pages->state.host_cr3 = read_cr3();
37726 +#else
37727 pages->state.host_cr3 = __pa(current->mm->pgd);
37728 +#endif
37729 +
37730 /*
37731 * Set up the Guest's page tables to see this CPU's pages (and no
37732 * other CPU's pages).
37733 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37734 * compiled-in switcher code and the high-mapped copy we just made.
37735 */
37736 for (i = 0; i < IDT_ENTRIES; i++)
37737 - default_idt_entries[i] += switcher_offset();
37738 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37739
37740 /*
37741 * Set up the Switcher's per-cpu areas.
37742 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37743 * it will be undisturbed when we switch. To change %cs and jump we
37744 * need this structure to feed to Intel's "lcall" instruction.
37745 */
37746 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37747 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37748 lguest_entry.segment = LGUEST_CS;
37749
37750 /*
37751 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37752 index 40634b0..4f5855e 100644
37753 --- a/drivers/lguest/x86/switcher_32.S
37754 +++ b/drivers/lguest/x86/switcher_32.S
37755 @@ -87,6 +87,7 @@
37756 #include <asm/page.h>
37757 #include <asm/segment.h>
37758 #include <asm/lguest.h>
37759 +#include <asm/processor-flags.h>
37760
37761 // We mark the start of the code to copy
37762 // It's placed in .text tho it's never run here
37763 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37764 // Changes type when we load it: damn Intel!
37765 // For after we switch over our page tables
37766 // That entry will be read-only: we'd crash.
37767 +
37768 +#ifdef CONFIG_PAX_KERNEXEC
37769 + mov %cr0, %edx
37770 + xor $X86_CR0_WP, %edx
37771 + mov %edx, %cr0
37772 +#endif
37773 +
37774 movl $(GDT_ENTRY_TSS*8), %edx
37775 ltr %dx
37776
37777 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37778 // Let's clear it again for our return.
37779 // The GDT descriptor of the Host
37780 // Points to the table after two "size" bytes
37781 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
37782 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
37783 // Clear "used" from type field (byte 5, bit 2)
37784 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
37785 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
37786 +
37787 +#ifdef CONFIG_PAX_KERNEXEC
37788 + mov %cr0, %eax
37789 + xor $X86_CR0_WP, %eax
37790 + mov %eax, %cr0
37791 +#endif
37792
37793 // Once our page table's switched, the Guest is live!
37794 // The Host fades as we run this final step.
37795 @@ -295,13 +309,12 @@ deliver_to_host:
37796 // I consulted gcc, and it gave
37797 // These instructions, which I gladly credit:
37798 leal (%edx,%ebx,8), %eax
37799 - movzwl (%eax),%edx
37800 - movl 4(%eax), %eax
37801 - xorw %ax, %ax
37802 - orl %eax, %edx
37803 + movl 4(%eax), %edx
37804 + movw (%eax), %dx
37805 // Now the address of the handler's in %edx
37806 // We call it now: its "iret" drops us home.
37807 - jmp *%edx
37808 + ljmp $__KERNEL_CS, $1f
37809 +1: jmp *%edx
37810
37811 // Every interrupt can come to us here
37812 // But we must truly tell each apart.
37813 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
37814 index 4fd9d6a..834fa03 100644
37815 --- a/drivers/md/bitmap.c
37816 +++ b/drivers/md/bitmap.c
37817 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
37818 chunk_kb ? "KB" : "B");
37819 if (bitmap->storage.file) {
37820 seq_printf(seq, ", file: ");
37821 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
37822 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
37823 }
37824
37825 seq_printf(seq, "\n");
37826 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
37827 index aa04f02..2a1309e 100644
37828 --- a/drivers/md/dm-ioctl.c
37829 +++ b/drivers/md/dm-ioctl.c
37830 @@ -1694,7 +1694,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
37831 cmd == DM_LIST_VERSIONS_CMD)
37832 return 0;
37833
37834 - if ((cmd == DM_DEV_CREATE_CMD)) {
37835 + if (cmd == DM_DEV_CREATE_CMD) {
37836 if (!*param->name) {
37837 DMWARN("name not supplied when creating device");
37838 return -EINVAL;
37839 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
37840 index d053098..05cc375 100644
37841 --- a/drivers/md/dm-raid1.c
37842 +++ b/drivers/md/dm-raid1.c
37843 @@ -40,7 +40,7 @@ enum dm_raid1_error {
37844
37845 struct mirror {
37846 struct mirror_set *ms;
37847 - atomic_t error_count;
37848 + atomic_unchecked_t error_count;
37849 unsigned long error_type;
37850 struct dm_dev *dev;
37851 sector_t offset;
37852 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
37853 struct mirror *m;
37854
37855 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
37856 - if (!atomic_read(&m->error_count))
37857 + if (!atomic_read_unchecked(&m->error_count))
37858 return m;
37859
37860 return NULL;
37861 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
37862 * simple way to tell if a device has encountered
37863 * errors.
37864 */
37865 - atomic_inc(&m->error_count);
37866 + atomic_inc_unchecked(&m->error_count);
37867
37868 if (test_and_set_bit(error_type, &m->error_type))
37869 return;
37870 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
37871 struct mirror *m = get_default_mirror(ms);
37872
37873 do {
37874 - if (likely(!atomic_read(&m->error_count)))
37875 + if (likely(!atomic_read_unchecked(&m->error_count)))
37876 return m;
37877
37878 if (m-- == ms->mirror)
37879 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
37880 {
37881 struct mirror *default_mirror = get_default_mirror(m->ms);
37882
37883 - return !atomic_read(&default_mirror->error_count);
37884 + return !atomic_read_unchecked(&default_mirror->error_count);
37885 }
37886
37887 static int mirror_available(struct mirror_set *ms, struct bio *bio)
37888 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
37889 */
37890 if (likely(region_in_sync(ms, region, 1)))
37891 m = choose_mirror(ms, bio->bi_sector);
37892 - else if (m && atomic_read(&m->error_count))
37893 + else if (m && atomic_read_unchecked(&m->error_count))
37894 m = NULL;
37895
37896 if (likely(m))
37897 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
37898 }
37899
37900 ms->mirror[mirror].ms = ms;
37901 - atomic_set(&(ms->mirror[mirror].error_count), 0);
37902 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
37903 ms->mirror[mirror].error_type = 0;
37904 ms->mirror[mirror].offset = offset;
37905
37906 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
37907 */
37908 static char device_status_char(struct mirror *m)
37909 {
37910 - if (!atomic_read(&(m->error_count)))
37911 + if (!atomic_read_unchecked(&(m->error_count)))
37912 return 'A';
37913
37914 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
37915 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
37916 index 7b8b2b9..9c7d145 100644
37917 --- a/drivers/md/dm-stripe.c
37918 +++ b/drivers/md/dm-stripe.c
37919 @@ -20,7 +20,7 @@ struct stripe {
37920 struct dm_dev *dev;
37921 sector_t physical_start;
37922
37923 - atomic_t error_count;
37924 + atomic_unchecked_t error_count;
37925 };
37926
37927 struct stripe_c {
37928 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
37929 kfree(sc);
37930 return r;
37931 }
37932 - atomic_set(&(sc->stripe[i].error_count), 0);
37933 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
37934 }
37935
37936 ti->private = sc;
37937 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
37938 DMEMIT("%d ", sc->stripes);
37939 for (i = 0; i < sc->stripes; i++) {
37940 DMEMIT("%s ", sc->stripe[i].dev->name);
37941 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
37942 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
37943 'D' : 'A';
37944 }
37945 buffer[i] = '\0';
37946 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
37947 */
37948 for (i = 0; i < sc->stripes; i++)
37949 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
37950 - atomic_inc(&(sc->stripe[i].error_count));
37951 - if (atomic_read(&(sc->stripe[i].error_count)) <
37952 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
37953 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
37954 DM_IO_ERROR_THRESHOLD)
37955 schedule_work(&sc->trigger_event);
37956 }
37957 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
37958 index 1ff252a..ee384c1 100644
37959 --- a/drivers/md/dm-table.c
37960 +++ b/drivers/md/dm-table.c
37961 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
37962 if (!dev_size)
37963 return 0;
37964
37965 - if ((start >= dev_size) || (start + len > dev_size)) {
37966 + if ((start >= dev_size) || (len > dev_size - start)) {
37967 DMWARN("%s: %s too small for target: "
37968 "start=%llu, len=%llu, dev_size=%llu",
37969 dm_device_name(ti->table->md), bdevname(bdev, b),
37970 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
37971 index 00cee02..b89a29d 100644
37972 --- a/drivers/md/dm-thin-metadata.c
37973 +++ b/drivers/md/dm-thin-metadata.c
37974 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37975 {
37976 pmd->info.tm = pmd->tm;
37977 pmd->info.levels = 2;
37978 - pmd->info.value_type.context = pmd->data_sm;
37979 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37980 pmd->info.value_type.size = sizeof(__le64);
37981 pmd->info.value_type.inc = data_block_inc;
37982 pmd->info.value_type.dec = data_block_dec;
37983 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37984
37985 pmd->bl_info.tm = pmd->tm;
37986 pmd->bl_info.levels = 1;
37987 - pmd->bl_info.value_type.context = pmd->data_sm;
37988 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37989 pmd->bl_info.value_type.size = sizeof(__le64);
37990 pmd->bl_info.value_type.inc = data_block_inc;
37991 pmd->bl_info.value_type.dec = data_block_dec;
37992 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
37993 index 9a0bdad..4df9543 100644
37994 --- a/drivers/md/dm.c
37995 +++ b/drivers/md/dm.c
37996 @@ -169,9 +169,9 @@ struct mapped_device {
37997 /*
37998 * Event handling.
37999 */
38000 - atomic_t event_nr;
38001 + atomic_unchecked_t event_nr;
38002 wait_queue_head_t eventq;
38003 - atomic_t uevent_seq;
38004 + atomic_unchecked_t uevent_seq;
38005 struct list_head uevent_list;
38006 spinlock_t uevent_lock; /* Protect access to uevent_list */
38007
38008 @@ -1879,8 +1879,8 @@ static struct mapped_device *alloc_dev(int minor)
38009 rwlock_init(&md->map_lock);
38010 atomic_set(&md->holders, 1);
38011 atomic_set(&md->open_count, 0);
38012 - atomic_set(&md->event_nr, 0);
38013 - atomic_set(&md->uevent_seq, 0);
38014 + atomic_set_unchecked(&md->event_nr, 0);
38015 + atomic_set_unchecked(&md->uevent_seq, 0);
38016 INIT_LIST_HEAD(&md->uevent_list);
38017 spin_lock_init(&md->uevent_lock);
38018
38019 @@ -2028,7 +2028,7 @@ static void event_callback(void *context)
38020
38021 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38022
38023 - atomic_inc(&md->event_nr);
38024 + atomic_inc_unchecked(&md->event_nr);
38025 wake_up(&md->eventq);
38026 }
38027
38028 @@ -2685,18 +2685,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38029
38030 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38031 {
38032 - return atomic_add_return(1, &md->uevent_seq);
38033 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38034 }
38035
38036 uint32_t dm_get_event_nr(struct mapped_device *md)
38037 {
38038 - return atomic_read(&md->event_nr);
38039 + return atomic_read_unchecked(&md->event_nr);
38040 }
38041
38042 int dm_wait_event(struct mapped_device *md, int event_nr)
38043 {
38044 return wait_event_interruptible(md->eventq,
38045 - (event_nr != atomic_read(&md->event_nr)));
38046 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38047 }
38048
38049 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38050 diff --git a/drivers/md/md.c b/drivers/md/md.c
38051 index a4a93b9..4747b63 100644
38052 --- a/drivers/md/md.c
38053 +++ b/drivers/md/md.c
38054 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38055 * start build, activate spare
38056 */
38057 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38058 -static atomic_t md_event_count;
38059 +static atomic_unchecked_t md_event_count;
38060 void md_new_event(struct mddev *mddev)
38061 {
38062 - atomic_inc(&md_event_count);
38063 + atomic_inc_unchecked(&md_event_count);
38064 wake_up(&md_event_waiters);
38065 }
38066 EXPORT_SYMBOL_GPL(md_new_event);
38067 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38068 */
38069 static void md_new_event_inintr(struct mddev *mddev)
38070 {
38071 - atomic_inc(&md_event_count);
38072 + atomic_inc_unchecked(&md_event_count);
38073 wake_up(&md_event_waiters);
38074 }
38075
38076 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38077 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38078 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38079 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38080 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38081 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38082
38083 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38084 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38085 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38086 else
38087 sb->resync_offset = cpu_to_le64(0);
38088
38089 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38090 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38091
38092 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38093 sb->size = cpu_to_le64(mddev->dev_sectors);
38094 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38095 static ssize_t
38096 errors_show(struct md_rdev *rdev, char *page)
38097 {
38098 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38099 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38100 }
38101
38102 static ssize_t
38103 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38104 char *e;
38105 unsigned long n = simple_strtoul(buf, &e, 10);
38106 if (*buf && (*e == 0 || *e == '\n')) {
38107 - atomic_set(&rdev->corrected_errors, n);
38108 + atomic_set_unchecked(&rdev->corrected_errors, n);
38109 return len;
38110 }
38111 return -EINVAL;
38112 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38113 rdev->sb_loaded = 0;
38114 rdev->bb_page = NULL;
38115 atomic_set(&rdev->nr_pending, 0);
38116 - atomic_set(&rdev->read_errors, 0);
38117 - atomic_set(&rdev->corrected_errors, 0);
38118 + atomic_set_unchecked(&rdev->read_errors, 0);
38119 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38120
38121 INIT_LIST_HEAD(&rdev->same_set);
38122 init_waitqueue_head(&rdev->blocked_wait);
38123 @@ -6994,7 +6994,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38124
38125 spin_unlock(&pers_lock);
38126 seq_printf(seq, "\n");
38127 - seq->poll_event = atomic_read(&md_event_count);
38128 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38129 return 0;
38130 }
38131 if (v == (void*)2) {
38132 @@ -7097,7 +7097,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38133 return error;
38134
38135 seq = file->private_data;
38136 - seq->poll_event = atomic_read(&md_event_count);
38137 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38138 return error;
38139 }
38140
38141 @@ -7111,7 +7111,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38142 /* always allow read */
38143 mask = POLLIN | POLLRDNORM;
38144
38145 - if (seq->poll_event != atomic_read(&md_event_count))
38146 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38147 mask |= POLLERR | POLLPRI;
38148 return mask;
38149 }
38150 @@ -7155,7 +7155,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38151 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38152 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38153 (int)part_stat_read(&disk->part0, sectors[1]) -
38154 - atomic_read(&disk->sync_io);
38155 + atomic_read_unchecked(&disk->sync_io);
38156 /* sync IO will cause sync_io to increase before the disk_stats
38157 * as sync_io is counted when a request starts, and
38158 * disk_stats is counted when it completes.
38159 diff --git a/drivers/md/md.h b/drivers/md/md.h
38160 index d90fb1a..4174a2b 100644
38161 --- a/drivers/md/md.h
38162 +++ b/drivers/md/md.h
38163 @@ -94,13 +94,13 @@ struct md_rdev {
38164 * only maintained for arrays that
38165 * support hot removal
38166 */
38167 - atomic_t read_errors; /* number of consecutive read errors that
38168 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38169 * we have tried to ignore.
38170 */
38171 struct timespec last_read_error; /* monotonic time since our
38172 * last read error
38173 */
38174 - atomic_t corrected_errors; /* number of corrected read errors,
38175 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38176 * for reporting to userspace and storing
38177 * in superblock.
38178 */
38179 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38180
38181 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38182 {
38183 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38184 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38185 }
38186
38187 struct md_personality
38188 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38189 index 1cbfc6b..56e1dbb 100644
38190 --- a/drivers/md/persistent-data/dm-space-map.h
38191 +++ b/drivers/md/persistent-data/dm-space-map.h
38192 @@ -60,6 +60,7 @@ struct dm_space_map {
38193 int (*root_size)(struct dm_space_map *sm, size_t *result);
38194 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38195 };
38196 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38197
38198 /*----------------------------------------------------------------*/
38199
38200 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38201 index 6af167f..40c25a1 100644
38202 --- a/drivers/md/raid1.c
38203 +++ b/drivers/md/raid1.c
38204 @@ -1826,7 +1826,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38205 if (r1_sync_page_io(rdev, sect, s,
38206 bio->bi_io_vec[idx].bv_page,
38207 READ) != 0)
38208 - atomic_add(s, &rdev->corrected_errors);
38209 + atomic_add_unchecked(s, &rdev->corrected_errors);
38210 }
38211 sectors -= s;
38212 sect += s;
38213 @@ -2048,7 +2048,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38214 test_bit(In_sync, &rdev->flags)) {
38215 if (r1_sync_page_io(rdev, sect, s,
38216 conf->tmppage, READ)) {
38217 - atomic_add(s, &rdev->corrected_errors);
38218 + atomic_add_unchecked(s, &rdev->corrected_errors);
38219 printk(KERN_INFO
38220 "md/raid1:%s: read error corrected "
38221 "(%d sectors at %llu on %s)\n",
38222 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38223 index 46c14e5..4db5966 100644
38224 --- a/drivers/md/raid10.c
38225 +++ b/drivers/md/raid10.c
38226 @@ -1932,7 +1932,7 @@ static void end_sync_read(struct bio *bio, int error)
38227 /* The write handler will notice the lack of
38228 * R10BIO_Uptodate and record any errors etc
38229 */
38230 - atomic_add(r10_bio->sectors,
38231 + atomic_add_unchecked(r10_bio->sectors,
38232 &conf->mirrors[d].rdev->corrected_errors);
38233
38234 /* for reconstruct, we always reschedule after a read.
38235 @@ -2281,7 +2281,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38236 {
38237 struct timespec cur_time_mon;
38238 unsigned long hours_since_last;
38239 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38240 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38241
38242 ktime_get_ts(&cur_time_mon);
38243
38244 @@ -2303,9 +2303,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38245 * overflowing the shift of read_errors by hours_since_last.
38246 */
38247 if (hours_since_last >= 8 * sizeof(read_errors))
38248 - atomic_set(&rdev->read_errors, 0);
38249 + atomic_set_unchecked(&rdev->read_errors, 0);
38250 else
38251 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38252 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38253 }
38254
38255 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38256 @@ -2359,8 +2359,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38257 return;
38258
38259 check_decay_read_errors(mddev, rdev);
38260 - atomic_inc(&rdev->read_errors);
38261 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38262 + atomic_inc_unchecked(&rdev->read_errors);
38263 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38264 char b[BDEVNAME_SIZE];
38265 bdevname(rdev->bdev, b);
38266
38267 @@ -2368,7 +2368,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38268 "md/raid10:%s: %s: Raid device exceeded "
38269 "read_error threshold [cur %d:max %d]\n",
38270 mdname(mddev), b,
38271 - atomic_read(&rdev->read_errors), max_read_errors);
38272 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38273 printk(KERN_NOTICE
38274 "md/raid10:%s: %s: Failing raid device\n",
38275 mdname(mddev), b);
38276 @@ -2523,7 +2523,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38277 sect +
38278 choose_data_offset(r10_bio, rdev)),
38279 bdevname(rdev->bdev, b));
38280 - atomic_add(s, &rdev->corrected_errors);
38281 + atomic_add_unchecked(s, &rdev->corrected_errors);
38282 }
38283
38284 rdev_dec_pending(rdev, mddev);
38285 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38286 index f4e87bf..0d4ad3f 100644
38287 --- a/drivers/md/raid5.c
38288 +++ b/drivers/md/raid5.c
38289 @@ -1763,21 +1763,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38290 mdname(conf->mddev), STRIPE_SECTORS,
38291 (unsigned long long)s,
38292 bdevname(rdev->bdev, b));
38293 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38294 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38295 clear_bit(R5_ReadError, &sh->dev[i].flags);
38296 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38297 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38298 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38299
38300 - if (atomic_read(&rdev->read_errors))
38301 - atomic_set(&rdev->read_errors, 0);
38302 + if (atomic_read_unchecked(&rdev->read_errors))
38303 + atomic_set_unchecked(&rdev->read_errors, 0);
38304 } else {
38305 const char *bdn = bdevname(rdev->bdev, b);
38306 int retry = 0;
38307 int set_bad = 0;
38308
38309 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38310 - atomic_inc(&rdev->read_errors);
38311 + atomic_inc_unchecked(&rdev->read_errors);
38312 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38313 printk_ratelimited(
38314 KERN_WARNING
38315 @@ -1805,7 +1805,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38316 mdname(conf->mddev),
38317 (unsigned long long)s,
38318 bdn);
38319 - } else if (atomic_read(&rdev->read_errors)
38320 + } else if (atomic_read_unchecked(&rdev->read_errors)
38321 > conf->max_nr_stripes)
38322 printk(KERN_WARNING
38323 "md/raid:%s: Too many read errors, failing device %s.\n",
38324 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38325 index 401ef64..836e563 100644
38326 --- a/drivers/media/dvb-core/dvbdev.c
38327 +++ b/drivers/media/dvb-core/dvbdev.c
38328 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38329 const struct dvb_device *template, void *priv, int type)
38330 {
38331 struct dvb_device *dvbdev;
38332 - struct file_operations *dvbdevfops;
38333 + file_operations_no_const *dvbdevfops;
38334 struct device *clsdev;
38335 int minor;
38336 int id;
38337 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38338 index 9b6c3bb..baeb5c7 100644
38339 --- a/drivers/media/dvb-frontends/dib3000.h
38340 +++ b/drivers/media/dvb-frontends/dib3000.h
38341 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38342 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38343 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38344 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38345 -};
38346 +} __no_const;
38347
38348 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38349 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38350 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38351 index bc78354..42c9459 100644
38352 --- a/drivers/media/pci/cx88/cx88-video.c
38353 +++ b/drivers/media/pci/cx88/cx88-video.c
38354 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38355
38356 /* ------------------------------------------------------------------ */
38357
38358 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38359 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38360 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38361 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38362 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38363 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38364
38365 module_param_array(video_nr, int, NULL, 0444);
38366 module_param_array(vbi_nr, int, NULL, 0444);
38367 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38368 index 96c4a17..1305a79 100644
38369 --- a/drivers/media/platform/omap/omap_vout.c
38370 +++ b/drivers/media/platform/omap/omap_vout.c
38371 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38372 OMAP_VIDEO2,
38373 };
38374
38375 -static struct videobuf_queue_ops video_vbq_ops;
38376 /* Variables configurable through module params*/
38377 static u32 video1_numbuffers = 3;
38378 static u32 video2_numbuffers = 3;
38379 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38380 {
38381 struct videobuf_queue *q;
38382 struct omap_vout_device *vout = NULL;
38383 + static struct videobuf_queue_ops video_vbq_ops = {
38384 + .buf_setup = omap_vout_buffer_setup,
38385 + .buf_prepare = omap_vout_buffer_prepare,
38386 + .buf_release = omap_vout_buffer_release,
38387 + .buf_queue = omap_vout_buffer_queue,
38388 + };
38389
38390 vout = video_drvdata(file);
38391 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38392 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38393 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38394
38395 q = &vout->vbq;
38396 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38397 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38398 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38399 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38400 spin_lock_init(&vout->vbq_lock);
38401
38402 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38403 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38404 index 04e6490..2df65bf 100644
38405 --- a/drivers/media/platform/s5p-tv/mixer.h
38406 +++ b/drivers/media/platform/s5p-tv/mixer.h
38407 @@ -156,7 +156,7 @@ struct mxr_layer {
38408 /** layer index (unique identifier) */
38409 int idx;
38410 /** callbacks for layer methods */
38411 - struct mxr_layer_ops ops;
38412 + struct mxr_layer_ops *ops;
38413 /** format array */
38414 const struct mxr_format **fmt_array;
38415 /** size of format array */
38416 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38417 index b93a21f..2535195 100644
38418 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38419 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38420 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38421 {
38422 struct mxr_layer *layer;
38423 int ret;
38424 - struct mxr_layer_ops ops = {
38425 + static struct mxr_layer_ops ops = {
38426 .release = mxr_graph_layer_release,
38427 .buffer_set = mxr_graph_buffer_set,
38428 .stream_set = mxr_graph_stream_set,
38429 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38430 index b713403..53cb5ad 100644
38431 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38432 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38433 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38434 layer->update_buf = next;
38435 }
38436
38437 - layer->ops.buffer_set(layer, layer->update_buf);
38438 + layer->ops->buffer_set(layer, layer->update_buf);
38439
38440 if (done && done != layer->shadow_buf)
38441 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38442 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38443 index 82142a2..6de47e8 100644
38444 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38445 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38446 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38447 layer->geo.src.height = layer->geo.src.full_height;
38448
38449 mxr_geometry_dump(mdev, &layer->geo);
38450 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38451 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38452 mxr_geometry_dump(mdev, &layer->geo);
38453 }
38454
38455 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38456 layer->geo.dst.full_width = mbus_fmt.width;
38457 layer->geo.dst.full_height = mbus_fmt.height;
38458 layer->geo.dst.field = mbus_fmt.field;
38459 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38460 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38461
38462 mxr_geometry_dump(mdev, &layer->geo);
38463 }
38464 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38465 /* set source size to highest accepted value */
38466 geo->src.full_width = max(geo->dst.full_width, pix->width);
38467 geo->src.full_height = max(geo->dst.full_height, pix->height);
38468 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38469 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38470 mxr_geometry_dump(mdev, &layer->geo);
38471 /* set cropping to total visible screen */
38472 geo->src.width = pix->width;
38473 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38474 geo->src.x_offset = 0;
38475 geo->src.y_offset = 0;
38476 /* assure consistency of geometry */
38477 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38478 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38479 mxr_geometry_dump(mdev, &layer->geo);
38480 /* set full size to lowest possible value */
38481 geo->src.full_width = 0;
38482 geo->src.full_height = 0;
38483 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38484 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38485 mxr_geometry_dump(mdev, &layer->geo);
38486
38487 /* returning results */
38488 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38489 target->width = s->r.width;
38490 target->height = s->r.height;
38491
38492 - layer->ops.fix_geometry(layer, stage, s->flags);
38493 + layer->ops->fix_geometry(layer, stage, s->flags);
38494
38495 /* retrieve update selection rectangle */
38496 res.left = target->x_offset;
38497 @@ -938,13 +938,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38498 mxr_output_get(mdev);
38499
38500 mxr_layer_update_output(layer);
38501 - layer->ops.format_set(layer);
38502 + layer->ops->format_set(layer);
38503 /* enabling layer in hardware */
38504 spin_lock_irqsave(&layer->enq_slock, flags);
38505 layer->state = MXR_LAYER_STREAMING;
38506 spin_unlock_irqrestore(&layer->enq_slock, flags);
38507
38508 - layer->ops.stream_set(layer, MXR_ENABLE);
38509 + layer->ops->stream_set(layer, MXR_ENABLE);
38510 mxr_streamer_get(mdev);
38511
38512 return 0;
38513 @@ -1014,7 +1014,7 @@ static int stop_streaming(struct vb2_queue *vq)
38514 spin_unlock_irqrestore(&layer->enq_slock, flags);
38515
38516 /* disabling layer in hardware */
38517 - layer->ops.stream_set(layer, MXR_DISABLE);
38518 + layer->ops->stream_set(layer, MXR_DISABLE);
38519 /* remove one streamer */
38520 mxr_streamer_put(mdev);
38521 /* allow changes in output configuration */
38522 @@ -1053,8 +1053,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38523
38524 void mxr_layer_release(struct mxr_layer *layer)
38525 {
38526 - if (layer->ops.release)
38527 - layer->ops.release(layer);
38528 + if (layer->ops->release)
38529 + layer->ops->release(layer);
38530 }
38531
38532 void mxr_base_layer_release(struct mxr_layer *layer)
38533 @@ -1080,7 +1080,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38534
38535 layer->mdev = mdev;
38536 layer->idx = idx;
38537 - layer->ops = *ops;
38538 + layer->ops = ops;
38539
38540 spin_lock_init(&layer->enq_slock);
38541 INIT_LIST_HEAD(&layer->enq_list);
38542 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38543 index 3d13a63..da31bf1 100644
38544 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38545 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38546 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38547 {
38548 struct mxr_layer *layer;
38549 int ret;
38550 - struct mxr_layer_ops ops = {
38551 + static struct mxr_layer_ops ops = {
38552 .release = mxr_vp_layer_release,
38553 .buffer_set = mxr_vp_buffer_set,
38554 .stream_set = mxr_vp_stream_set,
38555 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38556 index 643d80a..56bb96b 100644
38557 --- a/drivers/media/radio/radio-cadet.c
38558 +++ b/drivers/media/radio/radio-cadet.c
38559 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38560 unsigned char readbuf[RDS_BUFFER];
38561 int i = 0;
38562
38563 + if (count > RDS_BUFFER)
38564 + return -EFAULT;
38565 mutex_lock(&dev->lock);
38566 if (dev->rdsstat == 0)
38567 cadet_start_rds(dev);
38568 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38569 while (i < count && dev->rdsin != dev->rdsout)
38570 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38571
38572 - if (i && copy_to_user(data, readbuf, i))
38573 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38574 i = -EFAULT;
38575 unlock:
38576 mutex_unlock(&dev->lock);
38577 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38578 index 3940bb0..fb3952a 100644
38579 --- a/drivers/media/usb/dvb-usb/cxusb.c
38580 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38581 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38582
38583 struct dib0700_adapter_state {
38584 int (*set_param_save) (struct dvb_frontend *);
38585 -};
38586 +} __no_const;
38587
38588 static int dib7070_set_param_override(struct dvb_frontend *fe)
38589 {
38590 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38591 index 9578a67..31aa652 100644
38592 --- a/drivers/media/usb/dvb-usb/dw2102.c
38593 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38594 @@ -115,7 +115,7 @@ struct su3000_state {
38595
38596 struct s6x0_state {
38597 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38598 -};
38599 +} __no_const;
38600
38601 /* debug */
38602 static int dvb_usb_dw2102_debug;
38603 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38604 index 7157af3..139e91a 100644
38605 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38606 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38607 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
38608 __u32 reserved;
38609 };
38610
38611 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38612 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
38613 enum v4l2_memory memory)
38614 {
38615 void __user *up_pln;
38616 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38617 return 0;
38618 }
38619
38620 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38621 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
38622 enum v4l2_memory memory)
38623 {
38624 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
38625 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
38626 put_user(kp->start_block, &up->start_block) ||
38627 put_user(kp->blocks, &up->blocks) ||
38628 put_user(tmp, &up->edid) ||
38629 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
38630 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
38631 return -EFAULT;
38632 return 0;
38633 }
38634 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38635 index aa6e7c7..cb5de87 100644
38636 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38637 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38638 @@ -236,7 +236,7 @@ static void v4l_print_format(const void *arg, bool write_only)
38639 const struct v4l2_vbi_format *vbi;
38640 const struct v4l2_sliced_vbi_format *sliced;
38641 const struct v4l2_window *win;
38642 - const struct v4l2_clip *clip;
38643 + const struct v4l2_clip __user *pclip;
38644 unsigned i;
38645
38646 pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
38647 @@ -284,12 +284,16 @@ static void v4l_print_format(const void *arg, bool write_only)
38648 win->w.left, win->w.top,
38649 prt_names(win->field, v4l2_field_names),
38650 win->chromakey, win->bitmap, win->global_alpha);
38651 - clip = win->clips;
38652 + pclip = win->clips;
38653 for (i = 0; i < win->clipcount; i++) {
38654 + struct v4l2_clip clip;
38655 +
38656 + if (copy_from_user(&clip, pclip, sizeof clip))
38657 + break;
38658 printk(KERN_DEBUG "clip %u: wxh=%dx%d, x,y=%d,%d\n",
38659 - i, clip->c.width, clip->c.height,
38660 - clip->c.left, clip->c.top);
38661 - clip = clip->next;
38662 + i, clip.c.width, clip.c.height,
38663 + clip.c.left, clip.c.top);
38664 + pclip = clip.next;
38665 }
38666 break;
38667 case V4L2_BUF_TYPE_VBI_CAPTURE:
38668 @@ -1923,7 +1927,8 @@ struct v4l2_ioctl_info {
38669 struct file *file, void *fh, void *p);
38670 } u;
38671 void (*debug)(const void *arg, bool write_only);
38672 -};
38673 +} __do_const;
38674 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38675
38676 /* This control needs a priority check */
38677 #define INFO_FL_PRIO (1 << 0)
38678 @@ -2108,7 +2113,7 @@ static long __video_do_ioctl(struct file *file,
38679 struct video_device *vfd = video_devdata(file);
38680 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38681 bool write_only = false;
38682 - struct v4l2_ioctl_info default_info;
38683 + v4l2_ioctl_info_no_const default_info;
38684 const struct v4l2_ioctl_info *info;
38685 void *fh = file->private_data;
38686 struct v4l2_fh *vfh = NULL;
38687 @@ -2193,7 +2198,7 @@ done:
38688 }
38689
38690 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38691 - void * __user *user_ptr, void ***kernel_ptr)
38692 + void __user **user_ptr, void ***kernel_ptr)
38693 {
38694 int ret = 0;
38695
38696 @@ -2209,7 +2214,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38697 ret = -EINVAL;
38698 break;
38699 }
38700 - *user_ptr = (void __user *)buf->m.planes;
38701 + *user_ptr = (void __force_user *)buf->m.planes;
38702 *kernel_ptr = (void *)&buf->m.planes;
38703 *array_size = sizeof(struct v4l2_plane) * buf->length;
38704 ret = 1;
38705 @@ -2244,7 +2249,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38706 ret = -EINVAL;
38707 break;
38708 }
38709 - *user_ptr = (void __user *)ctrls->controls;
38710 + *user_ptr = (void __force_user *)ctrls->controls;
38711 *kernel_ptr = (void *)&ctrls->controls;
38712 *array_size = sizeof(struct v4l2_ext_control)
38713 * ctrls->count;
38714 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38715 index fb69baa..3aeea2e 100644
38716 --- a/drivers/message/fusion/mptbase.c
38717 +++ b/drivers/message/fusion/mptbase.c
38718 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38719 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38720 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38721
38722 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38723 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38724 +#else
38725 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38726 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38727 +#endif
38728 +
38729 /*
38730 * Rounding UP to nearest 4-kB boundary here...
38731 */
38732 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38733 ioc->facts.GlobalCredits);
38734
38735 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38736 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38737 + NULL, NULL);
38738 +#else
38739 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38740 +#endif
38741 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38742 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38743 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38744 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38745 index fa43c39..daeb158 100644
38746 --- a/drivers/message/fusion/mptsas.c
38747 +++ b/drivers/message/fusion/mptsas.c
38748 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38749 return 0;
38750 }
38751
38752 +static inline void
38753 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38754 +{
38755 + if (phy_info->port_details) {
38756 + phy_info->port_details->rphy = rphy;
38757 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38758 + ioc->name, rphy));
38759 + }
38760 +
38761 + if (rphy) {
38762 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38763 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38764 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38765 + ioc->name, rphy, rphy->dev.release));
38766 + }
38767 +}
38768 +
38769 /* no mutex */
38770 static void
38771 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38772 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38773 return NULL;
38774 }
38775
38776 -static inline void
38777 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38778 -{
38779 - if (phy_info->port_details) {
38780 - phy_info->port_details->rphy = rphy;
38781 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38782 - ioc->name, rphy));
38783 - }
38784 -
38785 - if (rphy) {
38786 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38787 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38788 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38789 - ioc->name, rphy, rphy->dev.release));
38790 - }
38791 -}
38792 -
38793 static inline struct sas_port *
38794 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38795 {
38796 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38797 index 164afa7..b6b2e74 100644
38798 --- a/drivers/message/fusion/mptscsih.c
38799 +++ b/drivers/message/fusion/mptscsih.c
38800 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38801
38802 h = shost_priv(SChost);
38803
38804 - if (h) {
38805 - if (h->info_kbuf == NULL)
38806 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38807 - return h->info_kbuf;
38808 - h->info_kbuf[0] = '\0';
38809 + if (!h)
38810 + return NULL;
38811
38812 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38813 - h->info_kbuf[size-1] = '\0';
38814 - }
38815 + if (h->info_kbuf == NULL)
38816 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38817 + return h->info_kbuf;
38818 + h->info_kbuf[0] = '\0';
38819 +
38820 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38821 + h->info_kbuf[size-1] = '\0';
38822
38823 return h->info_kbuf;
38824 }
38825 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38826 index 8001aa6..b137580 100644
38827 --- a/drivers/message/i2o/i2o_proc.c
38828 +++ b/drivers/message/i2o/i2o_proc.c
38829 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38830 "Array Controller Device"
38831 };
38832
38833 -static char *chtostr(char *tmp, u8 *chars, int n)
38834 -{
38835 - tmp[0] = 0;
38836 - return strncat(tmp, (char *)chars, n);
38837 -}
38838 -
38839 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38840 char *group)
38841 {
38842 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38843 } *result;
38844
38845 i2o_exec_execute_ddm_table ddm_table;
38846 - char tmp[28 + 1];
38847
38848 result = kmalloc(sizeof(*result), GFP_KERNEL);
38849 if (!result)
38850 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38851
38852 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
38853 seq_printf(seq, "%-#8x", ddm_table.module_id);
38854 - seq_printf(seq, "%-29s",
38855 - chtostr(tmp, ddm_table.module_name_version, 28));
38856 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
38857 seq_printf(seq, "%9d ", ddm_table.data_size);
38858 seq_printf(seq, "%8d", ddm_table.code_size);
38859
38860 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38861
38862 i2o_driver_result_table *result;
38863 i2o_driver_store_table *dst;
38864 - char tmp[28 + 1];
38865
38866 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
38867 if (result == NULL)
38868 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38869
38870 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
38871 seq_printf(seq, "%-#8x", dst->module_id);
38872 - seq_printf(seq, "%-29s",
38873 - chtostr(tmp, dst->module_name_version, 28));
38874 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
38875 + seq_printf(seq, "%-.28s", dst->module_name_version);
38876 + seq_printf(seq, "%-.8s", dst->date);
38877 seq_printf(seq, "%8d ", dst->module_size);
38878 seq_printf(seq, "%8d ", dst->mpb_size);
38879 seq_printf(seq, "0x%04x", dst->module_flags);
38880 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38881 // == (allow) 512d bytes (max)
38882 static u16 *work16 = (u16 *) work32;
38883 int token;
38884 - char tmp[16 + 1];
38885
38886 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
38887
38888 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38889 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
38890 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
38891 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
38892 - seq_printf(seq, "Vendor info : %s\n",
38893 - chtostr(tmp, (u8 *) (work32 + 2), 16));
38894 - seq_printf(seq, "Product info : %s\n",
38895 - chtostr(tmp, (u8 *) (work32 + 6), 16));
38896 - seq_printf(seq, "Description : %s\n",
38897 - chtostr(tmp, (u8 *) (work32 + 10), 16));
38898 - seq_printf(seq, "Product rev. : %s\n",
38899 - chtostr(tmp, (u8 *) (work32 + 14), 8));
38900 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
38901 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
38902 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
38903 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
38904
38905 seq_printf(seq, "Serial number : ");
38906 print_serial_number(seq, (u8 *) (work32 + 16),
38907 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38908 u8 pad[256]; // allow up to 256 byte (max) serial number
38909 } result;
38910
38911 - char tmp[24 + 1];
38912 -
38913 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
38914
38915 if (token < 0) {
38916 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38917 }
38918
38919 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
38920 - seq_printf(seq, "Module name : %s\n",
38921 - chtostr(tmp, result.module_name, 24));
38922 - seq_printf(seq, "Module revision : %s\n",
38923 - chtostr(tmp, result.module_rev, 8));
38924 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
38925 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
38926
38927 seq_printf(seq, "Serial number : ");
38928 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
38929 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38930 u8 instance_number[4];
38931 } result;
38932
38933 - char tmp[64 + 1];
38934 -
38935 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
38936
38937 if (token < 0) {
38938 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38939 return 0;
38940 }
38941
38942 - seq_printf(seq, "Device name : %s\n",
38943 - chtostr(tmp, result.device_name, 64));
38944 - seq_printf(seq, "Service name : %s\n",
38945 - chtostr(tmp, result.service_name, 64));
38946 - seq_printf(seq, "Physical name : %s\n",
38947 - chtostr(tmp, result.physical_location, 64));
38948 - seq_printf(seq, "Instance number : %s\n",
38949 - chtostr(tmp, result.instance_number, 4));
38950 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
38951 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
38952 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
38953 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
38954
38955 return 0;
38956 }
38957 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
38958 index a8c08f3..155fe3d 100644
38959 --- a/drivers/message/i2o/iop.c
38960 +++ b/drivers/message/i2o/iop.c
38961 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
38962
38963 spin_lock_irqsave(&c->context_list_lock, flags);
38964
38965 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
38966 - atomic_inc(&c->context_list_counter);
38967 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
38968 + atomic_inc_unchecked(&c->context_list_counter);
38969
38970 - entry->context = atomic_read(&c->context_list_counter);
38971 + entry->context = atomic_read_unchecked(&c->context_list_counter);
38972
38973 list_add(&entry->list, &c->context_list);
38974
38975 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
38976
38977 #if BITS_PER_LONG == 64
38978 spin_lock_init(&c->context_list_lock);
38979 - atomic_set(&c->context_list_counter, 0);
38980 + atomic_set_unchecked(&c->context_list_counter, 0);
38981 INIT_LIST_HEAD(&c->context_list);
38982 #endif
38983
38984 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
38985 index 45ece11..8efa218 100644
38986 --- a/drivers/mfd/janz-cmodio.c
38987 +++ b/drivers/mfd/janz-cmodio.c
38988 @@ -13,6 +13,7 @@
38989
38990 #include <linux/kernel.h>
38991 #include <linux/module.h>
38992 +#include <linux/slab.h>
38993 #include <linux/init.h>
38994 #include <linux/pci.h>
38995 #include <linux/interrupt.h>
38996 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
38997 index a5f9888..1c0ed56 100644
38998 --- a/drivers/mfd/twl4030-irq.c
38999 +++ b/drivers/mfd/twl4030-irq.c
39000 @@ -35,6 +35,7 @@
39001 #include <linux/of.h>
39002 #include <linux/irqdomain.h>
39003 #include <linux/i2c/twl.h>
39004 +#include <asm/pgtable.h>
39005
39006 #include "twl-core.h"
39007
39008 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39009 * Install an irq handler for each of the SIH modules;
39010 * clone dummy irq_chip since PIH can't *do* anything
39011 */
39012 - twl4030_irq_chip = dummy_irq_chip;
39013 - twl4030_irq_chip.name = "twl4030";
39014 + pax_open_kernel();
39015 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39016 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39017
39018 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39019 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39020 + pax_close_kernel();
39021
39022 for (i = irq_base; i < irq_end; i++) {
39023 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39024 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39025 index 277a8db..0e0b754 100644
39026 --- a/drivers/mfd/twl6030-irq.c
39027 +++ b/drivers/mfd/twl6030-irq.c
39028 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39029 * install an irq handler for each of the modules;
39030 * clone dummy irq_chip since PIH can't *do* anything
39031 */
39032 - twl6030_irq_chip = dummy_irq_chip;
39033 - twl6030_irq_chip.name = "twl6030";
39034 - twl6030_irq_chip.irq_set_type = NULL;
39035 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39036 + pax_open_kernel();
39037 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39038 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39039 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39040 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39041 + pax_close_kernel();
39042
39043 for (i = irq_base; i < irq_end; i++) {
39044 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39045 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39046 index f32550a..e3e52a2 100644
39047 --- a/drivers/misc/c2port/core.c
39048 +++ b/drivers/misc/c2port/core.c
39049 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
39050 mutex_init(&c2dev->mutex);
39051
39052 /* Create binary file */
39053 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39054 + pax_open_kernel();
39055 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39056 + pax_close_kernel();
39057 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39058 if (unlikely(ret))
39059 goto error_device_create_bin_file;
39060 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39061 index 36f5d52..32311c3 100644
39062 --- a/drivers/misc/kgdbts.c
39063 +++ b/drivers/misc/kgdbts.c
39064 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
39065 char before[BREAK_INSTR_SIZE];
39066 char after[BREAK_INSTR_SIZE];
39067
39068 - probe_kernel_read(before, (char *)kgdbts_break_test,
39069 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39070 BREAK_INSTR_SIZE);
39071 init_simple_test();
39072 ts.tst = plant_and_detach_test;
39073 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
39074 /* Activate test with initial breakpoint */
39075 if (!is_early)
39076 kgdb_breakpoint();
39077 - probe_kernel_read(after, (char *)kgdbts_break_test,
39078 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39079 BREAK_INSTR_SIZE);
39080 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39081 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39082 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39083 index 4a87e5c..76bdf5c 100644
39084 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39085 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39086 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39087 * the lid is closed. This leads to interrupts as soon as a little move
39088 * is done.
39089 */
39090 - atomic_inc(&lis3->count);
39091 + atomic_inc_unchecked(&lis3->count);
39092
39093 wake_up_interruptible(&lis3->misc_wait);
39094 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39095 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39096 if (lis3->pm_dev)
39097 pm_runtime_get_sync(lis3->pm_dev);
39098
39099 - atomic_set(&lis3->count, 0);
39100 + atomic_set_unchecked(&lis3->count, 0);
39101 return 0;
39102 }
39103
39104 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39105 add_wait_queue(&lis3->misc_wait, &wait);
39106 while (true) {
39107 set_current_state(TASK_INTERRUPTIBLE);
39108 - data = atomic_xchg(&lis3->count, 0);
39109 + data = atomic_xchg_unchecked(&lis3->count, 0);
39110 if (data)
39111 break;
39112
39113 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39114 struct lis3lv02d, miscdev);
39115
39116 poll_wait(file, &lis3->misc_wait, wait);
39117 - if (atomic_read(&lis3->count))
39118 + if (atomic_read_unchecked(&lis3->count))
39119 return POLLIN | POLLRDNORM;
39120 return 0;
39121 }
39122 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39123 index c439c82..1f20f57 100644
39124 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39125 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39126 @@ -297,7 +297,7 @@ struct lis3lv02d {
39127 struct input_polled_dev *idev; /* input device */
39128 struct platform_device *pdev; /* platform device */
39129 struct regulator_bulk_data regulators[2];
39130 - atomic_t count; /* interrupt count after last read */
39131 + atomic_unchecked_t count; /* interrupt count after last read */
39132 union axis_conversion ac; /* hw -> logical axis */
39133 int mapped_btns[3];
39134
39135 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39136 index 2f30bad..c4c13d0 100644
39137 --- a/drivers/misc/sgi-gru/gruhandles.c
39138 +++ b/drivers/misc/sgi-gru/gruhandles.c
39139 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39140 unsigned long nsec;
39141
39142 nsec = CLKS2NSEC(clks);
39143 - atomic_long_inc(&mcs_op_statistics[op].count);
39144 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39145 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39146 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39147 if (mcs_op_statistics[op].max < nsec)
39148 mcs_op_statistics[op].max = nsec;
39149 }
39150 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39151 index 950dbe9..eeef0f8 100644
39152 --- a/drivers/misc/sgi-gru/gruprocfs.c
39153 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39154 @@ -32,9 +32,9 @@
39155
39156 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39157
39158 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39159 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39160 {
39161 - unsigned long val = atomic_long_read(v);
39162 + unsigned long val = atomic_long_read_unchecked(v);
39163
39164 seq_printf(s, "%16lu %s\n", val, id);
39165 }
39166 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39167
39168 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39169 for (op = 0; op < mcsop_last; op++) {
39170 - count = atomic_long_read(&mcs_op_statistics[op].count);
39171 - total = atomic_long_read(&mcs_op_statistics[op].total);
39172 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39173 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39174 max = mcs_op_statistics[op].max;
39175 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39176 count ? total / count : 0, max);
39177 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39178 index 5c3ce24..4915ccb 100644
39179 --- a/drivers/misc/sgi-gru/grutables.h
39180 +++ b/drivers/misc/sgi-gru/grutables.h
39181 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39182 * GRU statistics.
39183 */
39184 struct gru_stats_s {
39185 - atomic_long_t vdata_alloc;
39186 - atomic_long_t vdata_free;
39187 - atomic_long_t gts_alloc;
39188 - atomic_long_t gts_free;
39189 - atomic_long_t gms_alloc;
39190 - atomic_long_t gms_free;
39191 - atomic_long_t gts_double_allocate;
39192 - atomic_long_t assign_context;
39193 - atomic_long_t assign_context_failed;
39194 - atomic_long_t free_context;
39195 - atomic_long_t load_user_context;
39196 - atomic_long_t load_kernel_context;
39197 - atomic_long_t lock_kernel_context;
39198 - atomic_long_t unlock_kernel_context;
39199 - atomic_long_t steal_user_context;
39200 - atomic_long_t steal_kernel_context;
39201 - atomic_long_t steal_context_failed;
39202 - atomic_long_t nopfn;
39203 - atomic_long_t asid_new;
39204 - atomic_long_t asid_next;
39205 - atomic_long_t asid_wrap;
39206 - atomic_long_t asid_reuse;
39207 - atomic_long_t intr;
39208 - atomic_long_t intr_cbr;
39209 - atomic_long_t intr_tfh;
39210 - atomic_long_t intr_spurious;
39211 - atomic_long_t intr_mm_lock_failed;
39212 - atomic_long_t call_os;
39213 - atomic_long_t call_os_wait_queue;
39214 - atomic_long_t user_flush_tlb;
39215 - atomic_long_t user_unload_context;
39216 - atomic_long_t user_exception;
39217 - atomic_long_t set_context_option;
39218 - atomic_long_t check_context_retarget_intr;
39219 - atomic_long_t check_context_unload;
39220 - atomic_long_t tlb_dropin;
39221 - atomic_long_t tlb_preload_page;
39222 - atomic_long_t tlb_dropin_fail_no_asid;
39223 - atomic_long_t tlb_dropin_fail_upm;
39224 - atomic_long_t tlb_dropin_fail_invalid;
39225 - atomic_long_t tlb_dropin_fail_range_active;
39226 - atomic_long_t tlb_dropin_fail_idle;
39227 - atomic_long_t tlb_dropin_fail_fmm;
39228 - atomic_long_t tlb_dropin_fail_no_exception;
39229 - atomic_long_t tfh_stale_on_fault;
39230 - atomic_long_t mmu_invalidate_range;
39231 - atomic_long_t mmu_invalidate_page;
39232 - atomic_long_t flush_tlb;
39233 - atomic_long_t flush_tlb_gru;
39234 - atomic_long_t flush_tlb_gru_tgh;
39235 - atomic_long_t flush_tlb_gru_zero_asid;
39236 + atomic_long_unchecked_t vdata_alloc;
39237 + atomic_long_unchecked_t vdata_free;
39238 + atomic_long_unchecked_t gts_alloc;
39239 + atomic_long_unchecked_t gts_free;
39240 + atomic_long_unchecked_t gms_alloc;
39241 + atomic_long_unchecked_t gms_free;
39242 + atomic_long_unchecked_t gts_double_allocate;
39243 + atomic_long_unchecked_t assign_context;
39244 + atomic_long_unchecked_t assign_context_failed;
39245 + atomic_long_unchecked_t free_context;
39246 + atomic_long_unchecked_t load_user_context;
39247 + atomic_long_unchecked_t load_kernel_context;
39248 + atomic_long_unchecked_t lock_kernel_context;
39249 + atomic_long_unchecked_t unlock_kernel_context;
39250 + atomic_long_unchecked_t steal_user_context;
39251 + atomic_long_unchecked_t steal_kernel_context;
39252 + atomic_long_unchecked_t steal_context_failed;
39253 + atomic_long_unchecked_t nopfn;
39254 + atomic_long_unchecked_t asid_new;
39255 + atomic_long_unchecked_t asid_next;
39256 + atomic_long_unchecked_t asid_wrap;
39257 + atomic_long_unchecked_t asid_reuse;
39258 + atomic_long_unchecked_t intr;
39259 + atomic_long_unchecked_t intr_cbr;
39260 + atomic_long_unchecked_t intr_tfh;
39261 + atomic_long_unchecked_t intr_spurious;
39262 + atomic_long_unchecked_t intr_mm_lock_failed;
39263 + atomic_long_unchecked_t call_os;
39264 + atomic_long_unchecked_t call_os_wait_queue;
39265 + atomic_long_unchecked_t user_flush_tlb;
39266 + atomic_long_unchecked_t user_unload_context;
39267 + atomic_long_unchecked_t user_exception;
39268 + atomic_long_unchecked_t set_context_option;
39269 + atomic_long_unchecked_t check_context_retarget_intr;
39270 + atomic_long_unchecked_t check_context_unload;
39271 + atomic_long_unchecked_t tlb_dropin;
39272 + atomic_long_unchecked_t tlb_preload_page;
39273 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39274 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39275 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39276 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39277 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39278 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39279 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39280 + atomic_long_unchecked_t tfh_stale_on_fault;
39281 + atomic_long_unchecked_t mmu_invalidate_range;
39282 + atomic_long_unchecked_t mmu_invalidate_page;
39283 + atomic_long_unchecked_t flush_tlb;
39284 + atomic_long_unchecked_t flush_tlb_gru;
39285 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39286 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39287
39288 - atomic_long_t copy_gpa;
39289 - atomic_long_t read_gpa;
39290 + atomic_long_unchecked_t copy_gpa;
39291 + atomic_long_unchecked_t read_gpa;
39292
39293 - atomic_long_t mesq_receive;
39294 - atomic_long_t mesq_receive_none;
39295 - atomic_long_t mesq_send;
39296 - atomic_long_t mesq_send_failed;
39297 - atomic_long_t mesq_noop;
39298 - atomic_long_t mesq_send_unexpected_error;
39299 - atomic_long_t mesq_send_lb_overflow;
39300 - atomic_long_t mesq_send_qlimit_reached;
39301 - atomic_long_t mesq_send_amo_nacked;
39302 - atomic_long_t mesq_send_put_nacked;
39303 - atomic_long_t mesq_page_overflow;
39304 - atomic_long_t mesq_qf_locked;
39305 - atomic_long_t mesq_qf_noop_not_full;
39306 - atomic_long_t mesq_qf_switch_head_failed;
39307 - atomic_long_t mesq_qf_unexpected_error;
39308 - atomic_long_t mesq_noop_unexpected_error;
39309 - atomic_long_t mesq_noop_lb_overflow;
39310 - atomic_long_t mesq_noop_qlimit_reached;
39311 - atomic_long_t mesq_noop_amo_nacked;
39312 - atomic_long_t mesq_noop_put_nacked;
39313 - atomic_long_t mesq_noop_page_overflow;
39314 + atomic_long_unchecked_t mesq_receive;
39315 + atomic_long_unchecked_t mesq_receive_none;
39316 + atomic_long_unchecked_t mesq_send;
39317 + atomic_long_unchecked_t mesq_send_failed;
39318 + atomic_long_unchecked_t mesq_noop;
39319 + atomic_long_unchecked_t mesq_send_unexpected_error;
39320 + atomic_long_unchecked_t mesq_send_lb_overflow;
39321 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39322 + atomic_long_unchecked_t mesq_send_amo_nacked;
39323 + atomic_long_unchecked_t mesq_send_put_nacked;
39324 + atomic_long_unchecked_t mesq_page_overflow;
39325 + atomic_long_unchecked_t mesq_qf_locked;
39326 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39327 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39328 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39329 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39330 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39331 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39332 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39333 + atomic_long_unchecked_t mesq_noop_put_nacked;
39334 + atomic_long_unchecked_t mesq_noop_page_overflow;
39335
39336 };
39337
39338 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39339 tghop_invalidate, mcsop_last};
39340
39341 struct mcs_op_statistic {
39342 - atomic_long_t count;
39343 - atomic_long_t total;
39344 + atomic_long_unchecked_t count;
39345 + atomic_long_unchecked_t total;
39346 unsigned long max;
39347 };
39348
39349 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39350
39351 #define STAT(id) do { \
39352 if (gru_options & OPT_STATS) \
39353 - atomic_long_inc(&gru_stats.id); \
39354 + atomic_long_inc_unchecked(&gru_stats.id); \
39355 } while (0)
39356
39357 #ifdef CONFIG_SGI_GRU_DEBUG
39358 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39359 index c862cd4..0d176fe 100644
39360 --- a/drivers/misc/sgi-xp/xp.h
39361 +++ b/drivers/misc/sgi-xp/xp.h
39362 @@ -288,7 +288,7 @@ struct xpc_interface {
39363 xpc_notify_func, void *);
39364 void (*received) (short, int, void *);
39365 enum xp_retval (*partid_to_nasids) (short, void *);
39366 -};
39367 +} __no_const;
39368
39369 extern struct xpc_interface xpc_interface;
39370
39371 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39372 index b94d5f7..7f494c5 100644
39373 --- a/drivers/misc/sgi-xp/xpc.h
39374 +++ b/drivers/misc/sgi-xp/xpc.h
39375 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39376 void (*received_payload) (struct xpc_channel *, void *);
39377 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39378 };
39379 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39380
39381 /* struct xpc_partition act_state values (for XPC HB) */
39382
39383 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39384 /* found in xpc_main.c */
39385 extern struct device *xpc_part;
39386 extern struct device *xpc_chan;
39387 -extern struct xpc_arch_operations xpc_arch_ops;
39388 +extern xpc_arch_operations_no_const xpc_arch_ops;
39389 extern int xpc_disengage_timelimit;
39390 extern int xpc_disengage_timedout;
39391 extern int xpc_activate_IRQ_rcvd;
39392 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39393 index d971817..33bdca5 100644
39394 --- a/drivers/misc/sgi-xp/xpc_main.c
39395 +++ b/drivers/misc/sgi-xp/xpc_main.c
39396 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39397 .notifier_call = xpc_system_die,
39398 };
39399
39400 -struct xpc_arch_operations xpc_arch_ops;
39401 +xpc_arch_operations_no_const xpc_arch_ops;
39402
39403 /*
39404 * Timer function to enforce the timelimit on the partition disengage.
39405 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39406
39407 if (((die_args->trapnr == X86_TRAP_MF) ||
39408 (die_args->trapnr == X86_TRAP_XF)) &&
39409 - !user_mode_vm(die_args->regs))
39410 + !user_mode(die_args->regs))
39411 xpc_die_deactivate();
39412
39413 break;
39414 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39415 index 49f04bc..65660c2 100644
39416 --- a/drivers/mmc/core/mmc_ops.c
39417 +++ b/drivers/mmc/core/mmc_ops.c
39418 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39419 void *data_buf;
39420 int is_on_stack;
39421
39422 - is_on_stack = object_is_on_stack(buf);
39423 + is_on_stack = object_starts_on_stack(buf);
39424 if (is_on_stack) {
39425 /*
39426 * dma onto stack is unsafe/nonportable, but callers to this
39427 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39428 index 53b8fd9..615b462 100644
39429 --- a/drivers/mmc/host/dw_mmc.h
39430 +++ b/drivers/mmc/host/dw_mmc.h
39431 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39432 int (*parse_dt)(struct dw_mci *host);
39433 int (*setup_bus)(struct dw_mci *host,
39434 struct device_node *slot_np, u8 bus_width);
39435 -};
39436 +} __do_const;
39437 #endif /* _DW_MMC_H_ */
39438 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39439 index 7363efe..681558e 100644
39440 --- a/drivers/mmc/host/sdhci-s3c.c
39441 +++ b/drivers/mmc/host/sdhci-s3c.c
39442 @@ -720,9 +720,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39443 * we can use overriding functions instead of default.
39444 */
39445 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39446 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39447 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39448 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39449 + pax_open_kernel();
39450 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39451 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39452 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39453 + pax_close_kernel();
39454 }
39455
39456 /* It supports additional host capabilities if needed */
39457 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39458 index a4eb8b5..8c0628f 100644
39459 --- a/drivers/mtd/devices/doc2000.c
39460 +++ b/drivers/mtd/devices/doc2000.c
39461 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39462
39463 /* The ECC will not be calculated correctly if less than 512 is written */
39464 /* DBB-
39465 - if (len != 0x200 && eccbuf)
39466 + if (len != 0x200)
39467 printk(KERN_WARNING
39468 "ECC needs a full sector write (adr: %lx size %lx)\n",
39469 (long) to, (long) len);
39470 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39471 index 0c8bb6b..6f35deb 100644
39472 --- a/drivers/mtd/nand/denali.c
39473 +++ b/drivers/mtd/nand/denali.c
39474 @@ -24,6 +24,7 @@
39475 #include <linux/slab.h>
39476 #include <linux/mtd/mtd.h>
39477 #include <linux/module.h>
39478 +#include <linux/slab.h>
39479
39480 #include "denali.h"
39481
39482 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39483 index 51b9d6a..52af9a7 100644
39484 --- a/drivers/mtd/nftlmount.c
39485 +++ b/drivers/mtd/nftlmount.c
39486 @@ -24,6 +24,7 @@
39487 #include <asm/errno.h>
39488 #include <linux/delay.h>
39489 #include <linux/slab.h>
39490 +#include <linux/sched.h>
39491 #include <linux/mtd/mtd.h>
39492 #include <linux/mtd/nand.h>
39493 #include <linux/mtd/nftl.h>
39494 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39495 index 8dd6ba5..419cc1d 100644
39496 --- a/drivers/mtd/sm_ftl.c
39497 +++ b/drivers/mtd/sm_ftl.c
39498 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39499 #define SM_CIS_VENDOR_OFFSET 0x59
39500 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39501 {
39502 - struct attribute_group *attr_group;
39503 + attribute_group_no_const *attr_group;
39504 struct attribute **attributes;
39505 struct sm_sysfs_attribute *vendor_attribute;
39506
39507 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39508 index dbbea0e..3f4a0b1 100644
39509 --- a/drivers/net/bonding/bond_main.c
39510 +++ b/drivers/net/bonding/bond_main.c
39511 @@ -4822,7 +4822,7 @@ static unsigned int bond_get_num_tx_queues(void)
39512 return tx_queues;
39513 }
39514
39515 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39516 +static struct rtnl_link_ops bond_link_ops = {
39517 .kind = "bond",
39518 .priv_size = sizeof(struct bonding),
39519 .setup = bond_setup,
39520 @@ -4947,8 +4947,8 @@ static void __exit bonding_exit(void)
39521
39522 bond_destroy_debugfs();
39523
39524 - rtnl_link_unregister(&bond_link_ops);
39525 unregister_pernet_subsys(&bond_net_ops);
39526 + rtnl_link_unregister(&bond_link_ops);
39527
39528 #ifdef CONFIG_NET_POLL_CONTROLLER
39529 /*
39530 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39531 index e1d2643..7f4133b 100644
39532 --- a/drivers/net/ethernet/8390/ax88796.c
39533 +++ b/drivers/net/ethernet/8390/ax88796.c
39534 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39535 if (ax->plat->reg_offsets)
39536 ei_local->reg_offset = ax->plat->reg_offsets;
39537 else {
39538 + resource_size_t _mem_size = mem_size;
39539 + do_div(_mem_size, 0x18);
39540 ei_local->reg_offset = ax->reg_offsets;
39541 for (ret = 0; ret < 0x18; ret++)
39542 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39543 + ax->reg_offsets[ret] = _mem_size * ret;
39544 }
39545
39546 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39547 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39548 index aee7671..3ca2651 100644
39549 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39550 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39551 @@ -1093,7 +1093,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39552 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39553 {
39554 /* RX_MODE controlling object */
39555 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39556 + bnx2x_init_rx_mode_obj(bp);
39557
39558 /* multicast configuration controlling object */
39559 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39560 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39561 index 7306416..5fb7fb5 100644
39562 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39563 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39564 @@ -2381,15 +2381,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39565 return rc;
39566 }
39567
39568 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39569 - struct bnx2x_rx_mode_obj *o)
39570 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39571 {
39572 if (CHIP_IS_E1x(bp)) {
39573 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39574 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39575 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39576 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39577 } else {
39578 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39579 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39580 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39581 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39582 }
39583 }
39584
39585 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39586 index ff90760..08d8aed 100644
39587 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39588 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39589 @@ -1306,8 +1306,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39590
39591 /********************* RX MODE ****************/
39592
39593 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39594 - struct bnx2x_rx_mode_obj *o);
39595 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39596
39597 /**
39598 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39599 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39600 index 8d7d4c2..95f7681 100644
39601 --- a/drivers/net/ethernet/broadcom/tg3.h
39602 +++ b/drivers/net/ethernet/broadcom/tg3.h
39603 @@ -147,6 +147,7 @@
39604 #define CHIPREV_ID_5750_A0 0x4000
39605 #define CHIPREV_ID_5750_A1 0x4001
39606 #define CHIPREV_ID_5750_A3 0x4003
39607 +#define CHIPREV_ID_5750_C1 0x4201
39608 #define CHIPREV_ID_5750_C2 0x4202
39609 #define CHIPREV_ID_5752_A0_HW 0x5000
39610 #define CHIPREV_ID_5752_A0 0x6000
39611 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39612 index 8cffcdf..aadf043 100644
39613 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39614 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39615 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39616 */
39617 struct l2t_skb_cb {
39618 arp_failure_handler_func arp_failure_handler;
39619 -};
39620 +} __no_const;
39621
39622 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39623
39624 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39625 index 4c83003..2a2a5b9 100644
39626 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39627 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39628 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39629 for (i=0; i<ETH_ALEN; i++) {
39630 tmp.addr[i] = dev->dev_addr[i];
39631 }
39632 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39633 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39634 break;
39635
39636 case DE4X5_SET_HWADDR: /* Set the hardware address */
39637 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39638 spin_lock_irqsave(&lp->lock, flags);
39639 memcpy(&statbuf, &lp->pktStats, ioc->len);
39640 spin_unlock_irqrestore(&lp->lock, flags);
39641 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39642 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39643 return -EFAULT;
39644 break;
39645 }
39646 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39647 index 2886c9b..db71673 100644
39648 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39649 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39650 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39651
39652 if (wrapped)
39653 newacc += 65536;
39654 - ACCESS_ONCE(*acc) = newacc;
39655 + ACCESS_ONCE_RW(*acc) = newacc;
39656 }
39657
39658 void be_parse_stats(struct be_adapter *adapter)
39659 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39660 index 7c361d1..57e3ff1 100644
39661 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39662 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39663 @@ -31,6 +31,8 @@
39664 #include <linux/netdevice.h>
39665 #include <linux/phy.h>
39666 #include <linux/platform_device.h>
39667 +#include <linux/interrupt.h>
39668 +#include <linux/irqreturn.h>
39669 #include <net/ip.h>
39670
39671 #include "ftgmac100.h"
39672 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39673 index b5ea8fb..bd25e9a 100644
39674 --- a/drivers/net/ethernet/faraday/ftmac100.c
39675 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39676 @@ -31,6 +31,8 @@
39677 #include <linux/module.h>
39678 #include <linux/netdevice.h>
39679 #include <linux/platform_device.h>
39680 +#include <linux/interrupt.h>
39681 +#include <linux/irqreturn.h>
39682
39683 #include "ftmac100.h"
39684
39685 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39686 index 331987d..3be1135 100644
39687 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39688 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39689 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
39690 }
39691
39692 /* update the base incval used to calculate frequency adjustment */
39693 - ACCESS_ONCE(adapter->base_incval) = incval;
39694 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
39695 smp_mb();
39696
39697 /* need lock to prevent incorrect read while modifying cyclecounter */
39698 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39699 index fbe5363..266b4e3 100644
39700 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
39701 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39702 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39703 struct __vxge_hw_fifo *fifo;
39704 struct vxge_hw_fifo_config *config;
39705 u32 txdl_size, txdl_per_memblock;
39706 - struct vxge_hw_mempool_cbs fifo_mp_callback;
39707 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
39708 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
39709 + };
39710 +
39711 struct __vxge_hw_virtualpath *vpath;
39712
39713 if ((vp == NULL) || (attr == NULL)) {
39714 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39715 goto exit;
39716 }
39717
39718 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
39719 -
39720 fifo->mempool =
39721 __vxge_hw_mempool_create(vpath->hldev,
39722 fifo->config->memblock_size,
39723 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39724 index 5c033f2..7bbb0d8 100644
39725 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39726 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39727 @@ -1894,7 +1894,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
39728 op_mode = QLCRDX(ahw, QLC_83XX_DRV_OP_MODE);
39729
39730 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
39731 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
39732 + pax_open_kernel();
39733 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
39734 + pax_close_kernel();
39735 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39736 } else {
39737 return -EIO;
39738 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39739 index b0c3de9..fc5857e 100644
39740 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39741 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39742 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
39743 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
39744 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
39745 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39746 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
39747 + pax_open_kernel();
39748 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
39749 + pax_close_kernel();
39750 } else if (priv_level == QLCNIC_PRIV_FUNC) {
39751 ahw->op_mode = QLCNIC_PRIV_FUNC;
39752 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
39753 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
39754 + pax_open_kernel();
39755 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
39756 + pax_close_kernel();
39757 } else if (priv_level == QLCNIC_MGMT_FUNC) {
39758 ahw->op_mode = QLCNIC_MGMT_FUNC;
39759 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39760 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
39761 + pax_open_kernel();
39762 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
39763 + pax_close_kernel();
39764 } else {
39765 return -EIO;
39766 }
39767 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
39768 index 15ba8c4..3f56838 100644
39769 --- a/drivers/net/ethernet/realtek/r8169.c
39770 +++ b/drivers/net/ethernet/realtek/r8169.c
39771 @@ -740,22 +740,22 @@ struct rtl8169_private {
39772 struct mdio_ops {
39773 void (*write)(struct rtl8169_private *, int, int);
39774 int (*read)(struct rtl8169_private *, int);
39775 - } mdio_ops;
39776 + } __no_const mdio_ops;
39777
39778 struct pll_power_ops {
39779 void (*down)(struct rtl8169_private *);
39780 void (*up)(struct rtl8169_private *);
39781 - } pll_power_ops;
39782 + } __no_const pll_power_ops;
39783
39784 struct jumbo_ops {
39785 void (*enable)(struct rtl8169_private *);
39786 void (*disable)(struct rtl8169_private *);
39787 - } jumbo_ops;
39788 + } __no_const jumbo_ops;
39789
39790 struct csi_ops {
39791 void (*write)(struct rtl8169_private *, int, int);
39792 u32 (*read)(struct rtl8169_private *, int);
39793 - } csi_ops;
39794 + } __no_const csi_ops;
39795
39796 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
39797 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
39798 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
39799 index 3f93624..cf01144 100644
39800 --- a/drivers/net/ethernet/sfc/ptp.c
39801 +++ b/drivers/net/ethernet/sfc/ptp.c
39802 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
39803 (u32)((u64)ptp->start.dma_addr >> 32));
39804
39805 /* Clear flag that signals MC ready */
39806 - ACCESS_ONCE(*start) = 0;
39807 + ACCESS_ONCE_RW(*start) = 0;
39808 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
39809 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
39810
39811 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39812 index 50617c5..b13724c 100644
39813 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39814 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39815 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
39816
39817 writel(value, ioaddr + MMC_CNTRL);
39818
39819 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39820 - MMC_CNTRL, value);
39821 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39822 +// MMC_CNTRL, value);
39823 }
39824
39825 /* To mask all all interrupts.*/
39826 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
39827 index e6fe0d8..2b7d752 100644
39828 --- a/drivers/net/hyperv/hyperv_net.h
39829 +++ b/drivers/net/hyperv/hyperv_net.h
39830 @@ -101,7 +101,7 @@ struct rndis_device {
39831
39832 enum rndis_device_state state;
39833 bool link_state;
39834 - atomic_t new_req_id;
39835 + atomic_unchecked_t new_req_id;
39836
39837 spinlock_t request_lock;
39838 struct list_head req_list;
39839 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
39840 index 0775f0a..d4fb316 100644
39841 --- a/drivers/net/hyperv/rndis_filter.c
39842 +++ b/drivers/net/hyperv/rndis_filter.c
39843 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
39844 * template
39845 */
39846 set = &rndis_msg->msg.set_req;
39847 - set->req_id = atomic_inc_return(&dev->new_req_id);
39848 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39849
39850 /* Add to the request list */
39851 spin_lock_irqsave(&dev->request_lock, flags);
39852 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
39853
39854 /* Setup the rndis set */
39855 halt = &request->request_msg.msg.halt_req;
39856 - halt->req_id = atomic_inc_return(&dev->new_req_id);
39857 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39858
39859 /* Ignore return since this msg is optional. */
39860 rndis_filter_send_request(dev, request);
39861 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
39862 index 8f1c256..a2991d1 100644
39863 --- a/drivers/net/ieee802154/fakehard.c
39864 +++ b/drivers/net/ieee802154/fakehard.c
39865 @@ -385,7 +385,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
39866 phy->transmit_power = 0xbf;
39867
39868 dev->netdev_ops = &fake_ops;
39869 - dev->ml_priv = &fake_mlme;
39870 + dev->ml_priv = (void *)&fake_mlme;
39871
39872 priv = netdev_priv(dev);
39873 priv->phy = phy;
39874 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
39875 index 011062e..ada88e9 100644
39876 --- a/drivers/net/macvlan.c
39877 +++ b/drivers/net/macvlan.c
39878 @@ -892,13 +892,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
39879 int macvlan_link_register(struct rtnl_link_ops *ops)
39880 {
39881 /* common fields */
39882 - ops->priv_size = sizeof(struct macvlan_dev);
39883 - ops->validate = macvlan_validate;
39884 - ops->maxtype = IFLA_MACVLAN_MAX;
39885 - ops->policy = macvlan_policy;
39886 - ops->changelink = macvlan_changelink;
39887 - ops->get_size = macvlan_get_size;
39888 - ops->fill_info = macvlan_fill_info;
39889 + pax_open_kernel();
39890 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
39891 + *(void **)&ops->validate = macvlan_validate;
39892 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
39893 + *(const void **)&ops->policy = macvlan_policy;
39894 + *(void **)&ops->changelink = macvlan_changelink;
39895 + *(void **)&ops->get_size = macvlan_get_size;
39896 + *(void **)&ops->fill_info = macvlan_fill_info;
39897 + pax_close_kernel();
39898
39899 return rtnl_link_register(ops);
39900 };
39901 @@ -954,7 +956,7 @@ static int macvlan_device_event(struct notifier_block *unused,
39902 return NOTIFY_DONE;
39903 }
39904
39905 -static struct notifier_block macvlan_notifier_block __read_mostly = {
39906 +static struct notifier_block macvlan_notifier_block = {
39907 .notifier_call = macvlan_device_event,
39908 };
39909
39910 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
39911 index a449439..1e468fe 100644
39912 --- a/drivers/net/macvtap.c
39913 +++ b/drivers/net/macvtap.c
39914 @@ -1090,7 +1090,7 @@ static int macvtap_device_event(struct notifier_block *unused,
39915 return NOTIFY_DONE;
39916 }
39917
39918 -static struct notifier_block macvtap_notifier_block __read_mostly = {
39919 +static struct notifier_block macvtap_notifier_block = {
39920 .notifier_call = macvtap_device_event,
39921 };
39922
39923 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
39924 index daec9b0..6428fcb 100644
39925 --- a/drivers/net/phy/mdio-bitbang.c
39926 +++ b/drivers/net/phy/mdio-bitbang.c
39927 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
39928 struct mdiobb_ctrl *ctrl = bus->priv;
39929
39930 module_put(ctrl->ops->owner);
39931 + mdiobus_unregister(bus);
39932 mdiobus_free(bus);
39933 }
39934 EXPORT_SYMBOL(free_mdio_bitbang);
39935 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
39936 index 72ff14b..11d442d 100644
39937 --- a/drivers/net/ppp/ppp_generic.c
39938 +++ b/drivers/net/ppp/ppp_generic.c
39939 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39940 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
39941 struct ppp_stats stats;
39942 struct ppp_comp_stats cstats;
39943 - char *vers;
39944
39945 switch (cmd) {
39946 case SIOCGPPPSTATS:
39947 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39948 break;
39949
39950 case SIOCGPPPVER:
39951 - vers = PPP_VERSION;
39952 - if (copy_to_user(addr, vers, strlen(vers) + 1))
39953 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
39954 break;
39955 err = 0;
39956 break;
39957 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
39958 index 1252d9c..80e660b 100644
39959 --- a/drivers/net/slip/slhc.c
39960 +++ b/drivers/net/slip/slhc.c
39961 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
39962 register struct tcphdr *thp;
39963 register struct iphdr *ip;
39964 register struct cstate *cs;
39965 - int len, hdrlen;
39966 + long len, hdrlen;
39967 unsigned char *cp = icp;
39968
39969 /* We've got a compressed packet; read the change byte */
39970 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
39971 index bf34192..fba3500 100644
39972 --- a/drivers/net/team/team.c
39973 +++ b/drivers/net/team/team.c
39974 @@ -2668,7 +2668,7 @@ static int team_device_event(struct notifier_block *unused,
39975 return NOTIFY_DONE;
39976 }
39977
39978 -static struct notifier_block team_notifier_block __read_mostly = {
39979 +static struct notifier_block team_notifier_block = {
39980 .notifier_call = team_device_event,
39981 };
39982
39983 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
39984 index 755fa9e..631fdce 100644
39985 --- a/drivers/net/tun.c
39986 +++ b/drivers/net/tun.c
39987 @@ -1841,7 +1841,7 @@ unlock:
39988 }
39989
39990 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39991 - unsigned long arg, int ifreq_len)
39992 + unsigned long arg, size_t ifreq_len)
39993 {
39994 struct tun_file *tfile = file->private_data;
39995 struct tun_struct *tun;
39996 @@ -1853,6 +1853,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39997 int vnet_hdr_sz;
39998 int ret;
39999
40000 + if (ifreq_len > sizeof ifr)
40001 + return -EFAULT;
40002 +
40003 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40004 if (copy_from_user(&ifr, argp, ifreq_len))
40005 return -EFAULT;
40006 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40007 index e2dd324..be92fcf 100644
40008 --- a/drivers/net/usb/hso.c
40009 +++ b/drivers/net/usb/hso.c
40010 @@ -71,7 +71,7 @@
40011 #include <asm/byteorder.h>
40012 #include <linux/serial_core.h>
40013 #include <linux/serial.h>
40014 -
40015 +#include <asm/local.h>
40016
40017 #define MOD_AUTHOR "Option Wireless"
40018 #define MOD_DESCRIPTION "USB High Speed Option driver"
40019 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40020 struct urb *urb;
40021
40022 urb = serial->rx_urb[0];
40023 - if (serial->port.count > 0) {
40024 + if (atomic_read(&serial->port.count) > 0) {
40025 count = put_rxbuf_data(urb, serial);
40026 if (count == -1)
40027 return;
40028 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40029 DUMP1(urb->transfer_buffer, urb->actual_length);
40030
40031 /* Anyone listening? */
40032 - if (serial->port.count == 0)
40033 + if (atomic_read(&serial->port.count) == 0)
40034 return;
40035
40036 if (status == 0) {
40037 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40038 tty_port_tty_set(&serial->port, tty);
40039
40040 /* check for port already opened, if not set the termios */
40041 - serial->port.count++;
40042 - if (serial->port.count == 1) {
40043 + if (atomic_inc_return(&serial->port.count) == 1) {
40044 serial->rx_state = RX_IDLE;
40045 /* Force default termio settings */
40046 _hso_serial_set_termios(tty, NULL);
40047 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40048 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40049 if (result) {
40050 hso_stop_serial_device(serial->parent);
40051 - serial->port.count--;
40052 + atomic_dec(&serial->port.count);
40053 kref_put(&serial->parent->ref, hso_serial_ref_free);
40054 }
40055 } else {
40056 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40057
40058 /* reset the rts and dtr */
40059 /* do the actual close */
40060 - serial->port.count--;
40061 + atomic_dec(&serial->port.count);
40062
40063 - if (serial->port.count <= 0) {
40064 - serial->port.count = 0;
40065 + if (atomic_read(&serial->port.count) <= 0) {
40066 + atomic_set(&serial->port.count, 0);
40067 tty_port_tty_set(&serial->port, NULL);
40068 if (!usb_gone)
40069 hso_stop_serial_device(serial->parent);
40070 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40071
40072 /* the actual setup */
40073 spin_lock_irqsave(&serial->serial_lock, flags);
40074 - if (serial->port.count)
40075 + if (atomic_read(&serial->port.count))
40076 _hso_serial_set_termios(tty, old);
40077 else
40078 tty->termios = *old;
40079 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40080 D1("Pending read interrupt on port %d\n", i);
40081 spin_lock(&serial->serial_lock);
40082 if (serial->rx_state == RX_IDLE &&
40083 - serial->port.count > 0) {
40084 + atomic_read(&serial->port.count) > 0) {
40085 /* Setup and send a ctrl req read on
40086 * port i */
40087 if (!serial->rx_urb_filled[0]) {
40088 @@ -3066,7 +3065,7 @@ static int hso_resume(struct usb_interface *iface)
40089 /* Start all serial ports */
40090 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40091 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40092 - if (dev2ser(serial_table[i])->port.count) {
40093 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40094 result =
40095 hso_start_serial_device(serial_table[i], GFP_NOIO);
40096 hso_kick_transmit(dev2ser(serial_table[i]));
40097 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40098 index 7cee7a3..1eb9f3b 100644
40099 --- a/drivers/net/vxlan.c
40100 +++ b/drivers/net/vxlan.c
40101 @@ -1443,7 +1443,7 @@ nla_put_failure:
40102 return -EMSGSIZE;
40103 }
40104
40105 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40106 +static struct rtnl_link_ops vxlan_link_ops = {
40107 .kind = "vxlan",
40108 .maxtype = IFLA_VXLAN_MAX,
40109 .policy = vxlan_policy,
40110 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40111 index 5ac5f7a..5f82012 100644
40112 --- a/drivers/net/wireless/at76c50x-usb.c
40113 +++ b/drivers/net/wireless/at76c50x-usb.c
40114 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40115 }
40116
40117 /* Convert timeout from the DFU status to jiffies */
40118 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40119 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40120 {
40121 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40122 | (s->poll_timeout[1] << 8)
40123 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40124 index 8d78253..bebbb68 100644
40125 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40126 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40127 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40128 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40129 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40130
40131 - ACCESS_ONCE(ads->ds_link) = i->link;
40132 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40133 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40134 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40135
40136 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40137 ctl6 = SM(i->keytype, AR_EncrType);
40138 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40139
40140 if ((i->is_first || i->is_last) &&
40141 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40142 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40143 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40144 | set11nTries(i->rates, 1)
40145 | set11nTries(i->rates, 2)
40146 | set11nTries(i->rates, 3)
40147 | (i->dur_update ? AR_DurUpdateEna : 0)
40148 | SM(0, AR_BurstDur);
40149
40150 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40151 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40152 | set11nRate(i->rates, 1)
40153 | set11nRate(i->rates, 2)
40154 | set11nRate(i->rates, 3);
40155 } else {
40156 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40157 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40158 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40159 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40160 }
40161
40162 if (!i->is_first) {
40163 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40164 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40165 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40166 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40167 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40168 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40169 return;
40170 }
40171
40172 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40173 break;
40174 }
40175
40176 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40177 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40178 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40179 | SM(i->txpower, AR_XmitPower)
40180 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40181 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40182 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40183 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40184
40185 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40186 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40187 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40188 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40189
40190 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40191 return;
40192
40193 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40194 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40195 | set11nPktDurRTSCTS(i->rates, 1);
40196
40197 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40198 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40199 | set11nPktDurRTSCTS(i->rates, 3);
40200
40201 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40202 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40203 | set11nRateFlags(i->rates, 1)
40204 | set11nRateFlags(i->rates, 2)
40205 | set11nRateFlags(i->rates, 3)
40206 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40207 index 301bf72..3f5654f 100644
40208 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40209 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40210 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40211 (i->qcu << AR_TxQcuNum_S) | desc_len;
40212
40213 checksum += val;
40214 - ACCESS_ONCE(ads->info) = val;
40215 + ACCESS_ONCE_RW(ads->info) = val;
40216
40217 checksum += i->link;
40218 - ACCESS_ONCE(ads->link) = i->link;
40219 + ACCESS_ONCE_RW(ads->link) = i->link;
40220
40221 checksum += i->buf_addr[0];
40222 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40223 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40224 checksum += i->buf_addr[1];
40225 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40226 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40227 checksum += i->buf_addr[2];
40228 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40229 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40230 checksum += i->buf_addr[3];
40231 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40232 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40233
40234 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40235 - ACCESS_ONCE(ads->ctl3) = val;
40236 + ACCESS_ONCE_RW(ads->ctl3) = val;
40237 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40238 - ACCESS_ONCE(ads->ctl5) = val;
40239 + ACCESS_ONCE_RW(ads->ctl5) = val;
40240 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40241 - ACCESS_ONCE(ads->ctl7) = val;
40242 + ACCESS_ONCE_RW(ads->ctl7) = val;
40243 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40244 - ACCESS_ONCE(ads->ctl9) = val;
40245 + ACCESS_ONCE_RW(ads->ctl9) = val;
40246
40247 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40248 - ACCESS_ONCE(ads->ctl10) = checksum;
40249 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40250
40251 if (i->is_first || i->is_last) {
40252 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40253 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40254 | set11nTries(i->rates, 1)
40255 | set11nTries(i->rates, 2)
40256 | set11nTries(i->rates, 3)
40257 | (i->dur_update ? AR_DurUpdateEna : 0)
40258 | SM(0, AR_BurstDur);
40259
40260 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40261 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40262 | set11nRate(i->rates, 1)
40263 | set11nRate(i->rates, 2)
40264 | set11nRate(i->rates, 3);
40265 } else {
40266 - ACCESS_ONCE(ads->ctl13) = 0;
40267 - ACCESS_ONCE(ads->ctl14) = 0;
40268 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40269 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40270 }
40271
40272 ads->ctl20 = 0;
40273 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40274
40275 ctl17 = SM(i->keytype, AR_EncrType);
40276 if (!i->is_first) {
40277 - ACCESS_ONCE(ads->ctl11) = 0;
40278 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40279 - ACCESS_ONCE(ads->ctl15) = 0;
40280 - ACCESS_ONCE(ads->ctl16) = 0;
40281 - ACCESS_ONCE(ads->ctl17) = ctl17;
40282 - ACCESS_ONCE(ads->ctl18) = 0;
40283 - ACCESS_ONCE(ads->ctl19) = 0;
40284 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40285 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40286 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40287 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40288 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40289 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40290 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40291 return;
40292 }
40293
40294 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40295 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40296 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40297 | SM(i->txpower, AR_XmitPower)
40298 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40299 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40300 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40301 ctl12 |= SM(val, AR_PAPRDChainMask);
40302
40303 - ACCESS_ONCE(ads->ctl12) = ctl12;
40304 - ACCESS_ONCE(ads->ctl17) = ctl17;
40305 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40306 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40307
40308 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40309 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40310 | set11nPktDurRTSCTS(i->rates, 1);
40311
40312 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40313 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40314 | set11nPktDurRTSCTS(i->rates, 3);
40315
40316 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40317 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40318 | set11nRateFlags(i->rates, 1)
40319 | set11nRateFlags(i->rates, 2)
40320 | set11nRateFlags(i->rates, 3)
40321 | SM(i->rtscts_rate, AR_RTSCTSRate);
40322
40323 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40324 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40325 }
40326
40327 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40328 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40329 index 784e81c..349e01e 100644
40330 --- a/drivers/net/wireless/ath/ath9k/hw.h
40331 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40332 @@ -653,7 +653,7 @@ struct ath_hw_private_ops {
40333
40334 /* ANI */
40335 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40336 -};
40337 +} __no_const;
40338
40339 /**
40340 * struct ath_spec_scan - parameters for Atheros spectral scan
40341 @@ -722,7 +722,7 @@ struct ath_hw_ops {
40342 struct ath_spec_scan *param);
40343 void (*spectral_scan_trigger)(struct ath_hw *ah);
40344 void (*spectral_scan_wait)(struct ath_hw *ah);
40345 -};
40346 +} __no_const;
40347
40348 struct ath_nf_limits {
40349 s16 max;
40350 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40351 index c353b5f..62aaca2 100644
40352 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40353 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40354 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40355 */
40356 if (il3945_mod_params.disable_hw_scan) {
40357 D_INFO("Disabling hw_scan\n");
40358 - il3945_mac_ops.hw_scan = NULL;
40359 + pax_open_kernel();
40360 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40361 + pax_close_kernel();
40362 }
40363
40364 D_INFO("*** LOAD DRIVER ***\n");
40365 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40366 index 81d4071..f2071ea 100644
40367 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40368 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40369 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40370 {
40371 struct iwl_priv *priv = file->private_data;
40372 char buf[64];
40373 - int buf_size;
40374 + size_t buf_size;
40375 u32 offset, len;
40376
40377 memset(buf, 0, sizeof(buf));
40378 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40379 struct iwl_priv *priv = file->private_data;
40380
40381 char buf[8];
40382 - int buf_size;
40383 + size_t buf_size;
40384 u32 reset_flag;
40385
40386 memset(buf, 0, sizeof(buf));
40387 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40388 {
40389 struct iwl_priv *priv = file->private_data;
40390 char buf[8];
40391 - int buf_size;
40392 + size_t buf_size;
40393 int ht40;
40394
40395 memset(buf, 0, sizeof(buf));
40396 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40397 {
40398 struct iwl_priv *priv = file->private_data;
40399 char buf[8];
40400 - int buf_size;
40401 + size_t buf_size;
40402 int value;
40403
40404 memset(buf, 0, sizeof(buf));
40405 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40406 {
40407 struct iwl_priv *priv = file->private_data;
40408 char buf[8];
40409 - int buf_size;
40410 + size_t buf_size;
40411 int clear;
40412
40413 memset(buf, 0, sizeof(buf));
40414 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40415 {
40416 struct iwl_priv *priv = file->private_data;
40417 char buf[8];
40418 - int buf_size;
40419 + size_t buf_size;
40420 int trace;
40421
40422 memset(buf, 0, sizeof(buf));
40423 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40424 {
40425 struct iwl_priv *priv = file->private_data;
40426 char buf[8];
40427 - int buf_size;
40428 + size_t buf_size;
40429 int missed;
40430
40431 memset(buf, 0, sizeof(buf));
40432 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40433
40434 struct iwl_priv *priv = file->private_data;
40435 char buf[8];
40436 - int buf_size;
40437 + size_t buf_size;
40438 int plcp;
40439
40440 memset(buf, 0, sizeof(buf));
40441 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40442
40443 struct iwl_priv *priv = file->private_data;
40444 char buf[8];
40445 - int buf_size;
40446 + size_t buf_size;
40447 int flush;
40448
40449 memset(buf, 0, sizeof(buf));
40450 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40451
40452 struct iwl_priv *priv = file->private_data;
40453 char buf[8];
40454 - int buf_size;
40455 + size_t buf_size;
40456 int rts;
40457
40458 if (!priv->cfg->ht_params)
40459 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40460 {
40461 struct iwl_priv *priv = file->private_data;
40462 char buf[8];
40463 - int buf_size;
40464 + size_t buf_size;
40465
40466 memset(buf, 0, sizeof(buf));
40467 buf_size = min(count, sizeof(buf) - 1);
40468 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40469 struct iwl_priv *priv = file->private_data;
40470 u32 event_log_flag;
40471 char buf[8];
40472 - int buf_size;
40473 + size_t buf_size;
40474
40475 /* check that the interface is up */
40476 if (!iwl_is_ready(priv))
40477 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40478 struct iwl_priv *priv = file->private_data;
40479 char buf[8];
40480 u32 calib_disabled;
40481 - int buf_size;
40482 + size_t buf_size;
40483
40484 memset(buf, 0, sizeof(buf));
40485 buf_size = min(count, sizeof(buf) - 1);
40486 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40487 index 12c4f31..484d948 100644
40488 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40489 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40490 @@ -1328,7 +1328,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40491 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40492
40493 char buf[8];
40494 - int buf_size;
40495 + size_t buf_size;
40496 u32 reset_flag;
40497
40498 memset(buf, 0, sizeof(buf));
40499 @@ -1349,7 +1349,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40500 {
40501 struct iwl_trans *trans = file->private_data;
40502 char buf[8];
40503 - int buf_size;
40504 + size_t buf_size;
40505 int csr;
40506
40507 memset(buf, 0, sizeof(buf));
40508 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40509 index cffdf4f..7cefb69 100644
40510 --- a/drivers/net/wireless/mac80211_hwsim.c
40511 +++ b/drivers/net/wireless/mac80211_hwsim.c
40512 @@ -2144,25 +2144,19 @@ static int __init init_mac80211_hwsim(void)
40513
40514 if (channels > 1) {
40515 hwsim_if_comb.num_different_channels = channels;
40516 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40517 - mac80211_hwsim_ops.cancel_hw_scan =
40518 - mac80211_hwsim_cancel_hw_scan;
40519 - mac80211_hwsim_ops.sw_scan_start = NULL;
40520 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40521 - mac80211_hwsim_ops.remain_on_channel =
40522 - mac80211_hwsim_roc;
40523 - mac80211_hwsim_ops.cancel_remain_on_channel =
40524 - mac80211_hwsim_croc;
40525 - mac80211_hwsim_ops.add_chanctx =
40526 - mac80211_hwsim_add_chanctx;
40527 - mac80211_hwsim_ops.remove_chanctx =
40528 - mac80211_hwsim_remove_chanctx;
40529 - mac80211_hwsim_ops.change_chanctx =
40530 - mac80211_hwsim_change_chanctx;
40531 - mac80211_hwsim_ops.assign_vif_chanctx =
40532 - mac80211_hwsim_assign_vif_chanctx;
40533 - mac80211_hwsim_ops.unassign_vif_chanctx =
40534 - mac80211_hwsim_unassign_vif_chanctx;
40535 + pax_open_kernel();
40536 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40537 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40538 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40539 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40540 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40541 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40542 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40543 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40544 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40545 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40546 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40547 + pax_close_kernel();
40548 }
40549
40550 spin_lock_init(&hwsim_radio_lock);
40551 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40552 index 525fd75..6c9f791 100644
40553 --- a/drivers/net/wireless/rndis_wlan.c
40554 +++ b/drivers/net/wireless/rndis_wlan.c
40555 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40556
40557 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40558
40559 - if (rts_threshold < 0 || rts_threshold > 2347)
40560 + if (rts_threshold > 2347)
40561 rts_threshold = 2347;
40562
40563 tmp = cpu_to_le32(rts_threshold);
40564 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40565 index 086abb4..8279c30 100644
40566 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40567 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40568 @@ -396,7 +396,7 @@ struct rt2x00_intf {
40569 * for hardware which doesn't support hardware
40570 * sequence counting.
40571 */
40572 - atomic_t seqno;
40573 + atomic_unchecked_t seqno;
40574 };
40575
40576 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40577 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40578 index 4d91795..62fccff 100644
40579 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40580 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40581 @@ -251,9 +251,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40582 * sequence counter given by mac80211.
40583 */
40584 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40585 - seqno = atomic_add_return(0x10, &intf->seqno);
40586 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40587 else
40588 - seqno = atomic_read(&intf->seqno);
40589 + seqno = atomic_read_unchecked(&intf->seqno);
40590
40591 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40592 hdr->seq_ctrl |= cpu_to_le16(seqno);
40593 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40594 index e57ee48..541cf6c 100644
40595 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40596 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40597 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40598
40599 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40600
40601 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40602 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40603 + pax_open_kernel();
40604 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40605 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40606 + pax_close_kernel();
40607
40608 wl1251_info("using dedicated interrupt line");
40609 } else {
40610 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40611 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40612 + pax_open_kernel();
40613 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40614 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40615 + pax_close_kernel();
40616
40617 wl1251_info("using SDIO interrupt");
40618 }
40619 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40620 index 09694e3..24ccec7 100644
40621 --- a/drivers/net/wireless/ti/wl12xx/main.c
40622 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40623 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40624 sizeof(wl->conf.mem));
40625
40626 /* read data preparation is only needed by wl127x */
40627 - wl->ops->prepare_read = wl127x_prepare_read;
40628 + pax_open_kernel();
40629 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40630 + pax_close_kernel();
40631
40632 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40633 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40634 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40635 sizeof(wl->conf.mem));
40636
40637 /* read data preparation is only needed by wl127x */
40638 - wl->ops->prepare_read = wl127x_prepare_read;
40639 + pax_open_kernel();
40640 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40641 + pax_close_kernel();
40642
40643 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40644 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40645 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40646 index da3ef1b..4790b95 100644
40647 --- a/drivers/net/wireless/ti/wl18xx/main.c
40648 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40649 @@ -1664,8 +1664,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40650 }
40651
40652 if (!checksum_param) {
40653 - wl18xx_ops.set_rx_csum = NULL;
40654 - wl18xx_ops.init_vif = NULL;
40655 + pax_open_kernel();
40656 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
40657 + *(void **)&wl18xx_ops.init_vif = NULL;
40658 + pax_close_kernel();
40659 }
40660
40661 /* Enable 11a Band only if we have 5G antennas */
40662 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
40663 index 7ef0b4a..ff65c28 100644
40664 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
40665 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
40666 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
40667 {
40668 struct zd_usb *usb = urb->context;
40669 struct zd_usb_interrupt *intr = &usb->intr;
40670 - int len;
40671 + unsigned int len;
40672 u16 int_num;
40673
40674 ZD_ASSERT(in_interrupt());
40675 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
40676 index d93b2b6..ae50401 100644
40677 --- a/drivers/oprofile/buffer_sync.c
40678 +++ b/drivers/oprofile/buffer_sync.c
40679 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
40680 if (cookie == NO_COOKIE)
40681 offset = pc;
40682 if (cookie == INVALID_COOKIE) {
40683 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40684 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40685 offset = pc;
40686 }
40687 if (cookie != last_cookie) {
40688 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
40689 /* add userspace sample */
40690
40691 if (!mm) {
40692 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
40693 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
40694 return 0;
40695 }
40696
40697 cookie = lookup_dcookie(mm, s->eip, &offset);
40698
40699 if (cookie == INVALID_COOKIE) {
40700 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40701 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40702 return 0;
40703 }
40704
40705 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
40706 /* ignore backtraces if failed to add a sample */
40707 if (state == sb_bt_start) {
40708 state = sb_bt_ignore;
40709 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
40710 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
40711 }
40712 }
40713 release_mm(mm);
40714 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
40715 index c0cc4e7..44d4e54 100644
40716 --- a/drivers/oprofile/event_buffer.c
40717 +++ b/drivers/oprofile/event_buffer.c
40718 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
40719 }
40720
40721 if (buffer_pos == buffer_size) {
40722 - atomic_inc(&oprofile_stats.event_lost_overflow);
40723 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
40724 return;
40725 }
40726
40727 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
40728 index ed2c3ec..deda85a 100644
40729 --- a/drivers/oprofile/oprof.c
40730 +++ b/drivers/oprofile/oprof.c
40731 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
40732 if (oprofile_ops.switch_events())
40733 return;
40734
40735 - atomic_inc(&oprofile_stats.multiplex_counter);
40736 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
40737 start_switch_worker();
40738 }
40739
40740 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
40741 index 84a208d..d61b0a1 100644
40742 --- a/drivers/oprofile/oprofile_files.c
40743 +++ b/drivers/oprofile/oprofile_files.c
40744 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
40745
40746 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
40747
40748 -static ssize_t timeout_read(struct file *file, char __user *buf,
40749 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
40750 size_t count, loff_t *offset)
40751 {
40752 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
40753 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
40754 index 917d28e..d62d981 100644
40755 --- a/drivers/oprofile/oprofile_stats.c
40756 +++ b/drivers/oprofile/oprofile_stats.c
40757 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
40758 cpu_buf->sample_invalid_eip = 0;
40759 }
40760
40761 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
40762 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
40763 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
40764 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
40765 - atomic_set(&oprofile_stats.multiplex_counter, 0);
40766 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
40767 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
40768 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
40769 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
40770 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
40771 }
40772
40773
40774 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
40775 index 38b6fc0..b5cbfce 100644
40776 --- a/drivers/oprofile/oprofile_stats.h
40777 +++ b/drivers/oprofile/oprofile_stats.h
40778 @@ -13,11 +13,11 @@
40779 #include <linux/atomic.h>
40780
40781 struct oprofile_stat_struct {
40782 - atomic_t sample_lost_no_mm;
40783 - atomic_t sample_lost_no_mapping;
40784 - atomic_t bt_lost_no_mapping;
40785 - atomic_t event_lost_overflow;
40786 - atomic_t multiplex_counter;
40787 + atomic_unchecked_t sample_lost_no_mm;
40788 + atomic_unchecked_t sample_lost_no_mapping;
40789 + atomic_unchecked_t bt_lost_no_mapping;
40790 + atomic_unchecked_t event_lost_overflow;
40791 + atomic_unchecked_t multiplex_counter;
40792 };
40793
40794 extern struct oprofile_stat_struct oprofile_stats;
40795 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
40796 index 7c12d9c..558bf3bb 100644
40797 --- a/drivers/oprofile/oprofilefs.c
40798 +++ b/drivers/oprofile/oprofilefs.c
40799 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
40800
40801
40802 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
40803 - char const *name, atomic_t *val)
40804 + char const *name, atomic_unchecked_t *val)
40805 {
40806 return __oprofilefs_create_file(sb, root, name,
40807 &atomic_ro_fops, 0444, val);
40808 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
40809 index 93404f7..4a313d8 100644
40810 --- a/drivers/oprofile/timer_int.c
40811 +++ b/drivers/oprofile/timer_int.c
40812 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
40813 return NOTIFY_OK;
40814 }
40815
40816 -static struct notifier_block __refdata oprofile_cpu_notifier = {
40817 +static struct notifier_block oprofile_cpu_notifier = {
40818 .notifier_call = oprofile_cpu_notify,
40819 };
40820
40821 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
40822 index 3f56bc0..707d642 100644
40823 --- a/drivers/parport/procfs.c
40824 +++ b/drivers/parport/procfs.c
40825 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
40826
40827 *ppos += len;
40828
40829 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
40830 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
40831 }
40832
40833 #ifdef CONFIG_PARPORT_1284
40834 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
40835
40836 *ppos += len;
40837
40838 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
40839 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
40840 }
40841 #endif /* IEEE1284.3 support. */
40842
40843 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
40844 index c35e8ad..fc33beb 100644
40845 --- a/drivers/pci/hotplug/acpiphp_ibm.c
40846 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
40847 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
40848 goto init_cleanup;
40849 }
40850
40851 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40852 + pax_open_kernel();
40853 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40854 + pax_close_kernel();
40855 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
40856
40857 return retval;
40858 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
40859 index a6a71c4..c91097b 100644
40860 --- a/drivers/pci/hotplug/cpcihp_generic.c
40861 +++ b/drivers/pci/hotplug/cpcihp_generic.c
40862 @@ -73,7 +73,6 @@ static u16 port;
40863 static unsigned int enum_bit;
40864 static u8 enum_mask;
40865
40866 -static struct cpci_hp_controller_ops generic_hpc_ops;
40867 static struct cpci_hp_controller generic_hpc;
40868
40869 static int __init validate_parameters(void)
40870 @@ -139,6 +138,10 @@ static int query_enum(void)
40871 return ((value & enum_mask) == enum_mask);
40872 }
40873
40874 +static struct cpci_hp_controller_ops generic_hpc_ops = {
40875 + .query_enum = query_enum,
40876 +};
40877 +
40878 static int __init cpcihp_generic_init(void)
40879 {
40880 int status;
40881 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
40882 pci_dev_put(dev);
40883
40884 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
40885 - generic_hpc_ops.query_enum = query_enum;
40886 generic_hpc.ops = &generic_hpc_ops;
40887
40888 status = cpci_hp_register_controller(&generic_hpc);
40889 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
40890 index 449b4bb..257e2e8 100644
40891 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
40892 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
40893 @@ -59,7 +59,6 @@
40894 /* local variables */
40895 static bool debug;
40896 static bool poll;
40897 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
40898 static struct cpci_hp_controller zt5550_hpc;
40899
40900 /* Primary cPCI bus bridge device */
40901 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
40902 return 0;
40903 }
40904
40905 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
40906 + .query_enum = zt5550_hc_query_enum,
40907 +};
40908 +
40909 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
40910 {
40911 int status;
40912 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
40913 dbg("returned from zt5550_hc_config");
40914
40915 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
40916 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
40917 zt5550_hpc.ops = &zt5550_hpc_ops;
40918 if(!poll) {
40919 zt5550_hpc.irq = hc_dev->irq;
40920 zt5550_hpc.irq_flags = IRQF_SHARED;
40921 zt5550_hpc.dev_id = hc_dev;
40922
40923 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40924 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40925 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40926 + pax_open_kernel();
40927 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40928 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40929 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40930 + pax_open_kernel();
40931 } else {
40932 info("using ENUM# polling mode");
40933 }
40934 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
40935 index 76ba8a1..20ca857 100644
40936 --- a/drivers/pci/hotplug/cpqphp_nvram.c
40937 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
40938 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
40939
40940 void compaq_nvram_init (void __iomem *rom_start)
40941 {
40942 +
40943 +#ifndef CONFIG_PAX_KERNEXEC
40944 if (rom_start) {
40945 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
40946 }
40947 +#endif
40948 +
40949 dbg("int15 entry = %p\n", compaq_int15_entry_point);
40950
40951 /* initialize our int15 lock */
40952 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
40953 index 202f4a9..8ee47d0 100644
40954 --- a/drivers/pci/hotplug/pci_hotplug_core.c
40955 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
40956 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
40957 return -EINVAL;
40958 }
40959
40960 - slot->ops->owner = owner;
40961 - slot->ops->mod_name = mod_name;
40962 + pax_open_kernel();
40963 + *(struct module **)&slot->ops->owner = owner;
40964 + *(const char **)&slot->ops->mod_name = mod_name;
40965 + pax_close_kernel();
40966
40967 mutex_lock(&pci_hp_mutex);
40968 /*
40969 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
40970 index 7d72c5e..edce02c 100644
40971 --- a/drivers/pci/hotplug/pciehp_core.c
40972 +++ b/drivers/pci/hotplug/pciehp_core.c
40973 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
40974 struct slot *slot = ctrl->slot;
40975 struct hotplug_slot *hotplug = NULL;
40976 struct hotplug_slot_info *info = NULL;
40977 - struct hotplug_slot_ops *ops = NULL;
40978 + hotplug_slot_ops_no_const *ops = NULL;
40979 char name[SLOT_NAME_SIZE];
40980 int retval = -ENOMEM;
40981
40982 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
40983 index 9c6e9bb..2916736 100644
40984 --- a/drivers/pci/pci-sysfs.c
40985 +++ b/drivers/pci/pci-sysfs.c
40986 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
40987 {
40988 /* allocate attribute structure, piggyback attribute name */
40989 int name_len = write_combine ? 13 : 10;
40990 - struct bin_attribute *res_attr;
40991 + bin_attribute_no_const *res_attr;
40992 int retval;
40993
40994 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
40995 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
40996 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
40997 {
40998 int retval;
40999 - struct bin_attribute *attr;
41000 + bin_attribute_no_const *attr;
41001
41002 /* If the device has VPD, try to expose it in sysfs. */
41003 if (dev->vpd) {
41004 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41005 {
41006 int retval;
41007 int rom_size = 0;
41008 - struct bin_attribute *attr;
41009 + bin_attribute_no_const *attr;
41010
41011 if (!sysfs_initialized)
41012 return -EACCES;
41013 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41014 index 7346ee6..41520eb 100644
41015 --- a/drivers/pci/pci.h
41016 +++ b/drivers/pci/pci.h
41017 @@ -93,7 +93,7 @@ struct pci_vpd_ops {
41018 struct pci_vpd {
41019 unsigned int len;
41020 const struct pci_vpd_ops *ops;
41021 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41022 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41023 };
41024
41025 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41026 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41027 index d320df6..ca9a8f6 100644
41028 --- a/drivers/pci/pcie/aspm.c
41029 +++ b/drivers/pci/pcie/aspm.c
41030 @@ -27,9 +27,9 @@
41031 #define MODULE_PARAM_PREFIX "pcie_aspm."
41032
41033 /* Note: those are not register definitions */
41034 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41035 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41036 -#define ASPM_STATE_L1 (4) /* L1 state */
41037 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41038 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41039 +#define ASPM_STATE_L1 (4U) /* L1 state */
41040 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41041 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41042
41043 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41044 index 5427787..8df273b 100644
41045 --- a/drivers/pci/probe.c
41046 +++ b/drivers/pci/probe.c
41047 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41048 struct pci_bus_region region;
41049 bool bar_too_big = false, bar_disabled = false;
41050
41051 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41052 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41053
41054 /* No printks while decoding is disabled! */
41055 if (!dev->mmio_always_on) {
41056 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41057 index 0b00947..64f7c0a 100644
41058 --- a/drivers/pci/proc.c
41059 +++ b/drivers/pci/proc.c
41060 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41061 static int __init pci_proc_init(void)
41062 {
41063 struct pci_dev *dev = NULL;
41064 +
41065 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41066 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41067 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41068 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41069 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41070 +#endif
41071 +#else
41072 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41073 +#endif
41074 proc_create("devices", 0, proc_bus_pci_dir,
41075 &proc_bus_pci_dev_operations);
41076 proc_initialized = 1;
41077 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
41078 index 3e5b4497..dcdfb70 100644
41079 --- a/drivers/platform/x86/chromeos_laptop.c
41080 +++ b/drivers/platform/x86/chromeos_laptop.c
41081 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
41082 return 0;
41083 }
41084
41085 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
41086 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
41087 {
41088 .ident = "Samsung Series 5 550 - Touchpad",
41089 .matches = {
41090 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41091 index 6b22938..bc9700e 100644
41092 --- a/drivers/platform/x86/msi-laptop.c
41093 +++ b/drivers/platform/x86/msi-laptop.c
41094 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41095
41096 if (!quirks->ec_read_only) {
41097 /* allow userland write sysfs file */
41098 - dev_attr_bluetooth.store = store_bluetooth;
41099 - dev_attr_wlan.store = store_wlan;
41100 - dev_attr_threeg.store = store_threeg;
41101 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41102 - dev_attr_wlan.attr.mode |= S_IWUSR;
41103 - dev_attr_threeg.attr.mode |= S_IWUSR;
41104 + pax_open_kernel();
41105 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41106 + *(void **)&dev_attr_wlan.store = store_wlan;
41107 + *(void **)&dev_attr_threeg.store = store_threeg;
41108 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41109 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41110 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41111 + pax_close_kernel();
41112 }
41113
41114 /* disable hardware control by fn key */
41115 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41116 index 14d4dce..b129917 100644
41117 --- a/drivers/platform/x86/sony-laptop.c
41118 +++ b/drivers/platform/x86/sony-laptop.c
41119 @@ -2465,7 +2465,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
41120 }
41121
41122 /* High speed charging function */
41123 -static struct device_attribute *hsc_handle;
41124 +static device_attribute_no_const *hsc_handle;
41125
41126 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41127 struct device_attribute *attr,
41128 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41129 index edec135..59a24a3 100644
41130 --- a/drivers/platform/x86/thinkpad_acpi.c
41131 +++ b/drivers/platform/x86/thinkpad_acpi.c
41132 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
41133 return 0;
41134 }
41135
41136 -void static hotkey_mask_warn_incomplete_mask(void)
41137 +static void hotkey_mask_warn_incomplete_mask(void)
41138 {
41139 /* log only what the user can fix... */
41140 const u32 wantedmask = hotkey_driver_mask &
41141 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41142 }
41143 }
41144
41145 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41146 - struct tp_nvram_state *newn,
41147 - const u32 event_mask)
41148 -{
41149 -
41150 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41151 do { \
41152 if ((event_mask & (1 << __scancode)) && \
41153 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41154 tpacpi_hotkey_send_key(__scancode); \
41155 } while (0)
41156
41157 - void issue_volchange(const unsigned int oldvol,
41158 - const unsigned int newvol)
41159 - {
41160 - unsigned int i = oldvol;
41161 +static void issue_volchange(const unsigned int oldvol,
41162 + const unsigned int newvol,
41163 + const u32 event_mask)
41164 +{
41165 + unsigned int i = oldvol;
41166
41167 - while (i > newvol) {
41168 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41169 - i--;
41170 - }
41171 - while (i < newvol) {
41172 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41173 - i++;
41174 - }
41175 + while (i > newvol) {
41176 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41177 + i--;
41178 }
41179 + while (i < newvol) {
41180 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41181 + i++;
41182 + }
41183 +}
41184
41185 - void issue_brightnesschange(const unsigned int oldbrt,
41186 - const unsigned int newbrt)
41187 - {
41188 - unsigned int i = oldbrt;
41189 +static void issue_brightnesschange(const unsigned int oldbrt,
41190 + const unsigned int newbrt,
41191 + const u32 event_mask)
41192 +{
41193 + unsigned int i = oldbrt;
41194
41195 - while (i > newbrt) {
41196 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41197 - i--;
41198 - }
41199 - while (i < newbrt) {
41200 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41201 - i++;
41202 - }
41203 + while (i > newbrt) {
41204 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41205 + i--;
41206 + }
41207 + while (i < newbrt) {
41208 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41209 + i++;
41210 }
41211 +}
41212
41213 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41214 + struct tp_nvram_state *newn,
41215 + const u32 event_mask)
41216 +{
41217 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41218 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41219 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41220 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41221 oldn->volume_level != newn->volume_level) {
41222 /* recently muted, or repeated mute keypress, or
41223 * multiple presses ending in mute */
41224 - issue_volchange(oldn->volume_level, newn->volume_level);
41225 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41226 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41227 }
41228 } else {
41229 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41230 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41231 }
41232 if (oldn->volume_level != newn->volume_level) {
41233 - issue_volchange(oldn->volume_level, newn->volume_level);
41234 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41235 } else if (oldn->volume_toggle != newn->volume_toggle) {
41236 /* repeated vol up/down keypress at end of scale ? */
41237 if (newn->volume_level == 0)
41238 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41239 /* handle brightness */
41240 if (oldn->brightness_level != newn->brightness_level) {
41241 issue_brightnesschange(oldn->brightness_level,
41242 - newn->brightness_level);
41243 + newn->brightness_level,
41244 + event_mask);
41245 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41246 /* repeated key presses that didn't change state */
41247 if (newn->brightness_level == 0)
41248 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41249 && !tp_features.bright_unkfw)
41250 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41251 }
41252 +}
41253
41254 #undef TPACPI_COMPARE_KEY
41255 #undef TPACPI_MAY_SEND_KEY
41256 -}
41257
41258 /*
41259 * Polling driver
41260 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41261 index 769d265..a3a05ca 100644
41262 --- a/drivers/pnp/pnpbios/bioscalls.c
41263 +++ b/drivers/pnp/pnpbios/bioscalls.c
41264 @@ -58,7 +58,7 @@ do { \
41265 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41266 } while(0)
41267
41268 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41269 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41270 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41271
41272 /*
41273 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41274
41275 cpu = get_cpu();
41276 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41277 +
41278 + pax_open_kernel();
41279 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41280 + pax_close_kernel();
41281
41282 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41283 spin_lock_irqsave(&pnp_bios_lock, flags);
41284 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41285 :"memory");
41286 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41287
41288 + pax_open_kernel();
41289 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41290 + pax_close_kernel();
41291 +
41292 put_cpu();
41293
41294 /* If we get here and this is set then the PnP BIOS faulted on us. */
41295 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41296 return status;
41297 }
41298
41299 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41300 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41301 {
41302 int i;
41303
41304 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41305 pnp_bios_callpoint.offset = header->fields.pm16offset;
41306 pnp_bios_callpoint.segment = PNP_CS16;
41307
41308 + pax_open_kernel();
41309 +
41310 for_each_possible_cpu(i) {
41311 struct desc_struct *gdt = get_cpu_gdt_table(i);
41312 if (!gdt)
41313 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41314 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41315 (unsigned long)__va(header->fields.pm16dseg));
41316 }
41317 +
41318 + pax_close_kernel();
41319 }
41320 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41321 index 3e6db1c..1fbbdae 100644
41322 --- a/drivers/pnp/resource.c
41323 +++ b/drivers/pnp/resource.c
41324 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41325 return 1;
41326
41327 /* check if the resource is valid */
41328 - if (*irq < 0 || *irq > 15)
41329 + if (*irq > 15)
41330 return 0;
41331
41332 /* check if the resource is reserved */
41333 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41334 return 1;
41335
41336 /* check if the resource is valid */
41337 - if (*dma < 0 || *dma == 4 || *dma > 7)
41338 + if (*dma == 4 || *dma > 7)
41339 return 0;
41340
41341 /* check if the resource is reserved */
41342 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41343 index 7df7c5f..bd48c47 100644
41344 --- a/drivers/power/pda_power.c
41345 +++ b/drivers/power/pda_power.c
41346 @@ -37,7 +37,11 @@ static int polling;
41347
41348 #ifdef CONFIG_USB_OTG_UTILS
41349 static struct usb_phy *transceiver;
41350 -static struct notifier_block otg_nb;
41351 +static int otg_handle_notification(struct notifier_block *nb,
41352 + unsigned long event, void *unused);
41353 +static struct notifier_block otg_nb = {
41354 + .notifier_call = otg_handle_notification
41355 +};
41356 #endif
41357
41358 static struct regulator *ac_draw;
41359 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41360
41361 #ifdef CONFIG_USB_OTG_UTILS
41362 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41363 - otg_nb.notifier_call = otg_handle_notification;
41364 ret = usb_register_notifier(transceiver, &otg_nb);
41365 if (ret) {
41366 dev_err(dev, "failure to register otg notifier\n");
41367 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41368 index cc439fd..8fa30df 100644
41369 --- a/drivers/power/power_supply.h
41370 +++ b/drivers/power/power_supply.h
41371 @@ -16,12 +16,12 @@ struct power_supply;
41372
41373 #ifdef CONFIG_SYSFS
41374
41375 -extern void power_supply_init_attrs(struct device_type *dev_type);
41376 +extern void power_supply_init_attrs(void);
41377 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41378
41379 #else
41380
41381 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41382 +static inline void power_supply_init_attrs(void) {}
41383 #define power_supply_uevent NULL
41384
41385 #endif /* CONFIG_SYSFS */
41386 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41387 index 5deac43..608c5ff 100644
41388 --- a/drivers/power/power_supply_core.c
41389 +++ b/drivers/power/power_supply_core.c
41390 @@ -24,7 +24,10 @@
41391 struct class *power_supply_class;
41392 EXPORT_SYMBOL_GPL(power_supply_class);
41393
41394 -static struct device_type power_supply_dev_type;
41395 +extern const struct attribute_group *power_supply_attr_groups[];
41396 +static struct device_type power_supply_dev_type = {
41397 + .groups = power_supply_attr_groups,
41398 +};
41399
41400 static int __power_supply_changed_work(struct device *dev, void *data)
41401 {
41402 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41403 return PTR_ERR(power_supply_class);
41404
41405 power_supply_class->dev_uevent = power_supply_uevent;
41406 - power_supply_init_attrs(&power_supply_dev_type);
41407 + power_supply_init_attrs();
41408
41409 return 0;
41410 }
41411 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41412 index 29178f7..c65f324 100644
41413 --- a/drivers/power/power_supply_sysfs.c
41414 +++ b/drivers/power/power_supply_sysfs.c
41415 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
41416 .is_visible = power_supply_attr_is_visible,
41417 };
41418
41419 -static const struct attribute_group *power_supply_attr_groups[] = {
41420 +const struct attribute_group *power_supply_attr_groups[] = {
41421 &power_supply_attr_group,
41422 NULL,
41423 };
41424
41425 -void power_supply_init_attrs(struct device_type *dev_type)
41426 +void power_supply_init_attrs(void)
41427 {
41428 int i;
41429
41430 - dev_type->groups = power_supply_attr_groups;
41431 -
41432 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41433 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41434 }
41435 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41436 index 4d7c635..9860196 100644
41437 --- a/drivers/regulator/max8660.c
41438 +++ b/drivers/regulator/max8660.c
41439 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41440 max8660->shadow_regs[MAX8660_OVER1] = 5;
41441 } else {
41442 /* Otherwise devices can be toggled via software */
41443 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41444 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41445 + pax_open_kernel();
41446 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41447 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41448 + pax_close_kernel();
41449 }
41450
41451 /*
41452 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41453 index 9a8ea91..c483dd9 100644
41454 --- a/drivers/regulator/max8973-regulator.c
41455 +++ b/drivers/regulator/max8973-regulator.c
41456 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41457 if (!pdata->enable_ext_control) {
41458 max->desc.enable_reg = MAX8973_VOUT;
41459 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41460 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41461 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41462 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41463 + pax_open_kernel();
41464 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41465 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41466 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41467 + pax_close_kernel();
41468 }
41469
41470 max->enable_external_control = pdata->enable_ext_control;
41471 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41472 index 9891aec..beb3083 100644
41473 --- a/drivers/regulator/mc13892-regulator.c
41474 +++ b/drivers/regulator/mc13892-regulator.c
41475 @@ -583,10 +583,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41476 }
41477 mc13xxx_unlock(mc13892);
41478
41479 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41480 + pax_open_kernel();
41481 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41482 = mc13892_vcam_set_mode;
41483 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41484 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41485 = mc13892_vcam_get_mode;
41486 + pax_close_kernel();
41487
41488 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41489 ARRAY_SIZE(mc13892_regulators),
41490 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41491 index cc5bea9..689f7d9 100644
41492 --- a/drivers/rtc/rtc-cmos.c
41493 +++ b/drivers/rtc/rtc-cmos.c
41494 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41495 hpet_rtc_timer_init();
41496
41497 /* export at least the first block of NVRAM */
41498 - nvram.size = address_space - NVRAM_OFFSET;
41499 + pax_open_kernel();
41500 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41501 + pax_close_kernel();
41502 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41503 if (retval < 0) {
41504 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41505 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41506 index d049393..bb20be0 100644
41507 --- a/drivers/rtc/rtc-dev.c
41508 +++ b/drivers/rtc/rtc-dev.c
41509 @@ -16,6 +16,7 @@
41510 #include <linux/module.h>
41511 #include <linux/rtc.h>
41512 #include <linux/sched.h>
41513 +#include <linux/grsecurity.h>
41514 #include "rtc-core.h"
41515
41516 static dev_t rtc_devt;
41517 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
41518 if (copy_from_user(&tm, uarg, sizeof(tm)))
41519 return -EFAULT;
41520
41521 + gr_log_timechange();
41522 +
41523 return rtc_set_time(rtc, &tm);
41524
41525 case RTC_PIE_ON:
41526 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41527 index 970a236..3613169 100644
41528 --- a/drivers/rtc/rtc-ds1307.c
41529 +++ b/drivers/rtc/rtc-ds1307.c
41530 @@ -106,7 +106,7 @@ struct ds1307 {
41531 u8 offset; /* register's offset */
41532 u8 regs[11];
41533 u16 nvram_offset;
41534 - struct bin_attribute *nvram;
41535 + bin_attribute_no_const *nvram;
41536 enum ds_type type;
41537 unsigned long flags;
41538 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41539 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41540 index 130f29a..6179d03 100644
41541 --- a/drivers/rtc/rtc-m48t59.c
41542 +++ b/drivers/rtc/rtc-m48t59.c
41543 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41544 goto out;
41545 }
41546
41547 - m48t59_nvram_attr.size = pdata->offset;
41548 + pax_open_kernel();
41549 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41550 + pax_close_kernel();
41551
41552 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41553 if (ret) {
41554 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41555 index e693af6..2e525b6 100644
41556 --- a/drivers/scsi/bfa/bfa_fcpim.h
41557 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41558 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41559
41560 struct bfa_itn_s {
41561 bfa_isr_func_t isr;
41562 -};
41563 +} __no_const;
41564
41565 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41566 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41567 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41568 index 23a90e7..9cf04ee 100644
41569 --- a/drivers/scsi/bfa/bfa_ioc.h
41570 +++ b/drivers/scsi/bfa/bfa_ioc.h
41571 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41572 bfa_ioc_disable_cbfn_t disable_cbfn;
41573 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41574 bfa_ioc_reset_cbfn_t reset_cbfn;
41575 -};
41576 +} __no_const;
41577
41578 /*
41579 * IOC event notification mechanism.
41580 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41581 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41582 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41583 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41584 -};
41585 +} __no_const;
41586
41587 /*
41588 * Queue element to wait for room in request queue. FIFO order is
41589 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41590 index df0c3c7..b00e1d0 100644
41591 --- a/drivers/scsi/hosts.c
41592 +++ b/drivers/scsi/hosts.c
41593 @@ -42,7 +42,7 @@
41594 #include "scsi_logging.h"
41595
41596
41597 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41598 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41599
41600
41601 static void scsi_host_cls_release(struct device *dev)
41602 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41603 * subtract one because we increment first then return, but we need to
41604 * know what the next host number was before increment
41605 */
41606 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41607 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41608 shost->dma_channel = 0xff;
41609
41610 /* These three are default values which can be overridden */
41611 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41612 index 7f4f790..b75b92a 100644
41613 --- a/drivers/scsi/hpsa.c
41614 +++ b/drivers/scsi/hpsa.c
41615 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41616 unsigned long flags;
41617
41618 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41619 - return h->access.command_completed(h, q);
41620 + return h->access->command_completed(h, q);
41621
41622 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41623 a = rq->head[rq->current_entry];
41624 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
41625 while (!list_empty(&h->reqQ)) {
41626 c = list_entry(h->reqQ.next, struct CommandList, list);
41627 /* can't do anything if fifo is full */
41628 - if ((h->access.fifo_full(h))) {
41629 + if ((h->access->fifo_full(h))) {
41630 dev_warn(&h->pdev->dev, "fifo full\n");
41631 break;
41632 }
41633 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
41634
41635 /* Tell the controller execute command */
41636 spin_unlock_irqrestore(&h->lock, flags);
41637 - h->access.submit_command(h, c);
41638 + h->access->submit_command(h, c);
41639 spin_lock_irqsave(&h->lock, flags);
41640 }
41641 spin_unlock_irqrestore(&h->lock, flags);
41642 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
41643
41644 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41645 {
41646 - return h->access.command_completed(h, q);
41647 + return h->access->command_completed(h, q);
41648 }
41649
41650 static inline bool interrupt_pending(struct ctlr_info *h)
41651 {
41652 - return h->access.intr_pending(h);
41653 + return h->access->intr_pending(h);
41654 }
41655
41656 static inline long interrupt_not_for_us(struct ctlr_info *h)
41657 {
41658 - return (h->access.intr_pending(h) == 0) ||
41659 + return (h->access->intr_pending(h) == 0) ||
41660 (h->interrupts_enabled == 0);
41661 }
41662
41663 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
41664 if (prod_index < 0)
41665 return -ENODEV;
41666 h->product_name = products[prod_index].product_name;
41667 - h->access = *(products[prod_index].access);
41668 + h->access = products[prod_index].access;
41669
41670 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
41671 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
41672 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
41673
41674 assert_spin_locked(&lockup_detector_lock);
41675 remove_ctlr_from_lockup_detector_list(h);
41676 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41677 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41678 spin_lock_irqsave(&h->lock, flags);
41679 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
41680 spin_unlock_irqrestore(&h->lock, flags);
41681 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
41682 }
41683
41684 /* make sure the board interrupts are off */
41685 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41686 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41687
41688 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
41689 goto clean2;
41690 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
41691 * fake ones to scoop up any residual completions.
41692 */
41693 spin_lock_irqsave(&h->lock, flags);
41694 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41695 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41696 spin_unlock_irqrestore(&h->lock, flags);
41697 free_irqs(h);
41698 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
41699 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
41700 dev_info(&h->pdev->dev, "Board READY.\n");
41701 dev_info(&h->pdev->dev,
41702 "Waiting for stale completions to drain.\n");
41703 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41704 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41705 msleep(10000);
41706 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41707 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41708
41709 rc = controller_reset_failed(h->cfgtable);
41710 if (rc)
41711 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
41712 }
41713
41714 /* Turn the interrupts on so we can service requests */
41715 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41716 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41717
41718 hpsa_hba_inquiry(h);
41719 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
41720 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
41721 * To write all data in the battery backed cache to disks
41722 */
41723 hpsa_flush_cache(h);
41724 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41725 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41726 hpsa_free_irqs_and_disable_msix(h);
41727 }
41728
41729 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
41730 return;
41731 }
41732 /* Change the access methods to the performant access methods */
41733 - h->access = SA5_performant_access;
41734 + h->access = &SA5_performant_access;
41735 h->transMethod = CFGTBL_Trans_Performant;
41736 }
41737
41738 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
41739 index 9816479..c5d4e97 100644
41740 --- a/drivers/scsi/hpsa.h
41741 +++ b/drivers/scsi/hpsa.h
41742 @@ -79,7 +79,7 @@ struct ctlr_info {
41743 unsigned int msix_vector;
41744 unsigned int msi_vector;
41745 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
41746 - struct access_method access;
41747 + struct access_method *access;
41748
41749 /* queue and queue Info */
41750 struct list_head reqQ;
41751 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
41752 index c772d8d..35c362c 100644
41753 --- a/drivers/scsi/libfc/fc_exch.c
41754 +++ b/drivers/scsi/libfc/fc_exch.c
41755 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
41756 u16 pool_max_index;
41757
41758 struct {
41759 - atomic_t no_free_exch;
41760 - atomic_t no_free_exch_xid;
41761 - atomic_t xid_not_found;
41762 - atomic_t xid_busy;
41763 - atomic_t seq_not_found;
41764 - atomic_t non_bls_resp;
41765 + atomic_unchecked_t no_free_exch;
41766 + atomic_unchecked_t no_free_exch_xid;
41767 + atomic_unchecked_t xid_not_found;
41768 + atomic_unchecked_t xid_busy;
41769 + atomic_unchecked_t seq_not_found;
41770 + atomic_unchecked_t non_bls_resp;
41771 } stats;
41772 };
41773
41774 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
41775 /* allocate memory for exchange */
41776 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
41777 if (!ep) {
41778 - atomic_inc(&mp->stats.no_free_exch);
41779 + atomic_inc_unchecked(&mp->stats.no_free_exch);
41780 goto out;
41781 }
41782 memset(ep, 0, sizeof(*ep));
41783 @@ -786,7 +786,7 @@ out:
41784 return ep;
41785 err:
41786 spin_unlock_bh(&pool->lock);
41787 - atomic_inc(&mp->stats.no_free_exch_xid);
41788 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
41789 mempool_free(ep, mp->ep_pool);
41790 return NULL;
41791 }
41792 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41793 xid = ntohs(fh->fh_ox_id); /* we originated exch */
41794 ep = fc_exch_find(mp, xid);
41795 if (!ep) {
41796 - atomic_inc(&mp->stats.xid_not_found);
41797 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41798 reject = FC_RJT_OX_ID;
41799 goto out;
41800 }
41801 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41802 ep = fc_exch_find(mp, xid);
41803 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
41804 if (ep) {
41805 - atomic_inc(&mp->stats.xid_busy);
41806 + atomic_inc_unchecked(&mp->stats.xid_busy);
41807 reject = FC_RJT_RX_ID;
41808 goto rel;
41809 }
41810 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41811 }
41812 xid = ep->xid; /* get our XID */
41813 } else if (!ep) {
41814 - atomic_inc(&mp->stats.xid_not_found);
41815 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41816 reject = FC_RJT_RX_ID; /* XID not found */
41817 goto out;
41818 }
41819 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41820 } else {
41821 sp = &ep->seq;
41822 if (sp->id != fh->fh_seq_id) {
41823 - atomic_inc(&mp->stats.seq_not_found);
41824 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41825 if (f_ctl & FC_FC_END_SEQ) {
41826 /*
41827 * Update sequence_id based on incoming last
41828 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41829
41830 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
41831 if (!ep) {
41832 - atomic_inc(&mp->stats.xid_not_found);
41833 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41834 goto out;
41835 }
41836 if (ep->esb_stat & ESB_ST_COMPLETE) {
41837 - atomic_inc(&mp->stats.xid_not_found);
41838 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41839 goto rel;
41840 }
41841 if (ep->rxid == FC_XID_UNKNOWN)
41842 ep->rxid = ntohs(fh->fh_rx_id);
41843 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
41844 - atomic_inc(&mp->stats.xid_not_found);
41845 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41846 goto rel;
41847 }
41848 if (ep->did != ntoh24(fh->fh_s_id) &&
41849 ep->did != FC_FID_FLOGI) {
41850 - atomic_inc(&mp->stats.xid_not_found);
41851 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41852 goto rel;
41853 }
41854 sof = fr_sof(fp);
41855 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41856 sp->ssb_stat |= SSB_ST_RESP;
41857 sp->id = fh->fh_seq_id;
41858 } else if (sp->id != fh->fh_seq_id) {
41859 - atomic_inc(&mp->stats.seq_not_found);
41860 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41861 goto rel;
41862 }
41863
41864 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41865 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
41866
41867 if (!sp)
41868 - atomic_inc(&mp->stats.xid_not_found);
41869 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41870 else
41871 - atomic_inc(&mp->stats.non_bls_resp);
41872 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
41873
41874 fc_frame_free(fp);
41875 }
41876 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
41877
41878 list_for_each_entry(ema, &lport->ema_list, ema_list) {
41879 mp = ema->mp;
41880 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
41881 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
41882 st->fc_no_free_exch_xid +=
41883 - atomic_read(&mp->stats.no_free_exch_xid);
41884 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
41885 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
41886 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
41887 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
41888 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
41889 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
41890 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
41891 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
41892 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
41893 }
41894 }
41895 EXPORT_SYMBOL(fc_exch_update_stats);
41896 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
41897 index bdb81cd..d3c7c2c 100644
41898 --- a/drivers/scsi/libsas/sas_ata.c
41899 +++ b/drivers/scsi/libsas/sas_ata.c
41900 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
41901 .postreset = ata_std_postreset,
41902 .error_handler = ata_std_error_handler,
41903 .post_internal_cmd = sas_ata_post_internal,
41904 - .qc_defer = ata_std_qc_defer,
41905 + .qc_defer = ata_std_qc_defer,
41906 .qc_prep = ata_noop_qc_prep,
41907 .qc_issue = sas_ata_qc_issue,
41908 .qc_fill_rtf = sas_ata_qc_fill_rtf,
41909 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
41910 index 7706c99..3b4fc0c 100644
41911 --- a/drivers/scsi/lpfc/lpfc.h
41912 +++ b/drivers/scsi/lpfc/lpfc.h
41913 @@ -424,7 +424,7 @@ struct lpfc_vport {
41914 struct dentry *debug_nodelist;
41915 struct dentry *vport_debugfs_root;
41916 struct lpfc_debugfs_trc *disc_trc;
41917 - atomic_t disc_trc_cnt;
41918 + atomic_unchecked_t disc_trc_cnt;
41919 #endif
41920 uint8_t stat_data_enabled;
41921 uint8_t stat_data_blocked;
41922 @@ -853,8 +853,8 @@ struct lpfc_hba {
41923 struct timer_list fabric_block_timer;
41924 unsigned long bit_flags;
41925 #define FABRIC_COMANDS_BLOCKED 0
41926 - atomic_t num_rsrc_err;
41927 - atomic_t num_cmd_success;
41928 + atomic_unchecked_t num_rsrc_err;
41929 + atomic_unchecked_t num_cmd_success;
41930 unsigned long last_rsrc_error_time;
41931 unsigned long last_ramp_down_time;
41932 unsigned long last_ramp_up_time;
41933 @@ -890,7 +890,7 @@ struct lpfc_hba {
41934
41935 struct dentry *debug_slow_ring_trc;
41936 struct lpfc_debugfs_trc *slow_ring_trc;
41937 - atomic_t slow_ring_trc_cnt;
41938 + atomic_unchecked_t slow_ring_trc_cnt;
41939 /* iDiag debugfs sub-directory */
41940 struct dentry *idiag_root;
41941 struct dentry *idiag_pci_cfg;
41942 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
41943 index f63f5ff..de29189 100644
41944 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
41945 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
41946 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
41947
41948 #include <linux/debugfs.h>
41949
41950 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41951 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41952 static unsigned long lpfc_debugfs_start_time = 0L;
41953
41954 /* iDiag */
41955 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
41956 lpfc_debugfs_enable = 0;
41957
41958 len = 0;
41959 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
41960 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
41961 (lpfc_debugfs_max_disc_trc - 1);
41962 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
41963 dtp = vport->disc_trc + i;
41964 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
41965 lpfc_debugfs_enable = 0;
41966
41967 len = 0;
41968 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
41969 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
41970 (lpfc_debugfs_max_slow_ring_trc - 1);
41971 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
41972 dtp = phba->slow_ring_trc + i;
41973 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
41974 !vport || !vport->disc_trc)
41975 return;
41976
41977 - index = atomic_inc_return(&vport->disc_trc_cnt) &
41978 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
41979 (lpfc_debugfs_max_disc_trc - 1);
41980 dtp = vport->disc_trc + index;
41981 dtp->fmt = fmt;
41982 dtp->data1 = data1;
41983 dtp->data2 = data2;
41984 dtp->data3 = data3;
41985 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41986 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41987 dtp->jif = jiffies;
41988 #endif
41989 return;
41990 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
41991 !phba || !phba->slow_ring_trc)
41992 return;
41993
41994 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
41995 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
41996 (lpfc_debugfs_max_slow_ring_trc - 1);
41997 dtp = phba->slow_ring_trc + index;
41998 dtp->fmt = fmt;
41999 dtp->data1 = data1;
42000 dtp->data2 = data2;
42001 dtp->data3 = data3;
42002 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42003 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42004 dtp->jif = jiffies;
42005 #endif
42006 return;
42007 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42008 "slow_ring buffer\n");
42009 goto debug_failed;
42010 }
42011 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42012 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42013 memset(phba->slow_ring_trc, 0,
42014 (sizeof(struct lpfc_debugfs_trc) *
42015 lpfc_debugfs_max_slow_ring_trc));
42016 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42017 "buffer\n");
42018 goto debug_failed;
42019 }
42020 - atomic_set(&vport->disc_trc_cnt, 0);
42021 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42022
42023 snprintf(name, sizeof(name), "discovery_trace");
42024 vport->debug_disc_trc =
42025 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42026 index 314b4f6..7005d10 100644
42027 --- a/drivers/scsi/lpfc/lpfc_init.c
42028 +++ b/drivers/scsi/lpfc/lpfc_init.c
42029 @@ -10551,8 +10551,10 @@ lpfc_init(void)
42030 "misc_register returned with status %d", error);
42031
42032 if (lpfc_enable_npiv) {
42033 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42034 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42035 + pax_open_kernel();
42036 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42037 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42038 + pax_close_kernel();
42039 }
42040 lpfc_transport_template =
42041 fc_attach_transport(&lpfc_transport_functions);
42042 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42043 index 98af07c..7625fb5 100644
42044 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42045 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42046 @@ -325,7 +325,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42047 uint32_t evt_posted;
42048
42049 spin_lock_irqsave(&phba->hbalock, flags);
42050 - atomic_inc(&phba->num_rsrc_err);
42051 + atomic_inc_unchecked(&phba->num_rsrc_err);
42052 phba->last_rsrc_error_time = jiffies;
42053
42054 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42055 @@ -366,7 +366,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42056 unsigned long flags;
42057 struct lpfc_hba *phba = vport->phba;
42058 uint32_t evt_posted;
42059 - atomic_inc(&phba->num_cmd_success);
42060 + atomic_inc_unchecked(&phba->num_cmd_success);
42061
42062 if (vport->cfg_lun_queue_depth <= queue_depth)
42063 return;
42064 @@ -410,8 +410,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42065 unsigned long num_rsrc_err, num_cmd_success;
42066 int i;
42067
42068 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42069 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42070 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42071 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42072
42073 /*
42074 * The error and success command counters are global per
42075 @@ -439,8 +439,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42076 }
42077 }
42078 lpfc_destroy_vport_work_array(phba, vports);
42079 - atomic_set(&phba->num_rsrc_err, 0);
42080 - atomic_set(&phba->num_cmd_success, 0);
42081 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42082 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42083 }
42084
42085 /**
42086 @@ -474,8 +474,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42087 }
42088 }
42089 lpfc_destroy_vport_work_array(phba, vports);
42090 - atomic_set(&phba->num_rsrc_err, 0);
42091 - atomic_set(&phba->num_cmd_success, 0);
42092 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42093 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42094 }
42095
42096 /**
42097 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42098 index b46f5e9..c4c4ccb 100644
42099 --- a/drivers/scsi/pmcraid.c
42100 +++ b/drivers/scsi/pmcraid.c
42101 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42102 res->scsi_dev = scsi_dev;
42103 scsi_dev->hostdata = res;
42104 res->change_detected = 0;
42105 - atomic_set(&res->read_failures, 0);
42106 - atomic_set(&res->write_failures, 0);
42107 + atomic_set_unchecked(&res->read_failures, 0);
42108 + atomic_set_unchecked(&res->write_failures, 0);
42109 rc = 0;
42110 }
42111 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42112 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42113
42114 /* If this was a SCSI read/write command keep count of errors */
42115 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42116 - atomic_inc(&res->read_failures);
42117 + atomic_inc_unchecked(&res->read_failures);
42118 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42119 - atomic_inc(&res->write_failures);
42120 + atomic_inc_unchecked(&res->write_failures);
42121
42122 if (!RES_IS_GSCSI(res->cfg_entry) &&
42123 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42124 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42125 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42126 * hrrq_id assigned here in queuecommand
42127 */
42128 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42129 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42130 pinstance->num_hrrq;
42131 cmd->cmd_done = pmcraid_io_done;
42132
42133 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42134 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42135 * hrrq_id assigned here in queuecommand
42136 */
42137 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42138 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42139 pinstance->num_hrrq;
42140
42141 if (request_size) {
42142 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42143
42144 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42145 /* add resources only after host is added into system */
42146 - if (!atomic_read(&pinstance->expose_resources))
42147 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42148 return;
42149
42150 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42151 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42152 init_waitqueue_head(&pinstance->reset_wait_q);
42153
42154 atomic_set(&pinstance->outstanding_cmds, 0);
42155 - atomic_set(&pinstance->last_message_id, 0);
42156 - atomic_set(&pinstance->expose_resources, 0);
42157 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42158 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42159
42160 INIT_LIST_HEAD(&pinstance->free_res_q);
42161 INIT_LIST_HEAD(&pinstance->used_res_q);
42162 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42163 /* Schedule worker thread to handle CCN and take care of adding and
42164 * removing devices to OS
42165 */
42166 - atomic_set(&pinstance->expose_resources, 1);
42167 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42168 schedule_work(&pinstance->worker_q);
42169 return rc;
42170
42171 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42172 index e1d150f..6c6df44 100644
42173 --- a/drivers/scsi/pmcraid.h
42174 +++ b/drivers/scsi/pmcraid.h
42175 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42176 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42177
42178 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42179 - atomic_t last_message_id;
42180 + atomic_unchecked_t last_message_id;
42181
42182 /* configuration table */
42183 struct pmcraid_config_table *cfg_table;
42184 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42185 atomic_t outstanding_cmds;
42186
42187 /* should add/delete resources to mid-layer now ?*/
42188 - atomic_t expose_resources;
42189 + atomic_unchecked_t expose_resources;
42190
42191
42192
42193 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42194 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42195 };
42196 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42197 - atomic_t read_failures; /* count of failed READ commands */
42198 - atomic_t write_failures; /* count of failed WRITE commands */
42199 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42200 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42201
42202 /* To indicate add/delete/modify during CCN */
42203 u8 change_detected;
42204 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42205 index b3db9dc..c3b1756 100644
42206 --- a/drivers/scsi/qla2xxx/qla_attr.c
42207 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42208 @@ -1971,7 +1971,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42209 return 0;
42210 }
42211
42212 -struct fc_function_template qla2xxx_transport_functions = {
42213 +fc_function_template_no_const qla2xxx_transport_functions = {
42214
42215 .show_host_node_name = 1,
42216 .show_host_port_name = 1,
42217 @@ -2018,7 +2018,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42218 .bsg_timeout = qla24xx_bsg_timeout,
42219 };
42220
42221 -struct fc_function_template qla2xxx_transport_vport_functions = {
42222 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42223
42224 .show_host_node_name = 1,
42225 .show_host_port_name = 1,
42226 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42227 index b310fa9..b9b3944 100644
42228 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42229 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42230 @@ -523,8 +523,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42231 struct device_attribute;
42232 extern struct device_attribute *qla2x00_host_attrs[];
42233 struct fc_function_template;
42234 -extern struct fc_function_template qla2xxx_transport_functions;
42235 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42236 +extern fc_function_template_no_const qla2xxx_transport_functions;
42237 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42238 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42239 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42240 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42241 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42242 index 2c6dd3d..e5ecd82 100644
42243 --- a/drivers/scsi/qla2xxx/qla_os.c
42244 +++ b/drivers/scsi/qla2xxx/qla_os.c
42245 @@ -1554,8 +1554,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42246 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42247 /* Ok, a 64bit DMA mask is applicable. */
42248 ha->flags.enable_64bit_addressing = 1;
42249 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42250 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42251 + pax_open_kernel();
42252 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42253 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42254 + pax_close_kernel();
42255 return;
42256 }
42257 }
42258 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42259 index 129f5dd..ade53e8 100644
42260 --- a/drivers/scsi/qla4xxx/ql4_def.h
42261 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42262 @@ -275,7 +275,7 @@ struct ddb_entry {
42263 * (4000 only) */
42264 atomic_t relogin_timer; /* Max Time to wait for
42265 * relogin to complete */
42266 - atomic_t relogin_retry_count; /* Num of times relogin has been
42267 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42268 * retried */
42269 uint32_t default_time2wait; /* Default Min time between
42270 * relogins (+aens) */
42271 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42272 index 6142729..b6a85c9 100644
42273 --- a/drivers/scsi/qla4xxx/ql4_os.c
42274 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42275 @@ -2622,12 +2622,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42276 */
42277 if (!iscsi_is_session_online(cls_sess)) {
42278 /* Reset retry relogin timer */
42279 - atomic_inc(&ddb_entry->relogin_retry_count);
42280 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42281 DEBUG2(ql4_printk(KERN_INFO, ha,
42282 "%s: index[%d] relogin timed out-retrying"
42283 " relogin (%d), retry (%d)\n", __func__,
42284 ddb_entry->fw_ddb_index,
42285 - atomic_read(&ddb_entry->relogin_retry_count),
42286 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42287 ddb_entry->default_time2wait + 4));
42288 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42289 atomic_set(&ddb_entry->retry_relogin_timer,
42290 @@ -4742,7 +4742,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42291
42292 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42293 atomic_set(&ddb_entry->relogin_timer, 0);
42294 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42295 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42296 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42297 ddb_entry->default_relogin_timeout =
42298 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42299 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42300 index 2c0d0ec..4e8681a 100644
42301 --- a/drivers/scsi/scsi.c
42302 +++ b/drivers/scsi/scsi.c
42303 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42304 unsigned long timeout;
42305 int rtn = 0;
42306
42307 - atomic_inc(&cmd->device->iorequest_cnt);
42308 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42309
42310 /* check if the device is still usable */
42311 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42312 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42313 index c31187d..0ead8c3 100644
42314 --- a/drivers/scsi/scsi_lib.c
42315 +++ b/drivers/scsi/scsi_lib.c
42316 @@ -1459,7 +1459,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42317 shost = sdev->host;
42318 scsi_init_cmd_errh(cmd);
42319 cmd->result = DID_NO_CONNECT << 16;
42320 - atomic_inc(&cmd->device->iorequest_cnt);
42321 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42322
42323 /*
42324 * SCSI request completion path will do scsi_device_unbusy(),
42325 @@ -1485,9 +1485,9 @@ static void scsi_softirq_done(struct request *rq)
42326
42327 INIT_LIST_HEAD(&cmd->eh_entry);
42328
42329 - atomic_inc(&cmd->device->iodone_cnt);
42330 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42331 if (cmd->result)
42332 - atomic_inc(&cmd->device->ioerr_cnt);
42333 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42334
42335 disposition = scsi_decide_disposition(cmd);
42336 if (disposition != SUCCESS &&
42337 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42338 index 931a7d9..0c2a754 100644
42339 --- a/drivers/scsi/scsi_sysfs.c
42340 +++ b/drivers/scsi/scsi_sysfs.c
42341 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42342 char *buf) \
42343 { \
42344 struct scsi_device *sdev = to_scsi_device(dev); \
42345 - unsigned long long count = atomic_read(&sdev->field); \
42346 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42347 return snprintf(buf, 20, "0x%llx\n", count); \
42348 } \
42349 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42350 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42351 index 84a1fdf..693b0d6 100644
42352 --- a/drivers/scsi/scsi_tgt_lib.c
42353 +++ b/drivers/scsi/scsi_tgt_lib.c
42354 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42355 int err;
42356
42357 dprintk("%lx %u\n", uaddr, len);
42358 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42359 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42360 if (err) {
42361 /*
42362 * TODO: need to fixup sg_tablesize, max_segment_size,
42363 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42364 index e894ca7..de9d7660 100644
42365 --- a/drivers/scsi/scsi_transport_fc.c
42366 +++ b/drivers/scsi/scsi_transport_fc.c
42367 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42368 * Netlink Infrastructure
42369 */
42370
42371 -static atomic_t fc_event_seq;
42372 +static atomic_unchecked_t fc_event_seq;
42373
42374 /**
42375 * fc_get_event_number - Obtain the next sequential FC event number
42376 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42377 u32
42378 fc_get_event_number(void)
42379 {
42380 - return atomic_add_return(1, &fc_event_seq);
42381 + return atomic_add_return_unchecked(1, &fc_event_seq);
42382 }
42383 EXPORT_SYMBOL(fc_get_event_number);
42384
42385 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42386 {
42387 int error;
42388
42389 - atomic_set(&fc_event_seq, 0);
42390 + atomic_set_unchecked(&fc_event_seq, 0);
42391
42392 error = transport_class_register(&fc_host_class);
42393 if (error)
42394 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42395 char *cp;
42396
42397 *val = simple_strtoul(buf, &cp, 0);
42398 - if ((*cp && (*cp != '\n')) || (*val < 0))
42399 + if (*cp && (*cp != '\n'))
42400 return -EINVAL;
42401 /*
42402 * Check for overflow; dev_loss_tmo is u32
42403 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42404 index 0a74b97..fa8d648 100644
42405 --- a/drivers/scsi/scsi_transport_iscsi.c
42406 +++ b/drivers/scsi/scsi_transport_iscsi.c
42407 @@ -79,7 +79,7 @@ struct iscsi_internal {
42408 struct transport_container session_cont;
42409 };
42410
42411 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42412 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42413 static struct workqueue_struct *iscsi_eh_timer_workq;
42414
42415 static DEFINE_IDA(iscsi_sess_ida);
42416 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42417 int err;
42418
42419 ihost = shost->shost_data;
42420 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42421 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42422
42423 if (target_id == ISCSI_MAX_TARGET) {
42424 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42425 @@ -2955,7 +2955,7 @@ static __init int iscsi_transport_init(void)
42426 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42427 ISCSI_TRANSPORT_VERSION);
42428
42429 - atomic_set(&iscsi_session_nr, 0);
42430 + atomic_set_unchecked(&iscsi_session_nr, 0);
42431
42432 err = class_register(&iscsi_transport_class);
42433 if (err)
42434 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42435 index f379c7f..e8fc69c 100644
42436 --- a/drivers/scsi/scsi_transport_srp.c
42437 +++ b/drivers/scsi/scsi_transport_srp.c
42438 @@ -33,7 +33,7 @@
42439 #include "scsi_transport_srp_internal.h"
42440
42441 struct srp_host_attrs {
42442 - atomic_t next_port_id;
42443 + atomic_unchecked_t next_port_id;
42444 };
42445 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42446
42447 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42448 struct Scsi_Host *shost = dev_to_shost(dev);
42449 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42450
42451 - atomic_set(&srp_host->next_port_id, 0);
42452 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42453 return 0;
42454 }
42455
42456 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42457 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42458 rport->roles = ids->roles;
42459
42460 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42461 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42462 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42463
42464 transport_setup_device(&rport->dev);
42465 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42466 index 82910cc..7c350ad 100644
42467 --- a/drivers/scsi/sd.c
42468 +++ b/drivers/scsi/sd.c
42469 @@ -2929,7 +2929,7 @@ static int sd_probe(struct device *dev)
42470 sdkp->disk = gd;
42471 sdkp->index = index;
42472 atomic_set(&sdkp->openers, 0);
42473 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42474 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42475
42476 if (!sdp->request_queue->rq_timeout) {
42477 if (sdp->type != TYPE_MOD)
42478 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42479 index 9f0c465..47194ee 100644
42480 --- a/drivers/scsi/sg.c
42481 +++ b/drivers/scsi/sg.c
42482 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42483 sdp->disk->disk_name,
42484 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42485 NULL,
42486 - (char *)arg);
42487 + (char __user *)arg);
42488 case BLKTRACESTART:
42489 return blk_trace_startstop(sdp->device->request_queue, 1);
42490 case BLKTRACESTOP:
42491 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42492 index 004b10f..7c98d51 100644
42493 --- a/drivers/spi/spi.c
42494 +++ b/drivers/spi/spi.c
42495 @@ -1620,7 +1620,7 @@ int spi_bus_unlock(struct spi_master *master)
42496 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42497
42498 /* portable code must never pass more than 32 bytes */
42499 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42500 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42501
42502 static u8 *buf;
42503
42504 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42505 index 93af756..a4bc5bf 100644
42506 --- a/drivers/staging/iio/iio_hwmon.c
42507 +++ b/drivers/staging/iio/iio_hwmon.c
42508 @@ -67,7 +67,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
42509 {
42510 struct device *dev = &pdev->dev;
42511 struct iio_hwmon_state *st;
42512 - struct sensor_device_attribute *a;
42513 + sensor_device_attribute_no_const *a;
42514 int ret, i;
42515 int in_i = 1, temp_i = 1, curr_i = 1;
42516 enum iio_chan_type type;
42517 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42518 index 34afc16..ffe44dd 100644
42519 --- a/drivers/staging/octeon/ethernet-rx.c
42520 +++ b/drivers/staging/octeon/ethernet-rx.c
42521 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42522 /* Increment RX stats for virtual ports */
42523 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42524 #ifdef CONFIG_64BIT
42525 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42526 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42527 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42528 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42529 #else
42530 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42531 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42532 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42533 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42534 #endif
42535 }
42536 netif_receive_skb(skb);
42537 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42538 dev->name);
42539 */
42540 #ifdef CONFIG_64BIT
42541 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42542 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42543 #else
42544 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42545 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42546 #endif
42547 dev_kfree_skb_irq(skb);
42548 }
42549 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42550 index c3a90e7..023619a 100644
42551 --- a/drivers/staging/octeon/ethernet.c
42552 +++ b/drivers/staging/octeon/ethernet.c
42553 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42554 * since the RX tasklet also increments it.
42555 */
42556 #ifdef CONFIG_64BIT
42557 - atomic64_add(rx_status.dropped_packets,
42558 - (atomic64_t *)&priv->stats.rx_dropped);
42559 + atomic64_add_unchecked(rx_status.dropped_packets,
42560 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42561 #else
42562 - atomic_add(rx_status.dropped_packets,
42563 - (atomic_t *)&priv->stats.rx_dropped);
42564 + atomic_add_unchecked(rx_status.dropped_packets,
42565 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42566 #endif
42567 }
42568
42569 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
42570 index dc23395..cf7e9b1 100644
42571 --- a/drivers/staging/rtl8712/rtl871x_io.h
42572 +++ b/drivers/staging/rtl8712/rtl871x_io.h
42573 @@ -108,7 +108,7 @@ struct _io_ops {
42574 u8 *pmem);
42575 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
42576 u8 *pmem);
42577 -};
42578 +} __no_const;
42579
42580 struct io_req {
42581 struct list_head list;
42582 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
42583 index 1f5088b..0e59820 100644
42584 --- a/drivers/staging/sbe-2t3e3/netdev.c
42585 +++ b/drivers/staging/sbe-2t3e3/netdev.c
42586 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42587 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
42588
42589 if (rlen)
42590 - if (copy_to_user(data, &resp, rlen))
42591 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
42592 return -EFAULT;
42593
42594 return 0;
42595 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
42596 index 5dddc4d..34fcb2f 100644
42597 --- a/drivers/staging/usbip/vhci.h
42598 +++ b/drivers/staging/usbip/vhci.h
42599 @@ -83,7 +83,7 @@ struct vhci_hcd {
42600 unsigned resuming:1;
42601 unsigned long re_timeout;
42602
42603 - atomic_t seqnum;
42604 + atomic_unchecked_t seqnum;
42605
42606 /*
42607 * NOTE:
42608 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
42609 index f1ca084..7b5c0c3 100644
42610 --- a/drivers/staging/usbip/vhci_hcd.c
42611 +++ b/drivers/staging/usbip/vhci_hcd.c
42612 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
42613
42614 spin_lock(&vdev->priv_lock);
42615
42616 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
42617 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42618 if (priv->seqnum == 0xffff)
42619 dev_info(&urb->dev->dev, "seqnum max\n");
42620
42621 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
42622 return -ENOMEM;
42623 }
42624
42625 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
42626 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42627 if (unlink->seqnum == 0xffff)
42628 pr_info("seqnum max\n");
42629
42630 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
42631 vdev->rhport = rhport;
42632 }
42633
42634 - atomic_set(&vhci->seqnum, 0);
42635 + atomic_set_unchecked(&vhci->seqnum, 0);
42636 spin_lock_init(&vhci->lock);
42637
42638 hcd->power_budget = 0; /* no limit */
42639 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
42640 index faf8e60..c46f8ab 100644
42641 --- a/drivers/staging/usbip/vhci_rx.c
42642 +++ b/drivers/staging/usbip/vhci_rx.c
42643 @@ -76,7 +76,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
42644 if (!urb) {
42645 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
42646 pr_info("max seqnum %d\n",
42647 - atomic_read(&the_controller->seqnum));
42648 + atomic_read_unchecked(&the_controller->seqnum));
42649 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
42650 return;
42651 }
42652 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
42653 index 5f13890..36a044b 100644
42654 --- a/drivers/staging/vt6655/hostap.c
42655 +++ b/drivers/staging/vt6655/hostap.c
42656 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
42657 *
42658 */
42659
42660 +static net_device_ops_no_const apdev_netdev_ops;
42661 +
42662 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42663 {
42664 PSDevice apdev_priv;
42665 struct net_device *dev = pDevice->dev;
42666 int ret;
42667 - const struct net_device_ops apdev_netdev_ops = {
42668 - .ndo_start_xmit = pDevice->tx_80211,
42669 - };
42670
42671 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42672
42673 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42674 *apdev_priv = *pDevice;
42675 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42676
42677 + /* only half broken now */
42678 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42679 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42680
42681 pDevice->apdev->type = ARPHRD_IEEE80211;
42682 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
42683 index bc5e9da..dacd556 100644
42684 --- a/drivers/staging/vt6656/hostap.c
42685 +++ b/drivers/staging/vt6656/hostap.c
42686 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
42687 *
42688 */
42689
42690 +static net_device_ops_no_const apdev_netdev_ops;
42691 +
42692 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
42693 {
42694 struct vnt_private *apdev_priv;
42695 struct net_device *dev = pDevice->dev;
42696 int ret;
42697 - const struct net_device_ops apdev_netdev_ops = {
42698 - .ndo_start_xmit = pDevice->tx_80211,
42699 - };
42700
42701 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42702
42703 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
42704 *apdev_priv = *pDevice;
42705 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42706
42707 + /* only half broken now */
42708 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42709 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42710
42711 pDevice->apdev->type = ARPHRD_IEEE80211;
42712 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
42713 index a2b7e03..9ff4bbd 100644
42714 --- a/drivers/staging/zcache/tmem.c
42715 +++ b/drivers/staging/zcache/tmem.c
42716 @@ -50,7 +50,7 @@
42717 * A tmem host implementation must use this function to register callbacks
42718 * for memory allocation.
42719 */
42720 -static struct tmem_hostops tmem_hostops;
42721 +static tmem_hostops_no_const tmem_hostops;
42722
42723 static void tmem_objnode_tree_init(void);
42724
42725 @@ -64,7 +64,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
42726 * A tmem host implementation must use this function to register
42727 * callbacks for a page-accessible memory (PAM) implementation.
42728 */
42729 -static struct tmem_pamops tmem_pamops;
42730 +static tmem_pamops_no_const tmem_pamops;
42731
42732 void tmem_register_pamops(struct tmem_pamops *m)
42733 {
42734 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
42735 index adbe5a8..d387359 100644
42736 --- a/drivers/staging/zcache/tmem.h
42737 +++ b/drivers/staging/zcache/tmem.h
42738 @@ -226,6 +226,7 @@ struct tmem_pamops {
42739 int (*replace_in_obj)(void *, struct tmem_obj *);
42740 #endif
42741 };
42742 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
42743 extern void tmem_register_pamops(struct tmem_pamops *m);
42744
42745 /* memory allocation methods provided by the host implementation */
42746 @@ -235,6 +236,7 @@ struct tmem_hostops {
42747 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
42748 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
42749 };
42750 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
42751 extern void tmem_register_hostops(struct tmem_hostops *m);
42752
42753 /* core tmem accessor functions */
42754 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
42755 index 2e4d655..fd72e68 100644
42756 --- a/drivers/target/target_core_device.c
42757 +++ b/drivers/target/target_core_device.c
42758 @@ -1414,7 +1414,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
42759 spin_lock_init(&dev->se_port_lock);
42760 spin_lock_init(&dev->se_tmr_lock);
42761 spin_lock_init(&dev->qf_cmd_lock);
42762 - atomic_set(&dev->dev_ordered_id, 0);
42763 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
42764 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
42765 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
42766 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
42767 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
42768 index 0d46276..f327cab5 100644
42769 --- a/drivers/target/target_core_transport.c
42770 +++ b/drivers/target/target_core_transport.c
42771 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
42772 * Used to determine when ORDERED commands should go from
42773 * Dormant to Active status.
42774 */
42775 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
42776 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
42777 smp_mb__after_atomic_inc();
42778 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
42779 cmd->se_ordered_id, cmd->sam_task_attr,
42780 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
42781 index 345bd0e..61d5375 100644
42782 --- a/drivers/tty/cyclades.c
42783 +++ b/drivers/tty/cyclades.c
42784 @@ -1576,10 +1576,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
42785 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
42786 info->port.count);
42787 #endif
42788 - info->port.count++;
42789 + atomic_inc(&info->port.count);
42790 #ifdef CY_DEBUG_COUNT
42791 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
42792 - current->pid, info->port.count);
42793 + current->pid, atomic_read(&info->port.count));
42794 #endif
42795
42796 /*
42797 @@ -3978,7 +3978,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
42798 for (j = 0; j < cy_card[i].nports; j++) {
42799 info = &cy_card[i].ports[j];
42800
42801 - if (info->port.count) {
42802 + if (atomic_read(&info->port.count)) {
42803 /* XXX is the ldisc num worth this? */
42804 struct tty_struct *tty;
42805 struct tty_ldisc *ld;
42806 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
42807 index eb255e8..f637a57 100644
42808 --- a/drivers/tty/hvc/hvc_console.c
42809 +++ b/drivers/tty/hvc/hvc_console.c
42810 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
42811
42812 spin_lock_irqsave(&hp->port.lock, flags);
42813 /* Check and then increment for fast path open. */
42814 - if (hp->port.count++ > 0) {
42815 + if (atomic_inc_return(&hp->port.count) > 1) {
42816 spin_unlock_irqrestore(&hp->port.lock, flags);
42817 hvc_kick();
42818 return 0;
42819 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42820
42821 spin_lock_irqsave(&hp->port.lock, flags);
42822
42823 - if (--hp->port.count == 0) {
42824 + if (atomic_dec_return(&hp->port.count) == 0) {
42825 spin_unlock_irqrestore(&hp->port.lock, flags);
42826 /* We are done with the tty pointer now. */
42827 tty_port_tty_set(&hp->port, NULL);
42828 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42829 */
42830 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
42831 } else {
42832 - if (hp->port.count < 0)
42833 + if (atomic_read(&hp->port.count) < 0)
42834 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
42835 - hp->vtermno, hp->port.count);
42836 + hp->vtermno, atomic_read(&hp->port.count));
42837 spin_unlock_irqrestore(&hp->port.lock, flags);
42838 }
42839 }
42840 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
42841 * open->hangup case this can be called after the final close so prevent
42842 * that from happening for now.
42843 */
42844 - if (hp->port.count <= 0) {
42845 + if (atomic_read(&hp->port.count) <= 0) {
42846 spin_unlock_irqrestore(&hp->port.lock, flags);
42847 return;
42848 }
42849
42850 - hp->port.count = 0;
42851 + atomic_set(&hp->port.count, 0);
42852 spin_unlock_irqrestore(&hp->port.lock, flags);
42853 tty_port_tty_set(&hp->port, NULL);
42854
42855 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
42856 return -EPIPE;
42857
42858 /* FIXME what's this (unprotected) check for? */
42859 - if (hp->port.count <= 0)
42860 + if (atomic_read(&hp->port.count) <= 0)
42861 return -EIO;
42862
42863 spin_lock_irqsave(&hp->lock, flags);
42864 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
42865 index 81e939e..95ead10 100644
42866 --- a/drivers/tty/hvc/hvcs.c
42867 +++ b/drivers/tty/hvc/hvcs.c
42868 @@ -83,6 +83,7 @@
42869 #include <asm/hvcserver.h>
42870 #include <asm/uaccess.h>
42871 #include <asm/vio.h>
42872 +#include <asm/local.h>
42873
42874 /*
42875 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
42876 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
42877
42878 spin_lock_irqsave(&hvcsd->lock, flags);
42879
42880 - if (hvcsd->port.count > 0) {
42881 + if (atomic_read(&hvcsd->port.count) > 0) {
42882 spin_unlock_irqrestore(&hvcsd->lock, flags);
42883 printk(KERN_INFO "HVCS: vterm state unchanged. "
42884 "The hvcs device node is still in use.\n");
42885 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
42886 }
42887 }
42888
42889 - hvcsd->port.count = 0;
42890 + atomic_set(&hvcsd->port.count, 0);
42891 hvcsd->port.tty = tty;
42892 tty->driver_data = hvcsd;
42893
42894 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
42895 unsigned long flags;
42896
42897 spin_lock_irqsave(&hvcsd->lock, flags);
42898 - hvcsd->port.count++;
42899 + atomic_inc(&hvcsd->port.count);
42900 hvcsd->todo_mask |= HVCS_SCHED_READ;
42901 spin_unlock_irqrestore(&hvcsd->lock, flags);
42902
42903 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42904 hvcsd = tty->driver_data;
42905
42906 spin_lock_irqsave(&hvcsd->lock, flags);
42907 - if (--hvcsd->port.count == 0) {
42908 + if (atomic_dec_and_test(&hvcsd->port.count)) {
42909
42910 vio_disable_interrupts(hvcsd->vdev);
42911
42912 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42913
42914 free_irq(irq, hvcsd);
42915 return;
42916 - } else if (hvcsd->port.count < 0) {
42917 + } else if (atomic_read(&hvcsd->port.count) < 0) {
42918 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
42919 " is missmanaged.\n",
42920 - hvcsd->vdev->unit_address, hvcsd->port.count);
42921 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
42922 }
42923
42924 spin_unlock_irqrestore(&hvcsd->lock, flags);
42925 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42926
42927 spin_lock_irqsave(&hvcsd->lock, flags);
42928 /* Preserve this so that we know how many kref refs to put */
42929 - temp_open_count = hvcsd->port.count;
42930 + temp_open_count = atomic_read(&hvcsd->port.count);
42931
42932 /*
42933 * Don't kref put inside the spinlock because the destruction
42934 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42935 tty->driver_data = NULL;
42936 hvcsd->port.tty = NULL;
42937
42938 - hvcsd->port.count = 0;
42939 + atomic_set(&hvcsd->port.count, 0);
42940
42941 /* This will drop any buffered data on the floor which is OK in a hangup
42942 * scenario. */
42943 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
42944 * the middle of a write operation? This is a crummy place to do this
42945 * but we want to keep it all in the spinlock.
42946 */
42947 - if (hvcsd->port.count <= 0) {
42948 + if (atomic_read(&hvcsd->port.count) <= 0) {
42949 spin_unlock_irqrestore(&hvcsd->lock, flags);
42950 return -ENODEV;
42951 }
42952 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
42953 {
42954 struct hvcs_struct *hvcsd = tty->driver_data;
42955
42956 - if (!hvcsd || hvcsd->port.count <= 0)
42957 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
42958 return 0;
42959
42960 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
42961 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
42962 index 8fd72ff..34a0bed 100644
42963 --- a/drivers/tty/ipwireless/tty.c
42964 +++ b/drivers/tty/ipwireless/tty.c
42965 @@ -29,6 +29,7 @@
42966 #include <linux/tty_driver.h>
42967 #include <linux/tty_flip.h>
42968 #include <linux/uaccess.h>
42969 +#include <asm/local.h>
42970
42971 #include "tty.h"
42972 #include "network.h"
42973 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42974 mutex_unlock(&tty->ipw_tty_mutex);
42975 return -ENODEV;
42976 }
42977 - if (tty->port.count == 0)
42978 + if (atomic_read(&tty->port.count) == 0)
42979 tty->tx_bytes_queued = 0;
42980
42981 - tty->port.count++;
42982 + atomic_inc(&tty->port.count);
42983
42984 tty->port.tty = linux_tty;
42985 linux_tty->driver_data = tty;
42986 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42987
42988 static void do_ipw_close(struct ipw_tty *tty)
42989 {
42990 - tty->port.count--;
42991 -
42992 - if (tty->port.count == 0) {
42993 + if (atomic_dec_return(&tty->port.count) == 0) {
42994 struct tty_struct *linux_tty = tty->port.tty;
42995
42996 if (linux_tty != NULL) {
42997 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
42998 return;
42999
43000 mutex_lock(&tty->ipw_tty_mutex);
43001 - if (tty->port.count == 0) {
43002 + if (atomic_read(&tty->port.count) == 0) {
43003 mutex_unlock(&tty->ipw_tty_mutex);
43004 return;
43005 }
43006 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43007
43008 mutex_lock(&tty->ipw_tty_mutex);
43009
43010 - if (!tty->port.count) {
43011 + if (!atomic_read(&tty->port.count)) {
43012 mutex_unlock(&tty->ipw_tty_mutex);
43013 return;
43014 }
43015 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43016 return -ENODEV;
43017
43018 mutex_lock(&tty->ipw_tty_mutex);
43019 - if (!tty->port.count) {
43020 + if (!atomic_read(&tty->port.count)) {
43021 mutex_unlock(&tty->ipw_tty_mutex);
43022 return -EINVAL;
43023 }
43024 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43025 if (!tty)
43026 return -ENODEV;
43027
43028 - if (!tty->port.count)
43029 + if (!atomic_read(&tty->port.count))
43030 return -EINVAL;
43031
43032 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43033 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43034 if (!tty)
43035 return 0;
43036
43037 - if (!tty->port.count)
43038 + if (!atomic_read(&tty->port.count))
43039 return 0;
43040
43041 return tty->tx_bytes_queued;
43042 @@ -369,7 +368,7 @@ static int ipw_tiocmget(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 return get_control_lines(tty);
43051 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43052 if (!tty)
43053 return -ENODEV;
43054
43055 - if (!tty->port.count)
43056 + if (!atomic_read(&tty->port.count))
43057 return -EINVAL;
43058
43059 return set_control_lines(tty, set, clear);
43060 @@ -399,7 +398,7 @@ static int ipw_ioctl(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 /* FIXME: Exactly how is the tty object locked here .. */
43069 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43070 * are gone */
43071 mutex_lock(&ttyj->ipw_tty_mutex);
43072 }
43073 - while (ttyj->port.count)
43074 + while (atomic_read(&ttyj->port.count))
43075 do_ipw_close(ttyj);
43076 ipwireless_disassociate_network_ttys(network,
43077 ttyj->channel_idx);
43078 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43079 index adeac25..787a0a1 100644
43080 --- a/drivers/tty/moxa.c
43081 +++ b/drivers/tty/moxa.c
43082 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43083 }
43084
43085 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43086 - ch->port.count++;
43087 + atomic_inc(&ch->port.count);
43088 tty->driver_data = ch;
43089 tty_port_tty_set(&ch->port, tty);
43090 mutex_lock(&ch->port.mutex);
43091 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43092 index 4a43ef5d7..aa71f27 100644
43093 --- a/drivers/tty/n_gsm.c
43094 +++ b/drivers/tty/n_gsm.c
43095 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43096 spin_lock_init(&dlci->lock);
43097 mutex_init(&dlci->mutex);
43098 dlci->fifo = &dlci->_fifo;
43099 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43100 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43101 kfree(dlci);
43102 return NULL;
43103 }
43104 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43105 struct gsm_dlci *dlci = tty->driver_data;
43106 struct tty_port *port = &dlci->port;
43107
43108 - port->count++;
43109 + atomic_inc(&port->count);
43110 dlci_get(dlci);
43111 dlci_get(dlci->gsm->dlci[0]);
43112 mux_get(dlci->gsm);
43113 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43114 index 05e72be..67f6a0f 100644
43115 --- a/drivers/tty/n_tty.c
43116 +++ b/drivers/tty/n_tty.c
43117 @@ -2197,6 +2197,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43118 {
43119 *ops = tty_ldisc_N_TTY;
43120 ops->owner = NULL;
43121 - ops->refcount = ops->flags = 0;
43122 + atomic_set(&ops->refcount, 0);
43123 + ops->flags = 0;
43124 }
43125 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43126 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43127 index 125e0fd..8c50690 100644
43128 --- a/drivers/tty/pty.c
43129 +++ b/drivers/tty/pty.c
43130 @@ -800,8 +800,10 @@ static void __init unix98_pty_init(void)
43131 panic("Couldn't register Unix98 pts driver");
43132
43133 /* Now create the /dev/ptmx special device */
43134 + pax_open_kernel();
43135 tty_default_fops(&ptmx_fops);
43136 - ptmx_fops.open = ptmx_open;
43137 + *(void **)&ptmx_fops.open = ptmx_open;
43138 + pax_close_kernel();
43139
43140 cdev_init(&ptmx_cdev, &ptmx_fops);
43141 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43142 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43143 index 1d27003..959f452 100644
43144 --- a/drivers/tty/rocket.c
43145 +++ b/drivers/tty/rocket.c
43146 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43147 tty->driver_data = info;
43148 tty_port_tty_set(port, tty);
43149
43150 - if (port->count++ == 0) {
43151 + if (atomic_inc_return(&port->count) == 1) {
43152 atomic_inc(&rp_num_ports_open);
43153
43154 #ifdef ROCKET_DEBUG_OPEN
43155 @@ -932,7 +932,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43156 #endif
43157 }
43158 #ifdef ROCKET_DEBUG_OPEN
43159 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43160 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43161 #endif
43162
43163 /*
43164 @@ -1527,7 +1527,7 @@ static void rp_hangup(struct tty_struct *tty)
43165 spin_unlock_irqrestore(&info->port.lock, flags);
43166 return;
43167 }
43168 - if (info->port.count)
43169 + if (atomic_read(&info->port.count))
43170 atomic_dec(&rp_num_ports_open);
43171 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43172 spin_unlock_irqrestore(&info->port.lock, flags);
43173 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43174 index 1002054..dd644a8 100644
43175 --- a/drivers/tty/serial/kgdboc.c
43176 +++ b/drivers/tty/serial/kgdboc.c
43177 @@ -24,8 +24,9 @@
43178 #define MAX_CONFIG_LEN 40
43179
43180 static struct kgdb_io kgdboc_io_ops;
43181 +static struct kgdb_io kgdboc_io_ops_console;
43182
43183 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43184 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43185 static int configured = -1;
43186
43187 static char config[MAX_CONFIG_LEN];
43188 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43189 kgdboc_unregister_kbd();
43190 if (configured == 1)
43191 kgdb_unregister_io_module(&kgdboc_io_ops);
43192 + else if (configured == 2)
43193 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43194 }
43195
43196 static int configure_kgdboc(void)
43197 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43198 int err;
43199 char *cptr = config;
43200 struct console *cons;
43201 + int is_console = 0;
43202
43203 err = kgdboc_option_setup(config);
43204 if (err || !strlen(config) || isspace(config[0]))
43205 goto noconfig;
43206
43207 err = -ENODEV;
43208 - kgdboc_io_ops.is_console = 0;
43209 kgdb_tty_driver = NULL;
43210
43211 kgdboc_use_kms = 0;
43212 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43213 int idx;
43214 if (cons->device && cons->device(cons, &idx) == p &&
43215 idx == tty_line) {
43216 - kgdboc_io_ops.is_console = 1;
43217 + is_console = 1;
43218 break;
43219 }
43220 cons = cons->next;
43221 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43222 kgdb_tty_line = tty_line;
43223
43224 do_register:
43225 - err = kgdb_register_io_module(&kgdboc_io_ops);
43226 + if (is_console) {
43227 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43228 + configured = 2;
43229 + } else {
43230 + err = kgdb_register_io_module(&kgdboc_io_ops);
43231 + configured = 1;
43232 + }
43233 if (err)
43234 goto noconfig;
43235
43236 @@ -205,8 +214,6 @@ do_register:
43237 if (err)
43238 goto nmi_con_failed;
43239
43240 - configured = 1;
43241 -
43242 return 0;
43243
43244 nmi_con_failed:
43245 @@ -223,7 +230,7 @@ noconfig:
43246 static int __init init_kgdboc(void)
43247 {
43248 /* Already configured? */
43249 - if (configured == 1)
43250 + if (configured >= 1)
43251 return 0;
43252
43253 return configure_kgdboc();
43254 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43255 if (config[len - 1] == '\n')
43256 config[len - 1] = '\0';
43257
43258 - if (configured == 1)
43259 + if (configured >= 1)
43260 cleanup_kgdboc();
43261
43262 /* Go and configure with the new params. */
43263 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43264 .post_exception = kgdboc_post_exp_handler,
43265 };
43266
43267 +static struct kgdb_io kgdboc_io_ops_console = {
43268 + .name = "kgdboc",
43269 + .read_char = kgdboc_get_char,
43270 + .write_char = kgdboc_put_char,
43271 + .pre_exception = kgdboc_pre_exp_handler,
43272 + .post_exception = kgdboc_post_exp_handler,
43273 + .is_console = 1
43274 +};
43275 +
43276 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43277 /* This is only available if kgdboc is a built in for early debugging */
43278 static int __init kgdboc_early_init(char *opt)
43279 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43280 index 2769a38..f3dbe48 100644
43281 --- a/drivers/tty/serial/samsung.c
43282 +++ b/drivers/tty/serial/samsung.c
43283 @@ -451,11 +451,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43284 }
43285 }
43286
43287 +static int s3c64xx_serial_startup(struct uart_port *port);
43288 static int s3c24xx_serial_startup(struct uart_port *port)
43289 {
43290 struct s3c24xx_uart_port *ourport = to_ourport(port);
43291 int ret;
43292
43293 + /* Startup sequence is different for s3c64xx and higher SoC's */
43294 + if (s3c24xx_serial_has_interrupt_mask(port))
43295 + return s3c64xx_serial_startup(port);
43296 +
43297 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43298 port->mapbase, port->membase);
43299
43300 @@ -1120,10 +1125,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43301 /* setup info for port */
43302 port->dev = &platdev->dev;
43303
43304 - /* Startup sequence is different for s3c64xx and higher SoC's */
43305 - if (s3c24xx_serial_has_interrupt_mask(port))
43306 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43307 -
43308 port->uartclk = 1;
43309
43310 if (cfg->uart_flags & UPF_CONS_FLOW) {
43311 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43312 index 8fbb6d2..822a9e6 100644
43313 --- a/drivers/tty/serial/serial_core.c
43314 +++ b/drivers/tty/serial/serial_core.c
43315 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
43316 uart_flush_buffer(tty);
43317 uart_shutdown(tty, state);
43318 spin_lock_irqsave(&port->lock, flags);
43319 - port->count = 0;
43320 + atomic_set(&port->count, 0);
43321 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43322 spin_unlock_irqrestore(&port->lock, flags);
43323 tty_port_tty_set(port, NULL);
43324 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43325 goto end;
43326 }
43327
43328 - port->count++;
43329 + atomic_inc(&port->count);
43330 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43331 retval = -ENXIO;
43332 goto err_dec_count;
43333 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43334 /*
43335 * Make sure the device is in D0 state.
43336 */
43337 - if (port->count == 1)
43338 + if (atomic_read(&port->count) == 1)
43339 uart_change_pm(state, UART_PM_STATE_ON);
43340
43341 /*
43342 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43343 end:
43344 return retval;
43345 err_dec_count:
43346 - port->count--;
43347 + atomic_inc(&port->count);
43348 mutex_unlock(&port->mutex);
43349 goto end;
43350 }
43351 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43352 index 8983276..72a4090 100644
43353 --- a/drivers/tty/synclink.c
43354 +++ b/drivers/tty/synclink.c
43355 @@ -3093,7 +3093,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43356
43357 if (debug_level >= DEBUG_LEVEL_INFO)
43358 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43359 - __FILE__,__LINE__, info->device_name, info->port.count);
43360 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43361
43362 if (tty_port_close_start(&info->port, tty, filp) == 0)
43363 goto cleanup;
43364 @@ -3111,7 +3111,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43365 cleanup:
43366 if (debug_level >= DEBUG_LEVEL_INFO)
43367 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43368 - tty->driver->name, info->port.count);
43369 + tty->driver->name, atomic_read(&info->port.count));
43370
43371 } /* end of mgsl_close() */
43372
43373 @@ -3210,8 +3210,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43374
43375 mgsl_flush_buffer(tty);
43376 shutdown(info);
43377 -
43378 - info->port.count = 0;
43379 +
43380 + atomic_set(&info->port.count, 0);
43381 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43382 info->port.tty = NULL;
43383
43384 @@ -3300,12 +3300,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43385
43386 if (debug_level >= DEBUG_LEVEL_INFO)
43387 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43388 - __FILE__,__LINE__, tty->driver->name, port->count );
43389 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43390
43391 spin_lock_irqsave(&info->irq_spinlock, flags);
43392 if (!tty_hung_up_p(filp)) {
43393 extra_count = true;
43394 - port->count--;
43395 + atomic_dec(&port->count);
43396 }
43397 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43398 port->blocked_open++;
43399 @@ -3334,7 +3334,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43400
43401 if (debug_level >= DEBUG_LEVEL_INFO)
43402 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43403 - __FILE__,__LINE__, tty->driver->name, port->count );
43404 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43405
43406 tty_unlock(tty);
43407 schedule();
43408 @@ -3346,12 +3346,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43409
43410 /* FIXME: Racy on hangup during close wait */
43411 if (extra_count)
43412 - port->count++;
43413 + atomic_inc(&port->count);
43414 port->blocked_open--;
43415
43416 if (debug_level >= DEBUG_LEVEL_INFO)
43417 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43418 - __FILE__,__LINE__, tty->driver->name, port->count );
43419 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43420
43421 if (!retval)
43422 port->flags |= ASYNC_NORMAL_ACTIVE;
43423 @@ -3403,7 +3403,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43424
43425 if (debug_level >= DEBUG_LEVEL_INFO)
43426 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43427 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43428 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43429
43430 /* If port is closing, signal caller to try again */
43431 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43432 @@ -3422,10 +3422,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43433 spin_unlock_irqrestore(&info->netlock, flags);
43434 goto cleanup;
43435 }
43436 - info->port.count++;
43437 + atomic_inc(&info->port.count);
43438 spin_unlock_irqrestore(&info->netlock, flags);
43439
43440 - if (info->port.count == 1) {
43441 + if (atomic_read(&info->port.count) == 1) {
43442 /* 1st open on this device, init hardware */
43443 retval = startup(info);
43444 if (retval < 0)
43445 @@ -3449,8 +3449,8 @@ cleanup:
43446 if (retval) {
43447 if (tty->count == 1)
43448 info->port.tty = NULL; /* tty layer will release tty struct */
43449 - if(info->port.count)
43450 - info->port.count--;
43451 + if (atomic_read(&info->port.count))
43452 + atomic_dec(&info->port.count);
43453 }
43454
43455 return retval;
43456 @@ -7668,7 +7668,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43457 unsigned short new_crctype;
43458
43459 /* return error if TTY interface open */
43460 - if (info->port.count)
43461 + if (atomic_read(&info->port.count))
43462 return -EBUSY;
43463
43464 switch (encoding)
43465 @@ -7763,7 +7763,7 @@ static int hdlcdev_open(struct net_device *dev)
43466
43467 /* arbitrate between network and tty opens */
43468 spin_lock_irqsave(&info->netlock, flags);
43469 - if (info->port.count != 0 || info->netcount != 0) {
43470 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43471 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43472 spin_unlock_irqrestore(&info->netlock, flags);
43473 return -EBUSY;
43474 @@ -7849,7 +7849,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43475 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
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 if (cmd != SIOCWANDEV)
43483 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43484 index aa9eece..d8baaec 100644
43485 --- a/drivers/tty/synclink_gt.c
43486 +++ b/drivers/tty/synclink_gt.c
43487 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43488 tty->driver_data = info;
43489 info->port.tty = tty;
43490
43491 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43492 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43493
43494 /* If port is closing, signal caller to try again */
43495 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43496 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43497 mutex_unlock(&info->port.mutex);
43498 goto cleanup;
43499 }
43500 - info->port.count++;
43501 + atomic_inc(&info->port.count);
43502 spin_unlock_irqrestore(&info->netlock, flags);
43503
43504 - if (info->port.count == 1) {
43505 + if (atomic_read(&info->port.count) == 1) {
43506 /* 1st open on this device, init hardware */
43507 retval = startup(info);
43508 if (retval < 0) {
43509 @@ -715,8 +715,8 @@ cleanup:
43510 if (retval) {
43511 if (tty->count == 1)
43512 info->port.tty = NULL; /* tty layer will release tty struct */
43513 - if(info->port.count)
43514 - info->port.count--;
43515 + if(atomic_read(&info->port.count))
43516 + atomic_dec(&info->port.count);
43517 }
43518
43519 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43520 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43521
43522 if (sanity_check(info, tty->name, "close"))
43523 return;
43524 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43525 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43526
43527 if (tty_port_close_start(&info->port, tty, filp) == 0)
43528 goto cleanup;
43529 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43530 tty_port_close_end(&info->port, tty);
43531 info->port.tty = NULL;
43532 cleanup:
43533 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43534 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43535 }
43536
43537 static void hangup(struct tty_struct *tty)
43538 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
43539 shutdown(info);
43540
43541 spin_lock_irqsave(&info->port.lock, flags);
43542 - info->port.count = 0;
43543 + atomic_set(&info->port.count, 0);
43544 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43545 info->port.tty = NULL;
43546 spin_unlock_irqrestore(&info->port.lock, flags);
43547 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43548 unsigned short new_crctype;
43549
43550 /* return error if TTY interface open */
43551 - if (info->port.count)
43552 + if (atomic_read(&info->port.count))
43553 return -EBUSY;
43554
43555 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
43556 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
43557
43558 /* arbitrate between network and tty opens */
43559 spin_lock_irqsave(&info->netlock, flags);
43560 - if (info->port.count != 0 || info->netcount != 0) {
43561 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43562 DBGINFO(("%s hdlc_open busy\n", dev->name));
43563 spin_unlock_irqrestore(&info->netlock, flags);
43564 return -EBUSY;
43565 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43566 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
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 if (cmd != SIOCWANDEV)
43574 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
43575 if (port == NULL)
43576 continue;
43577 spin_lock(&port->lock);
43578 - if ((port->port.count || port->netcount) &&
43579 + if ((atomic_read(&port->port.count) || port->netcount) &&
43580 port->pending_bh && !port->bh_running &&
43581 !port->bh_requested) {
43582 DBGISR(("%s bh queued\n", port->device_name));
43583 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43584 spin_lock_irqsave(&info->lock, flags);
43585 if (!tty_hung_up_p(filp)) {
43586 extra_count = true;
43587 - port->count--;
43588 + atomic_dec(&port->count);
43589 }
43590 spin_unlock_irqrestore(&info->lock, flags);
43591 port->blocked_open++;
43592 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43593 remove_wait_queue(&port->open_wait, &wait);
43594
43595 if (extra_count)
43596 - port->count++;
43597 + atomic_inc(&port->count);
43598 port->blocked_open--;
43599
43600 if (!retval)
43601 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
43602 index 6d5780c..aa4d8cd 100644
43603 --- a/drivers/tty/synclinkmp.c
43604 +++ b/drivers/tty/synclinkmp.c
43605 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43606
43607 if (debug_level >= DEBUG_LEVEL_INFO)
43608 printk("%s(%d):%s open(), old ref count = %d\n",
43609 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43610 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43611
43612 /* If port is closing, signal caller to try again */
43613 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43614 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43615 spin_unlock_irqrestore(&info->netlock, flags);
43616 goto cleanup;
43617 }
43618 - info->port.count++;
43619 + atomic_inc(&info->port.count);
43620 spin_unlock_irqrestore(&info->netlock, flags);
43621
43622 - if (info->port.count == 1) {
43623 + if (atomic_read(&info->port.count) == 1) {
43624 /* 1st open on this device, init hardware */
43625 retval = startup(info);
43626 if (retval < 0)
43627 @@ -796,8 +796,8 @@ cleanup:
43628 if (retval) {
43629 if (tty->count == 1)
43630 info->port.tty = NULL; /* tty layer will release tty struct */
43631 - if(info->port.count)
43632 - info->port.count--;
43633 + if(atomic_read(&info->port.count))
43634 + atomic_dec(&info->port.count);
43635 }
43636
43637 return retval;
43638 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43639
43640 if (debug_level >= DEBUG_LEVEL_INFO)
43641 printk("%s(%d):%s close() entry, count=%d\n",
43642 - __FILE__,__LINE__, info->device_name, info->port.count);
43643 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43644
43645 if (tty_port_close_start(&info->port, tty, filp) == 0)
43646 goto cleanup;
43647 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43648 cleanup:
43649 if (debug_level >= DEBUG_LEVEL_INFO)
43650 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
43651 - tty->driver->name, info->port.count);
43652 + tty->driver->name, atomic_read(&info->port.count));
43653 }
43654
43655 /* Called by tty_hangup() when a hangup is signaled.
43656 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
43657 shutdown(info);
43658
43659 spin_lock_irqsave(&info->port.lock, flags);
43660 - info->port.count = 0;
43661 + atomic_set(&info->port.count, 0);
43662 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43663 info->port.tty = NULL;
43664 spin_unlock_irqrestore(&info->port.lock, flags);
43665 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43666 unsigned short new_crctype;
43667
43668 /* return error if TTY interface open */
43669 - if (info->port.count)
43670 + if (atomic_read(&info->port.count))
43671 return -EBUSY;
43672
43673 switch (encoding)
43674 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
43675
43676 /* arbitrate between network and tty opens */
43677 spin_lock_irqsave(&info->netlock, flags);
43678 - if (info->port.count != 0 || info->netcount != 0) {
43679 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43680 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43681 spin_unlock_irqrestore(&info->netlock, flags);
43682 return -EBUSY;
43683 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43684 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
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 if (cmd != SIOCWANDEV)
43692 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
43693 * do not request bottom half processing if the
43694 * device is not open in a normal mode.
43695 */
43696 - if ( port && (port->port.count || port->netcount) &&
43697 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
43698 port->pending_bh && !port->bh_running &&
43699 !port->bh_requested ) {
43700 if ( debug_level >= DEBUG_LEVEL_ISR )
43701 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43702
43703 if (debug_level >= DEBUG_LEVEL_INFO)
43704 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
43705 - __FILE__,__LINE__, tty->driver->name, port->count );
43706 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43707
43708 spin_lock_irqsave(&info->lock, flags);
43709 if (!tty_hung_up_p(filp)) {
43710 extra_count = true;
43711 - port->count--;
43712 + atomic_dec(&port->count);
43713 }
43714 spin_unlock_irqrestore(&info->lock, flags);
43715 port->blocked_open++;
43716 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43717
43718 if (debug_level >= DEBUG_LEVEL_INFO)
43719 printk("%s(%d):%s block_til_ready() count=%d\n",
43720 - __FILE__,__LINE__, tty->driver->name, port->count );
43721 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43722
43723 tty_unlock(tty);
43724 schedule();
43725 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43726 remove_wait_queue(&port->open_wait, &wait);
43727
43728 if (extra_count)
43729 - port->count++;
43730 + atomic_inc(&port->count);
43731 port->blocked_open--;
43732
43733 if (debug_level >= DEBUG_LEVEL_INFO)
43734 printk("%s(%d):%s block_til_ready() after, count=%d\n",
43735 - __FILE__,__LINE__, tty->driver->name, port->count );
43736 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43737
43738 if (!retval)
43739 port->flags |= ASYNC_NORMAL_ACTIVE;
43740 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
43741 index 3687f0c..6b9b808 100644
43742 --- a/drivers/tty/sysrq.c
43743 +++ b/drivers/tty/sysrq.c
43744 @@ -995,7 +995,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
43745 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
43746 size_t count, loff_t *ppos)
43747 {
43748 - if (count) {
43749 + if (count && capable(CAP_SYS_ADMIN)) {
43750 char c;
43751
43752 if (get_user(c, buf))
43753 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
43754 index a9cd0b9..47b9336 100644
43755 --- a/drivers/tty/tty_io.c
43756 +++ b/drivers/tty/tty_io.c
43757 @@ -3398,7 +3398,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
43758
43759 void tty_default_fops(struct file_operations *fops)
43760 {
43761 - *fops = tty_fops;
43762 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
43763 }
43764
43765 /*
43766 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
43767 index d794087..e4f49e5 100644
43768 --- a/drivers/tty/tty_ldisc.c
43769 +++ b/drivers/tty/tty_ldisc.c
43770 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
43771 if (atomic_dec_and_test(&ld->users)) {
43772 struct tty_ldisc_ops *ldo = ld->ops;
43773
43774 - ldo->refcount--;
43775 + atomic_dec(&ldo->refcount);
43776 module_put(ldo->owner);
43777 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43778
43779 @@ -93,7 +93,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
43780 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43781 tty_ldiscs[disc] = new_ldisc;
43782 new_ldisc->num = disc;
43783 - new_ldisc->refcount = 0;
43784 + atomic_set(&new_ldisc->refcount, 0);
43785 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43786
43787 return ret;
43788 @@ -121,7 +121,7 @@ int tty_unregister_ldisc(int disc)
43789 return -EINVAL;
43790
43791 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43792 - if (tty_ldiscs[disc]->refcount)
43793 + if (atomic_read(&tty_ldiscs[disc]->refcount))
43794 ret = -EBUSY;
43795 else
43796 tty_ldiscs[disc] = NULL;
43797 @@ -142,7 +142,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
43798 if (ldops) {
43799 ret = ERR_PTR(-EAGAIN);
43800 if (try_module_get(ldops->owner)) {
43801 - ldops->refcount++;
43802 + atomic_inc(&ldops->refcount);
43803 ret = ldops;
43804 }
43805 }
43806 @@ -155,7 +155,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
43807 unsigned long flags;
43808
43809 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43810 - ldops->refcount--;
43811 + atomic_dec(&ldops->refcount);
43812 module_put(ldops->owner);
43813 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43814 }
43815 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
43816 index b7ff59d..7c6105e 100644
43817 --- a/drivers/tty/tty_port.c
43818 +++ b/drivers/tty/tty_port.c
43819 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
43820 unsigned long flags;
43821
43822 spin_lock_irqsave(&port->lock, flags);
43823 - port->count = 0;
43824 + atomic_set(&port->count, 0);
43825 port->flags &= ~ASYNC_NORMAL_ACTIVE;
43826 if (port->tty) {
43827 set_bit(TTY_IO_ERROR, &port->tty->flags);
43828 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43829 /* The port lock protects the port counts */
43830 spin_lock_irqsave(&port->lock, flags);
43831 if (!tty_hung_up_p(filp))
43832 - port->count--;
43833 + atomic_dec(&port->count);
43834 port->blocked_open++;
43835 spin_unlock_irqrestore(&port->lock, flags);
43836
43837 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43838 we must not mess that up further */
43839 spin_lock_irqsave(&port->lock, flags);
43840 if (!tty_hung_up_p(filp))
43841 - port->count++;
43842 + atomic_inc(&port->count);
43843 port->blocked_open--;
43844 if (retval == 0)
43845 port->flags |= ASYNC_NORMAL_ACTIVE;
43846 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
43847 return 0;
43848 }
43849
43850 - if (tty->count == 1 && port->count != 1) {
43851 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
43852 printk(KERN_WARNING
43853 "tty_port_close_start: tty->count = 1 port count = %d.\n",
43854 - port->count);
43855 - port->count = 1;
43856 + atomic_read(&port->count));
43857 + atomic_set(&port->count, 1);
43858 }
43859 - if (--port->count < 0) {
43860 + if (atomic_dec_return(&port->count) < 0) {
43861 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
43862 - port->count);
43863 - port->count = 0;
43864 + atomic_read(&port->count));
43865 + atomic_set(&port->count, 0);
43866 }
43867
43868 - if (port->count) {
43869 + if (atomic_read(&port->count)) {
43870 spin_unlock_irqrestore(&port->lock, flags);
43871 if (port->ops->drop)
43872 port->ops->drop(port);
43873 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
43874 {
43875 spin_lock_irq(&port->lock);
43876 if (!tty_hung_up_p(filp))
43877 - ++port->count;
43878 + atomic_inc(&port->count);
43879 spin_unlock_irq(&port->lock);
43880 tty_port_tty_set(port, tty);
43881
43882 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
43883 index a9af1b9a..1e08e7f 100644
43884 --- a/drivers/tty/vt/keyboard.c
43885 +++ b/drivers/tty/vt/keyboard.c
43886 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
43887 kbd->kbdmode == VC_OFF) &&
43888 value != KVAL(K_SAK))
43889 return; /* SAK is allowed even in raw mode */
43890 +
43891 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
43892 + {
43893 + void *func = fn_handler[value];
43894 + if (func == fn_show_state || func == fn_show_ptregs ||
43895 + func == fn_show_mem)
43896 + return;
43897 + }
43898 +#endif
43899 +
43900 fn_handler[value](vc);
43901 }
43902
43903 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43904 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
43905 return -EFAULT;
43906
43907 - if (!capable(CAP_SYS_TTY_CONFIG))
43908 - perm = 0;
43909 -
43910 switch (cmd) {
43911 case KDGKBENT:
43912 /* Ensure another thread doesn't free it under us */
43913 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43914 spin_unlock_irqrestore(&kbd_event_lock, flags);
43915 return put_user(val, &user_kbe->kb_value);
43916 case KDSKBENT:
43917 + if (!capable(CAP_SYS_TTY_CONFIG))
43918 + perm = 0;
43919 +
43920 if (!perm)
43921 return -EPERM;
43922 if (!i && v == K_NOSUCHMAP) {
43923 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43924 int i, j, k;
43925 int ret;
43926
43927 - if (!capable(CAP_SYS_TTY_CONFIG))
43928 - perm = 0;
43929 -
43930 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
43931 if (!kbs) {
43932 ret = -ENOMEM;
43933 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43934 kfree(kbs);
43935 return ((p && *p) ? -EOVERFLOW : 0);
43936 case KDSKBSENT:
43937 + if (!capable(CAP_SYS_TTY_CONFIG))
43938 + perm = 0;
43939 +
43940 if (!perm) {
43941 ret = -EPERM;
43942 goto reterr;
43943 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
43944 index c8b9262..7e824e6 100644
43945 --- a/drivers/uio/uio.c
43946 +++ b/drivers/uio/uio.c
43947 @@ -25,6 +25,7 @@
43948 #include <linux/kobject.h>
43949 #include <linux/cdev.h>
43950 #include <linux/uio_driver.h>
43951 +#include <asm/local.h>
43952
43953 #define UIO_MAX_DEVICES (1U << MINORBITS)
43954
43955 @@ -32,10 +33,10 @@ struct uio_device {
43956 struct module *owner;
43957 struct device *dev;
43958 int minor;
43959 - atomic_t event;
43960 + atomic_unchecked_t event;
43961 struct fasync_struct *async_queue;
43962 wait_queue_head_t wait;
43963 - int vma_count;
43964 + local_t vma_count;
43965 struct uio_info *info;
43966 struct kobject *map_dir;
43967 struct kobject *portio_dir;
43968 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
43969 struct device_attribute *attr, char *buf)
43970 {
43971 struct uio_device *idev = dev_get_drvdata(dev);
43972 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
43973 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
43974 }
43975
43976 static struct device_attribute uio_class_attributes[] = {
43977 @@ -397,7 +398,7 @@ void uio_event_notify(struct uio_info *info)
43978 {
43979 struct uio_device *idev = info->uio_dev;
43980
43981 - atomic_inc(&idev->event);
43982 + atomic_inc_unchecked(&idev->event);
43983 wake_up_interruptible(&idev->wait);
43984 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
43985 }
43986 @@ -450,7 +451,7 @@ static int uio_open(struct inode *inode, struct file *filep)
43987 }
43988
43989 listener->dev = idev;
43990 - listener->event_count = atomic_read(&idev->event);
43991 + listener->event_count = atomic_read_unchecked(&idev->event);
43992 filep->private_data = listener;
43993
43994 if (idev->info->open) {
43995 @@ -501,7 +502,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
43996 return -EIO;
43997
43998 poll_wait(filep, &idev->wait, wait);
43999 - if (listener->event_count != atomic_read(&idev->event))
44000 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44001 return POLLIN | POLLRDNORM;
44002 return 0;
44003 }
44004 @@ -526,7 +527,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44005 do {
44006 set_current_state(TASK_INTERRUPTIBLE);
44007
44008 - event_count = atomic_read(&idev->event);
44009 + event_count = atomic_read_unchecked(&idev->event);
44010 if (event_count != listener->event_count) {
44011 if (copy_to_user(buf, &event_count, count))
44012 retval = -EFAULT;
44013 @@ -595,13 +596,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44014 static void uio_vma_open(struct vm_area_struct *vma)
44015 {
44016 struct uio_device *idev = vma->vm_private_data;
44017 - idev->vma_count++;
44018 + local_inc(&idev->vma_count);
44019 }
44020
44021 static void uio_vma_close(struct vm_area_struct *vma)
44022 {
44023 struct uio_device *idev = vma->vm_private_data;
44024 - idev->vma_count--;
44025 + local_dec(&idev->vma_count);
44026 }
44027
44028 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44029 @@ -808,7 +809,7 @@ int __uio_register_device(struct module *owner,
44030 idev->owner = owner;
44031 idev->info = info;
44032 init_waitqueue_head(&idev->wait);
44033 - atomic_set(&idev->event, 0);
44034 + atomic_set_unchecked(&idev->event, 0);
44035
44036 ret = uio_get_minor(idev);
44037 if (ret)
44038 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44039 index b7eb86a..36d28af 100644
44040 --- a/drivers/usb/atm/cxacru.c
44041 +++ b/drivers/usb/atm/cxacru.c
44042 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44043 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44044 if (ret < 2)
44045 return -EINVAL;
44046 - if (index < 0 || index > 0x7f)
44047 + if (index > 0x7f)
44048 return -EINVAL;
44049 pos += tmp;
44050
44051 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44052 index 35f10bf..6a38a0b 100644
44053 --- a/drivers/usb/atm/usbatm.c
44054 +++ b/drivers/usb/atm/usbatm.c
44055 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44056 if (printk_ratelimit())
44057 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44058 __func__, vpi, vci);
44059 - atomic_inc(&vcc->stats->rx_err);
44060 + atomic_inc_unchecked(&vcc->stats->rx_err);
44061 return;
44062 }
44063
44064 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44065 if (length > ATM_MAX_AAL5_PDU) {
44066 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44067 __func__, length, vcc);
44068 - atomic_inc(&vcc->stats->rx_err);
44069 + atomic_inc_unchecked(&vcc->stats->rx_err);
44070 goto out;
44071 }
44072
44073 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44074 if (sarb->len < pdu_length) {
44075 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44076 __func__, pdu_length, sarb->len, vcc);
44077 - atomic_inc(&vcc->stats->rx_err);
44078 + atomic_inc_unchecked(&vcc->stats->rx_err);
44079 goto out;
44080 }
44081
44082 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44083 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44084 __func__, vcc);
44085 - atomic_inc(&vcc->stats->rx_err);
44086 + atomic_inc_unchecked(&vcc->stats->rx_err);
44087 goto out;
44088 }
44089
44090 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44091 if (printk_ratelimit())
44092 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44093 __func__, length);
44094 - atomic_inc(&vcc->stats->rx_drop);
44095 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44096 goto out;
44097 }
44098
44099 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44100
44101 vcc->push(vcc, skb);
44102
44103 - atomic_inc(&vcc->stats->rx);
44104 + atomic_inc_unchecked(&vcc->stats->rx);
44105 out:
44106 skb_trim(sarb, 0);
44107 }
44108 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44109 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44110
44111 usbatm_pop(vcc, skb);
44112 - atomic_inc(&vcc->stats->tx);
44113 + atomic_inc_unchecked(&vcc->stats->tx);
44114
44115 skb = skb_dequeue(&instance->sndqueue);
44116 }
44117 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44118 if (!left--)
44119 return sprintf(page,
44120 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44121 - atomic_read(&atm_dev->stats.aal5.tx),
44122 - atomic_read(&atm_dev->stats.aal5.tx_err),
44123 - atomic_read(&atm_dev->stats.aal5.rx),
44124 - atomic_read(&atm_dev->stats.aal5.rx_err),
44125 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44126 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44127 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44128 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44129 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44130 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44131
44132 if (!left--) {
44133 if (instance->disconnected)
44134 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44135 index 2a3bbdf..91d72cf 100644
44136 --- a/drivers/usb/core/devices.c
44137 +++ b/drivers/usb/core/devices.c
44138 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44139 * time it gets called.
44140 */
44141 static struct device_connect_event {
44142 - atomic_t count;
44143 + atomic_unchecked_t count;
44144 wait_queue_head_t wait;
44145 } device_event = {
44146 .count = ATOMIC_INIT(1),
44147 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44148
44149 void usbfs_conn_disc_event(void)
44150 {
44151 - atomic_add(2, &device_event.count);
44152 + atomic_add_unchecked(2, &device_event.count);
44153 wake_up(&device_event.wait);
44154 }
44155
44156 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
44157
44158 poll_wait(file, &device_event.wait, wait);
44159
44160 - event_count = atomic_read(&device_event.count);
44161 + event_count = atomic_read_unchecked(&device_event.count);
44162 if (file->f_version != event_count) {
44163 file->f_version = event_count;
44164 return POLLIN | POLLRDNORM;
44165 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44166 index f9ec44c..eb5779f 100644
44167 --- a/drivers/usb/core/hcd.c
44168 +++ b/drivers/usb/core/hcd.c
44169 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44170 */
44171 usb_get_urb(urb);
44172 atomic_inc(&urb->use_count);
44173 - atomic_inc(&urb->dev->urbnum);
44174 + atomic_inc_unchecked(&urb->dev->urbnum);
44175 usbmon_urb_submit(&hcd->self, urb);
44176
44177 /* NOTE requirements on root-hub callers (usbfs and the hub
44178 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44179 urb->hcpriv = NULL;
44180 INIT_LIST_HEAD(&urb->urb_list);
44181 atomic_dec(&urb->use_count);
44182 - atomic_dec(&urb->dev->urbnum);
44183 + atomic_dec_unchecked(&urb->dev->urbnum);
44184 if (atomic_read(&urb->reject))
44185 wake_up(&usb_kill_urb_queue);
44186 usb_put_urb(urb);
44187 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44188 index 444d30e..f15c850 100644
44189 --- a/drivers/usb/core/message.c
44190 +++ b/drivers/usb/core/message.c
44191 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44192 * method can wait for it to complete. Since you don't have a handle on the
44193 * URB used, you can't cancel the request.
44194 */
44195 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44196 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44197 __u8 requesttype, __u16 value, __u16 index, void *data,
44198 __u16 size, int timeout)
44199 {
44200 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44201 index 3f81a3d..a3aa993 100644
44202 --- a/drivers/usb/core/sysfs.c
44203 +++ b/drivers/usb/core/sysfs.c
44204 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44205 struct usb_device *udev;
44206
44207 udev = to_usb_device(dev);
44208 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44209 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44210 }
44211 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44212
44213 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44214 index f81b925..78d22ec 100644
44215 --- a/drivers/usb/core/usb.c
44216 +++ b/drivers/usb/core/usb.c
44217 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44218 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44219 dev->state = USB_STATE_ATTACHED;
44220 dev->lpm_disable_count = 1;
44221 - atomic_set(&dev->urbnum, 0);
44222 + atomic_set_unchecked(&dev->urbnum, 0);
44223
44224 INIT_LIST_HEAD(&dev->ep0.urb_list);
44225 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44226 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44227 index 5e29dde..eca992f 100644
44228 --- a/drivers/usb/early/ehci-dbgp.c
44229 +++ b/drivers/usb/early/ehci-dbgp.c
44230 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44231
44232 #ifdef CONFIG_KGDB
44233 static struct kgdb_io kgdbdbgp_io_ops;
44234 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44235 +static struct kgdb_io kgdbdbgp_io_ops_console;
44236 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44237 #else
44238 #define dbgp_kgdb_mode (0)
44239 #endif
44240 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44241 .write_char = kgdbdbgp_write_char,
44242 };
44243
44244 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44245 + .name = "kgdbdbgp",
44246 + .read_char = kgdbdbgp_read_char,
44247 + .write_char = kgdbdbgp_write_char,
44248 + .is_console = 1
44249 +};
44250 +
44251 static int kgdbdbgp_wait_time;
44252
44253 static int __init kgdbdbgp_parse_config(char *str)
44254 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44255 ptr++;
44256 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44257 }
44258 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44259 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44260 + if (early_dbgp_console.index != -1)
44261 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44262 + else
44263 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44264
44265 return 0;
44266 }
44267 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44268 index b369292..9f3ba40 100644
44269 --- a/drivers/usb/gadget/u_serial.c
44270 +++ b/drivers/usb/gadget/u_serial.c
44271 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44272 spin_lock_irq(&port->port_lock);
44273
44274 /* already open? Great. */
44275 - if (port->port.count) {
44276 + if (atomic_read(&port->port.count)) {
44277 status = 0;
44278 - port->port.count++;
44279 + atomic_inc(&port->port.count);
44280
44281 /* currently opening/closing? wait ... */
44282 } else if (port->openclose) {
44283 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44284 tty->driver_data = port;
44285 port->port.tty = tty;
44286
44287 - port->port.count = 1;
44288 + atomic_set(&port->port.count, 1);
44289 port->openclose = false;
44290
44291 /* if connected, start the I/O stream */
44292 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44293
44294 spin_lock_irq(&port->port_lock);
44295
44296 - if (port->port.count != 1) {
44297 - if (port->port.count == 0)
44298 + if (atomic_read(&port->port.count) != 1) {
44299 + if (atomic_read(&port->port.count) == 0)
44300 WARN_ON(1);
44301 else
44302 - --port->port.count;
44303 + atomic_dec(&port->port.count);
44304 goto exit;
44305 }
44306
44307 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44308 * and sleep if necessary
44309 */
44310 port->openclose = true;
44311 - port->port.count = 0;
44312 + atomic_set(&port->port.count, 0);
44313
44314 gser = port->port_usb;
44315 if (gser && gser->disconnect)
44316 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
44317 int cond;
44318
44319 spin_lock_irq(&port->port_lock);
44320 - cond = (port->port.count == 0) && !port->openclose;
44321 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44322 spin_unlock_irq(&port->port_lock);
44323 return cond;
44324 }
44325 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44326 /* if it's already open, start I/O ... and notify the serial
44327 * protocol about open/close status (connect/disconnect).
44328 */
44329 - if (port->port.count) {
44330 + if (atomic_read(&port->port.count)) {
44331 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44332 gs_start_io(port);
44333 if (gser->connect)
44334 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
44335
44336 port->port_usb = NULL;
44337 gser->ioport = NULL;
44338 - if (port->port.count > 0 || port->openclose) {
44339 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44340 wake_up_interruptible(&port->drain_wait);
44341 if (port->port.tty)
44342 tty_hangup(port->port.tty);
44343 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
44344
44345 /* finally, free any unused/unusable I/O buffers */
44346 spin_lock_irqsave(&port->port_lock, flags);
44347 - if (port->port.count == 0 && !port->openclose)
44348 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44349 gs_buf_free(&port->port_write_buf);
44350 gs_free_requests(gser->out, &port->read_pool, NULL);
44351 gs_free_requests(gser->out, &port->read_queue, NULL);
44352 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44353 index 5f3bcd3..bfca43f 100644
44354 --- a/drivers/usb/serial/console.c
44355 +++ b/drivers/usb/serial/console.c
44356 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44357
44358 info->port = port;
44359
44360 - ++port->port.count;
44361 + atomic_inc(&port->port.count);
44362 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44363 if (serial->type->set_termios) {
44364 /*
44365 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44366 }
44367 /* Now that any required fake tty operations are completed restore
44368 * the tty port count */
44369 - --port->port.count;
44370 + atomic_dec(&port->port.count);
44371 /* The console is special in terms of closing the device so
44372 * indicate this port is now acting as a system console. */
44373 port->port.console = 1;
44374 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44375 free_tty:
44376 kfree(tty);
44377 reset_open_count:
44378 - port->port.count = 0;
44379 + atomic_set(&port->port.count, 0);
44380 usb_autopm_put_interface(serial->interface);
44381 error_get_interface:
44382 usb_serial_put(serial);
44383 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44384 index 6c3586a..a94e621 100644
44385 --- a/drivers/usb/storage/realtek_cr.c
44386 +++ b/drivers/usb/storage/realtek_cr.c
44387 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44388
44389 buf = kmalloc(len, GFP_NOIO);
44390 if (buf == NULL)
44391 - return USB_STOR_TRANSPORT_ERROR;
44392 + return -ENOMEM;
44393
44394 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44395
44396 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44397 index 75f70f0..d467e1a 100644
44398 --- a/drivers/usb/storage/usb.h
44399 +++ b/drivers/usb/storage/usb.h
44400 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44401 __u8 useProtocol;
44402 __u8 useTransport;
44403 int (*initFunction)(struct us_data *);
44404 -};
44405 +} __do_const;
44406
44407
44408 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44409 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44410 index d6bea3e..60b250e 100644
44411 --- a/drivers/usb/wusbcore/wa-hc.h
44412 +++ b/drivers/usb/wusbcore/wa-hc.h
44413 @@ -192,7 +192,7 @@ struct wahc {
44414 struct list_head xfer_delayed_list;
44415 spinlock_t xfer_list_lock;
44416 struct work_struct xfer_work;
44417 - atomic_t xfer_id_count;
44418 + atomic_unchecked_t xfer_id_count;
44419 };
44420
44421
44422 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44423 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44424 spin_lock_init(&wa->xfer_list_lock);
44425 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44426 - atomic_set(&wa->xfer_id_count, 1);
44427 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44428 }
44429
44430 /**
44431 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44432 index 6ef94bc..1b41265 100644
44433 --- a/drivers/usb/wusbcore/wa-xfer.c
44434 +++ b/drivers/usb/wusbcore/wa-xfer.c
44435 @@ -296,7 +296,7 @@ out:
44436 */
44437 static void wa_xfer_id_init(struct wa_xfer *xfer)
44438 {
44439 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44440 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44441 }
44442
44443 /*
44444 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44445 index 8c55011..eed4ae1a 100644
44446 --- a/drivers/video/aty/aty128fb.c
44447 +++ b/drivers/video/aty/aty128fb.c
44448 @@ -149,7 +149,7 @@ enum {
44449 };
44450
44451 /* Must match above enum */
44452 -static char * const r128_family[] = {
44453 +static const char * const r128_family[] = {
44454 "AGP",
44455 "PCI",
44456 "PRO AGP",
44457 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44458 index 4f27fdc..d3537e6 100644
44459 --- a/drivers/video/aty/atyfb_base.c
44460 +++ b/drivers/video/aty/atyfb_base.c
44461 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44462 par->accel_flags = var->accel_flags; /* hack */
44463
44464 if (var->accel_flags) {
44465 - info->fbops->fb_sync = atyfb_sync;
44466 + pax_open_kernel();
44467 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44468 + pax_close_kernel();
44469 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44470 } else {
44471 - info->fbops->fb_sync = NULL;
44472 + pax_open_kernel();
44473 + *(void **)&info->fbops->fb_sync = NULL;
44474 + pax_close_kernel();
44475 info->flags |= FBINFO_HWACCEL_DISABLED;
44476 }
44477
44478 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44479 index 95ec042..e6affdd 100644
44480 --- a/drivers/video/aty/mach64_cursor.c
44481 +++ b/drivers/video/aty/mach64_cursor.c
44482 @@ -7,6 +7,7 @@
44483 #include <linux/string.h>
44484
44485 #include <asm/io.h>
44486 +#include <asm/pgtable.h>
44487
44488 #ifdef __sparc__
44489 #include <asm/fbio.h>
44490 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44491 info->sprite.buf_align = 16; /* and 64 lines tall. */
44492 info->sprite.flags = FB_PIXMAP_IO;
44493
44494 - info->fbops->fb_cursor = atyfb_cursor;
44495 + pax_open_kernel();
44496 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44497 + pax_close_kernel();
44498
44499 return 0;
44500 }
44501 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44502 index 6c5ed6b..b727c88 100644
44503 --- a/drivers/video/backlight/kb3886_bl.c
44504 +++ b/drivers/video/backlight/kb3886_bl.c
44505 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44506 static unsigned long kb3886bl_flags;
44507 #define KB3886BL_SUSPENDED 0x01
44508
44509 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44510 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44511 {
44512 .ident = "Sahara Touch-iT",
44513 .matches = {
44514 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44515 index 900aa4e..6d49418 100644
44516 --- a/drivers/video/fb_defio.c
44517 +++ b/drivers/video/fb_defio.c
44518 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44519
44520 BUG_ON(!fbdefio);
44521 mutex_init(&fbdefio->lock);
44522 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44523 + pax_open_kernel();
44524 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44525 + pax_close_kernel();
44526 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44527 INIT_LIST_HEAD(&fbdefio->pagelist);
44528 if (fbdefio->delay == 0) /* set a default of 1 s */
44529 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44530 page->mapping = NULL;
44531 }
44532
44533 - info->fbops->fb_mmap = NULL;
44534 + *(void **)&info->fbops->fb_mmap = NULL;
44535 mutex_destroy(&fbdefio->lock);
44536 }
44537 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44538 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44539 index 5c3960d..15cf8fc 100644
44540 --- a/drivers/video/fbcmap.c
44541 +++ b/drivers/video/fbcmap.c
44542 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44543 rc = -ENODEV;
44544 goto out;
44545 }
44546 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44547 - !info->fbops->fb_setcmap)) {
44548 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
44549 rc = -EINVAL;
44550 goto out1;
44551 }
44552 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
44553 index 86291dc..7cc5962 100644
44554 --- a/drivers/video/fbmem.c
44555 +++ b/drivers/video/fbmem.c
44556 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44557 image->dx += image->width + 8;
44558 }
44559 } else if (rotate == FB_ROTATE_UD) {
44560 - for (x = 0; x < num && image->dx >= 0; x++) {
44561 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
44562 info->fbops->fb_imageblit(info, image);
44563 image->dx -= image->width + 8;
44564 }
44565 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44566 image->dy += image->height + 8;
44567 }
44568 } else if (rotate == FB_ROTATE_CCW) {
44569 - for (x = 0; x < num && image->dy >= 0; x++) {
44570 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
44571 info->fbops->fb_imageblit(info, image);
44572 image->dy -= image->height + 8;
44573 }
44574 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
44575 return -EFAULT;
44576 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
44577 return -EINVAL;
44578 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
44579 + if (con2fb.framebuffer >= FB_MAX)
44580 return -EINVAL;
44581 if (!registered_fb[con2fb.framebuffer])
44582 request_module("fb%d", con2fb.framebuffer);
44583 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
44584 index 7672d2e..b56437f 100644
44585 --- a/drivers/video/i810/i810_accel.c
44586 +++ b/drivers/video/i810/i810_accel.c
44587 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
44588 }
44589 }
44590 printk("ringbuffer lockup!!!\n");
44591 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
44592 i810_report_error(mmio);
44593 par->dev_flags |= LOCKUP;
44594 info->pixmap.scan_align = 1;
44595 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
44596 index 3c14e43..eafa544 100644
44597 --- a/drivers/video/logo/logo_linux_clut224.ppm
44598 +++ b/drivers/video/logo/logo_linux_clut224.ppm
44599 @@ -1,1604 +1,1123 @@
44600 P3
44601 -# Standard 224-color Linux logo
44602 80 80
44603 255
44604 - 0 0 0 0 0 0 0 0 0 0 0 0
44605 - 0 0 0 0 0 0 0 0 0 0 0 0
44606 - 0 0 0 0 0 0 0 0 0 0 0 0
44607 - 0 0 0 0 0 0 0 0 0 0 0 0
44608 - 0 0 0 0 0 0 0 0 0 0 0 0
44609 - 0 0 0 0 0 0 0 0 0 0 0 0
44610 - 0 0 0 0 0 0 0 0 0 0 0 0
44611 - 0 0 0 0 0 0 0 0 0 0 0 0
44612 - 0 0 0 0 0 0 0 0 0 0 0 0
44613 - 6 6 6 6 6 6 10 10 10 10 10 10
44614 - 10 10 10 6 6 6 6 6 6 6 6 6
44615 - 0 0 0 0 0 0 0 0 0 0 0 0
44616 - 0 0 0 0 0 0 0 0 0 0 0 0
44617 - 0 0 0 0 0 0 0 0 0 0 0 0
44618 - 0 0 0 0 0 0 0 0 0 0 0 0
44619 - 0 0 0 0 0 0 0 0 0 0 0 0
44620 - 0 0 0 0 0 0 0 0 0 0 0 0
44621 - 0 0 0 0 0 0 0 0 0 0 0 0
44622 - 0 0 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 - 0 0 0 0 0 0 0 0 0 0 0 0
44632 - 0 0 0 6 6 6 10 10 10 14 14 14
44633 - 22 22 22 26 26 26 30 30 30 34 34 34
44634 - 30 30 30 30 30 30 26 26 26 18 18 18
44635 - 14 14 14 10 10 10 6 6 6 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 1 0 0 1 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 0 0 0 0 0 0 0 0 0
44651 - 0 0 0 0 0 0 0 0 0 0 0 0
44652 - 6 6 6 14 14 14 26 26 26 42 42 42
44653 - 54 54 54 66 66 66 78 78 78 78 78 78
44654 - 78 78 78 74 74 74 66 66 66 54 54 54
44655 - 42 42 42 26 26 26 18 18 18 10 10 10
44656 - 6 6 6 0 0 0 0 0 0 0 0 0
44657 - 0 0 0 0 0 0 0 0 0 0 0 0
44658 - 0 0 0 0 0 0 0 0 0 0 0 0
44659 - 0 0 0 0 0 0 0 0 0 0 0 0
44660 - 0 0 0 0 0 0 0 0 0 0 0 0
44661 - 0 0 0 0 0 0 0 0 0 0 0 0
44662 - 0 0 0 0 0 0 0 0 0 0 0 0
44663 - 0 0 0 0 0 0 0 0 0 0 0 0
44664 - 0 0 0 0 0 0 0 0 0 0 0 0
44665 - 0 0 1 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 - 0 0 0 0 0 0 0 0 0 0 0 0
44671 - 0 0 0 0 0 0 0 0 0 10 10 10
44672 - 22 22 22 42 42 42 66 66 66 86 86 86
44673 - 66 66 66 38 38 38 38 38 38 22 22 22
44674 - 26 26 26 34 34 34 54 54 54 66 66 66
44675 - 86 86 86 70 70 70 46 46 46 26 26 26
44676 - 14 14 14 6 6 6 0 0 0 0 0 0
44677 - 0 0 0 0 0 0 0 0 0 0 0 0
44678 - 0 0 0 0 0 0 0 0 0 0 0 0
44679 - 0 0 0 0 0 0 0 0 0 0 0 0
44680 - 0 0 0 0 0 0 0 0 0 0 0 0
44681 - 0 0 0 0 0 0 0 0 0 0 0 0
44682 - 0 0 0 0 0 0 0 0 0 0 0 0
44683 - 0 0 0 0 0 0 0 0 0 0 0 0
44684 - 0 0 0 0 0 0 0 0 0 0 0 0
44685 - 0 0 1 0 0 1 0 0 1 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 0 0 0
44690 - 0 0 0 0 0 0 0 0 0 0 0 0
44691 - 0 0 0 0 0 0 10 10 10 26 26 26
44692 - 50 50 50 82 82 82 58 58 58 6 6 6
44693 - 2 2 6 2 2 6 2 2 6 2 2 6
44694 - 2 2 6 2 2 6 2 2 6 2 2 6
44695 - 6 6 6 54 54 54 86 86 86 66 66 66
44696 - 38 38 38 18 18 18 6 6 6 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 0 0 0 0 0 0 0 0 0 0
44704 - 0 0 0 0 0 0 0 0 0 0 0 0
44705 - 0 0 0 0 0 0 0 0 0 0 0 0
44706 - 0 0 0 0 0 0 0 0 0 0 0 0
44707 - 0 0 0 0 0 0 0 0 0 0 0 0
44708 - 0 0 0 0 0 0 0 0 0 0 0 0
44709 - 0 0 0 0 0 0 0 0 0 0 0 0
44710 - 0 0 0 0 0 0 0 0 0 0 0 0
44711 - 0 0 0 6 6 6 22 22 22 50 50 50
44712 - 78 78 78 34 34 34 2 2 6 2 2 6
44713 - 2 2 6 2 2 6 2 2 6 2 2 6
44714 - 2 2 6 2 2 6 2 2 6 2 2 6
44715 - 2 2 6 2 2 6 6 6 6 70 70 70
44716 - 78 78 78 46 46 46 22 22 22 6 6 6
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 1 0 0 1 0 0 1 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 0 0 0 0 0 0 0 0 0
44730 - 0 0 0 0 0 0 0 0 0 0 0 0
44731 - 6 6 6 18 18 18 42 42 42 82 82 82
44732 - 26 26 26 2 2 6 2 2 6 2 2 6
44733 - 2 2 6 2 2 6 2 2 6 2 2 6
44734 - 2 2 6 2 2 6 2 2 6 14 14 14
44735 - 46 46 46 34 34 34 6 6 6 2 2 6
44736 - 42 42 42 78 78 78 42 42 42 18 18 18
44737 - 6 6 6 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 0 0 0 0 0 0 0 0 0 0
44744 - 0 0 0 0 0 0 0 0 0 0 0 0
44745 - 0 0 1 0 0 0 0 0 1 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 - 0 0 0 0 0 0 0 0 0 0 0 0
44750 - 0 0 0 0 0 0 0 0 0 0 0 0
44751 - 10 10 10 30 30 30 66 66 66 58 58 58
44752 - 2 2 6 2 2 6 2 2 6 2 2 6
44753 - 2 2 6 2 2 6 2 2 6 2 2 6
44754 - 2 2 6 2 2 6 2 2 6 26 26 26
44755 - 86 86 86 101 101 101 46 46 46 10 10 10
44756 - 2 2 6 58 58 58 70 70 70 34 34 34
44757 - 10 10 10 0 0 0 0 0 0 0 0 0
44758 - 0 0 0 0 0 0 0 0 0 0 0 0
44759 - 0 0 0 0 0 0 0 0 0 0 0 0
44760 - 0 0 0 0 0 0 0 0 0 0 0 0
44761 - 0 0 0 0 0 0 0 0 0 0 0 0
44762 - 0 0 0 0 0 0 0 0 0 0 0 0
44763 - 0 0 0 0 0 0 0 0 0 0 0 0
44764 - 0 0 0 0 0 0 0 0 0 0 0 0
44765 - 0 0 1 0 0 1 0 0 1 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 - 0 0 0 0 0 0 0 0 0 0 0 0
44770 - 0 0 0 0 0 0 0 0 0 0 0 0
44771 - 14 14 14 42 42 42 86 86 86 10 10 10
44772 - 2 2 6 2 2 6 2 2 6 2 2 6
44773 - 2 2 6 2 2 6 2 2 6 2 2 6
44774 - 2 2 6 2 2 6 2 2 6 30 30 30
44775 - 94 94 94 94 94 94 58 58 58 26 26 26
44776 - 2 2 6 6 6 6 78 78 78 54 54 54
44777 - 22 22 22 6 6 6 0 0 0 0 0 0
44778 - 0 0 0 0 0 0 0 0 0 0 0 0
44779 - 0 0 0 0 0 0 0 0 0 0 0 0
44780 - 0 0 0 0 0 0 0 0 0 0 0 0
44781 - 0 0 0 0 0 0 0 0 0 0 0 0
44782 - 0 0 0 0 0 0 0 0 0 0 0 0
44783 - 0 0 0 0 0 0 0 0 0 0 0 0
44784 - 0 0 0 0 0 0 0 0 0 0 0 0
44785 - 0 0 0 0 0 0 0 0 0 0 0 0
44786 - 0 0 0 0 0 0 0 0 0 0 0 0
44787 - 0 0 0 0 0 0 0 0 0 0 0 0
44788 - 0 0 0 0 0 0 0 0 0 0 0 0
44789 - 0 0 0 0 0 0 0 0 0 0 0 0
44790 - 0 0 0 0 0 0 0 0 0 6 6 6
44791 - 22 22 22 62 62 62 62 62 62 2 2 6
44792 - 2 2 6 2 2 6 2 2 6 2 2 6
44793 - 2 2 6 2 2 6 2 2 6 2 2 6
44794 - 2 2 6 2 2 6 2 2 6 26 26 26
44795 - 54 54 54 38 38 38 18 18 18 10 10 10
44796 - 2 2 6 2 2 6 34 34 34 82 82 82
44797 - 38 38 38 14 14 14 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 1 0 0 1 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 0 0 0
44809 - 0 0 0 0 0 0 0 0 0 0 0 0
44810 - 0 0 0 0 0 0 0 0 0 6 6 6
44811 - 30 30 30 78 78 78 30 30 30 2 2 6
44812 - 2 2 6 2 2 6 2 2 6 2 2 6
44813 - 2 2 6 2 2 6 2 2 6 2 2 6
44814 - 2 2 6 2 2 6 2 2 6 10 10 10
44815 - 10 10 10 2 2 6 2 2 6 2 2 6
44816 - 2 2 6 2 2 6 2 2 6 78 78 78
44817 - 50 50 50 18 18 18 6 6 6 0 0 0
44818 - 0 0 0 0 0 0 0 0 0 0 0 0
44819 - 0 0 0 0 0 0 0 0 0 0 0 0
44820 - 0 0 0 0 0 0 0 0 0 0 0 0
44821 - 0 0 0 0 0 0 0 0 0 0 0 0
44822 - 0 0 0 0 0 0 0 0 0 0 0 0
44823 - 0 0 0 0 0 0 0 0 0 0 0 0
44824 - 0 0 0 0 0 0 0 0 0 0 0 0
44825 - 0 0 1 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 0 0 0
44829 - 0 0 0 0 0 0 0 0 0 0 0 0
44830 - 0 0 0 0 0 0 0 0 0 10 10 10
44831 - 38 38 38 86 86 86 14 14 14 2 2 6
44832 - 2 2 6 2 2 6 2 2 6 2 2 6
44833 - 2 2 6 2 2 6 2 2 6 2 2 6
44834 - 2 2 6 2 2 6 2 2 6 2 2 6
44835 - 2 2 6 2 2 6 2 2 6 2 2 6
44836 - 2 2 6 2 2 6 2 2 6 54 54 54
44837 - 66 66 66 26 26 26 6 6 6 0 0 0
44838 - 0 0 0 0 0 0 0 0 0 0 0 0
44839 - 0 0 0 0 0 0 0 0 0 0 0 0
44840 - 0 0 0 0 0 0 0 0 0 0 0 0
44841 - 0 0 0 0 0 0 0 0 0 0 0 0
44842 - 0 0 0 0 0 0 0 0 0 0 0 0
44843 - 0 0 0 0 0 0 0 0 0 0 0 0
44844 - 0 0 0 0 0 0 0 0 0 0 0 0
44845 - 0 0 0 0 0 1 0 0 1 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 0 0 0
44849 - 0 0 0 0 0 0 0 0 0 0 0 0
44850 - 0 0 0 0 0 0 0 0 0 14 14 14
44851 - 42 42 42 82 82 82 2 2 6 2 2 6
44852 - 2 2 6 6 6 6 10 10 10 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 6 6 6
44855 - 14 14 14 10 10 10 2 2 6 2 2 6
44856 - 2 2 6 2 2 6 2 2 6 18 18 18
44857 - 82 82 82 34 34 34 10 10 10 0 0 0
44858 - 0 0 0 0 0 0 0 0 0 0 0 0
44859 - 0 0 0 0 0 0 0 0 0 0 0 0
44860 - 0 0 0 0 0 0 0 0 0 0 0 0
44861 - 0 0 0 0 0 0 0 0 0 0 0 0
44862 - 0 0 0 0 0 0 0 0 0 0 0 0
44863 - 0 0 0 0 0 0 0 0 0 0 0 0
44864 - 0 0 0 0 0 0 0 0 0 0 0 0
44865 - 0 0 1 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 0 0 0
44869 - 0 0 0 0 0 0 0 0 0 0 0 0
44870 - 0 0 0 0 0 0 0 0 0 14 14 14
44871 - 46 46 46 86 86 86 2 2 6 2 2 6
44872 - 6 6 6 6 6 6 22 22 22 34 34 34
44873 - 6 6 6 2 2 6 2 2 6 2 2 6
44874 - 2 2 6 2 2 6 18 18 18 34 34 34
44875 - 10 10 10 50 50 50 22 22 22 2 2 6
44876 - 2 2 6 2 2 6 2 2 6 10 10 10
44877 - 86 86 86 42 42 42 14 14 14 0 0 0
44878 - 0 0 0 0 0 0 0 0 0 0 0 0
44879 - 0 0 0 0 0 0 0 0 0 0 0 0
44880 - 0 0 0 0 0 0 0 0 0 0 0 0
44881 - 0 0 0 0 0 0 0 0 0 0 0 0
44882 - 0 0 0 0 0 0 0 0 0 0 0 0
44883 - 0 0 0 0 0 0 0 0 0 0 0 0
44884 - 0 0 0 0 0 0 0 0 0 0 0 0
44885 - 0 0 1 0 0 1 0 0 1 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 0 0 0
44889 - 0 0 0 0 0 0 0 0 0 0 0 0
44890 - 0 0 0 0 0 0 0 0 0 14 14 14
44891 - 46 46 46 86 86 86 2 2 6 2 2 6
44892 - 38 38 38 116 116 116 94 94 94 22 22 22
44893 - 22 22 22 2 2 6 2 2 6 2 2 6
44894 - 14 14 14 86 86 86 138 138 138 162 162 162
44895 -154 154 154 38 38 38 26 26 26 6 6 6
44896 - 2 2 6 2 2 6 2 2 6 2 2 6
44897 - 86 86 86 46 46 46 14 14 14 0 0 0
44898 - 0 0 0 0 0 0 0 0 0 0 0 0
44899 - 0 0 0 0 0 0 0 0 0 0 0 0
44900 - 0 0 0 0 0 0 0 0 0 0 0 0
44901 - 0 0 0 0 0 0 0 0 0 0 0 0
44902 - 0 0 0 0 0 0 0 0 0 0 0 0
44903 - 0 0 0 0 0 0 0 0 0 0 0 0
44904 - 0 0 0 0 0 0 0 0 0 0 0 0
44905 - 0 0 0 0 0 0 0 0 0 0 0 0
44906 - 0 0 0 0 0 0 0 0 0 0 0 0
44907 - 0 0 0 0 0 0 0 0 0 0 0 0
44908 - 0 0 0 0 0 0 0 0 0 0 0 0
44909 - 0 0 0 0 0 0 0 0 0 0 0 0
44910 - 0 0 0 0 0 0 0 0 0 14 14 14
44911 - 46 46 46 86 86 86 2 2 6 14 14 14
44912 -134 134 134 198 198 198 195 195 195 116 116 116
44913 - 10 10 10 2 2 6 2 2 6 6 6 6
44914 -101 98 89 187 187 187 210 210 210 218 218 218
44915 -214 214 214 134 134 134 14 14 14 6 6 6
44916 - 2 2 6 2 2 6 2 2 6 2 2 6
44917 - 86 86 86 50 50 50 18 18 18 6 6 6
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 1 0 0 0
44925 - 0 0 1 0 0 1 0 0 1 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 0 0 0
44929 - 0 0 0 0 0 0 0 0 0 0 0 0
44930 - 0 0 0 0 0 0 0 0 0 14 14 14
44931 - 46 46 46 86 86 86 2 2 6 54 54 54
44932 -218 218 218 195 195 195 226 226 226 246 246 246
44933 - 58 58 58 2 2 6 2 2 6 30 30 30
44934 -210 210 210 253 253 253 174 174 174 123 123 123
44935 -221 221 221 234 234 234 74 74 74 2 2 6
44936 - 2 2 6 2 2 6 2 2 6 2 2 6
44937 - 70 70 70 58 58 58 22 22 22 6 6 6
44938 - 0 0 0 0 0 0 0 0 0 0 0 0
44939 - 0 0 0 0 0 0 0 0 0 0 0 0
44940 - 0 0 0 0 0 0 0 0 0 0 0 0
44941 - 0 0 0 0 0 0 0 0 0 0 0 0
44942 - 0 0 0 0 0 0 0 0 0 0 0 0
44943 - 0 0 0 0 0 0 0 0 0 0 0 0
44944 - 0 0 0 0 0 0 0 0 0 0 0 0
44945 - 0 0 0 0 0 0 0 0 0 0 0 0
44946 - 0 0 0 0 0 0 0 0 0 0 0 0
44947 - 0 0 0 0 0 0 0 0 0 0 0 0
44948 - 0 0 0 0 0 0 0 0 0 0 0 0
44949 - 0 0 0 0 0 0 0 0 0 0 0 0
44950 - 0 0 0 0 0 0 0 0 0 14 14 14
44951 - 46 46 46 82 82 82 2 2 6 106 106 106
44952 -170 170 170 26 26 26 86 86 86 226 226 226
44953 -123 123 123 10 10 10 14 14 14 46 46 46
44954 -231 231 231 190 190 190 6 6 6 70 70 70
44955 - 90 90 90 238 238 238 158 158 158 2 2 6
44956 - 2 2 6 2 2 6 2 2 6 2 2 6
44957 - 70 70 70 58 58 58 22 22 22 6 6 6
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 1 0 0 0
44965 - 0 0 1 0 0 1 0 0 1 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 0 0 0
44969 - 0 0 0 0 0 0 0 0 0 0 0 0
44970 - 0 0 0 0 0 0 0 0 0 14 14 14
44971 - 42 42 42 86 86 86 6 6 6 116 116 116
44972 -106 106 106 6 6 6 70 70 70 149 149 149
44973 -128 128 128 18 18 18 38 38 38 54 54 54
44974 -221 221 221 106 106 106 2 2 6 14 14 14
44975 - 46 46 46 190 190 190 198 198 198 2 2 6
44976 - 2 2 6 2 2 6 2 2 6 2 2 6
44977 - 74 74 74 62 62 62 22 22 22 6 6 6
44978 - 0 0 0 0 0 0 0 0 0 0 0 0
44979 - 0 0 0 0 0 0 0 0 0 0 0 0
44980 - 0 0 0 0 0 0 0 0 0 0 0 0
44981 - 0 0 0 0 0 0 0 0 0 0 0 0
44982 - 0 0 0 0 0 0 0 0 0 0 0 0
44983 - 0 0 0 0 0 0 0 0 0 0 0 0
44984 - 0 0 0 0 0 0 0 0 1 0 0 0
44985 - 0 0 1 0 0 0 0 0 1 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 0 0 0
44989 - 0 0 0 0 0 0 0 0 0 0 0 0
44990 - 0 0 0 0 0 0 0 0 0 14 14 14
44991 - 42 42 42 94 94 94 14 14 14 101 101 101
44992 -128 128 128 2 2 6 18 18 18 116 116 116
44993 -118 98 46 121 92 8 121 92 8 98 78 10
44994 -162 162 162 106 106 106 2 2 6 2 2 6
44995 - 2 2 6 195 195 195 195 195 195 6 6 6
44996 - 2 2 6 2 2 6 2 2 6 2 2 6
44997 - 74 74 74 62 62 62 22 22 22 6 6 6
44998 - 0 0 0 0 0 0 0 0 0 0 0 0
44999 - 0 0 0 0 0 0 0 0 0 0 0 0
45000 - 0 0 0 0 0 0 0 0 0 0 0 0
45001 - 0 0 0 0 0 0 0 0 0 0 0 0
45002 - 0 0 0 0 0 0 0 0 0 0 0 0
45003 - 0 0 0 0 0 0 0 0 0 0 0 0
45004 - 0 0 0 0 0 0 0 0 1 0 0 1
45005 - 0 0 1 0 0 0 0 0 1 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 0 0 0
45009 - 0 0 0 0 0 0 0 0 0 0 0 0
45010 - 0 0 0 0 0 0 0 0 0 10 10 10
45011 - 38 38 38 90 90 90 14 14 14 58 58 58
45012 -210 210 210 26 26 26 54 38 6 154 114 10
45013 -226 170 11 236 186 11 225 175 15 184 144 12
45014 -215 174 15 175 146 61 37 26 9 2 2 6
45015 - 70 70 70 246 246 246 138 138 138 2 2 6
45016 - 2 2 6 2 2 6 2 2 6 2 2 6
45017 - 70 70 70 66 66 66 26 26 26 6 6 6
45018 - 0 0 0 0 0 0 0 0 0 0 0 0
45019 - 0 0 0 0 0 0 0 0 0 0 0 0
45020 - 0 0 0 0 0 0 0 0 0 0 0 0
45021 - 0 0 0 0 0 0 0 0 0 0 0 0
45022 - 0 0 0 0 0 0 0 0 0 0 0 0
45023 - 0 0 0 0 0 0 0 0 0 0 0 0
45024 - 0 0 0 0 0 0 0 0 0 0 0 0
45025 - 0 0 0 0 0 0 0 0 0 0 0 0
45026 - 0 0 0 0 0 0 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 0 0 0
45029 - 0 0 0 0 0 0 0 0 0 0 0 0
45030 - 0 0 0 0 0 0 0 0 0 10 10 10
45031 - 38 38 38 86 86 86 14 14 14 10 10 10
45032 -195 195 195 188 164 115 192 133 9 225 175 15
45033 -239 182 13 234 190 10 232 195 16 232 200 30
45034 -245 207 45 241 208 19 232 195 16 184 144 12
45035 -218 194 134 211 206 186 42 42 42 2 2 6
45036 - 2 2 6 2 2 6 2 2 6 2 2 6
45037 - 50 50 50 74 74 74 30 30 30 6 6 6
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 0 0 0
45049 - 0 0 0 0 0 0 0 0 0 0 0 0
45050 - 0 0 0 0 0 0 0 0 0 10 10 10
45051 - 34 34 34 86 86 86 14 14 14 2 2 6
45052 -121 87 25 192 133 9 219 162 10 239 182 13
45053 -236 186 11 232 195 16 241 208 19 244 214 54
45054 -246 218 60 246 218 38 246 215 20 241 208 19
45055 -241 208 19 226 184 13 121 87 25 2 2 6
45056 - 2 2 6 2 2 6 2 2 6 2 2 6
45057 - 50 50 50 82 82 82 34 34 34 10 10 10
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 0 0 0
45069 - 0 0 0 0 0 0 0 0 0 0 0 0
45070 - 0 0 0 0 0 0 0 0 0 10 10 10
45071 - 34 34 34 82 82 82 30 30 30 61 42 6
45072 -180 123 7 206 145 10 230 174 11 239 182 13
45073 -234 190 10 238 202 15 241 208 19 246 218 74
45074 -246 218 38 246 215 20 246 215 20 246 215 20
45075 -226 184 13 215 174 15 184 144 12 6 6 6
45076 - 2 2 6 2 2 6 2 2 6 2 2 6
45077 - 26 26 26 94 94 94 42 42 42 14 14 14
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 0 0 0
45089 - 0 0 0 0 0 0 0 0 0 0 0 0
45090 - 0 0 0 0 0 0 0 0 0 10 10 10
45091 - 30 30 30 78 78 78 50 50 50 104 69 6
45092 -192 133 9 216 158 10 236 178 12 236 186 11
45093 -232 195 16 241 208 19 244 214 54 245 215 43
45094 -246 215 20 246 215 20 241 208 19 198 155 10
45095 -200 144 11 216 158 10 156 118 10 2 2 6
45096 - 2 2 6 2 2 6 2 2 6 2 2 6
45097 - 6 6 6 90 90 90 54 54 54 18 18 18
45098 - 6 6 6 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 0 0 0
45109 - 0 0 0 0 0 0 0 0 0 0 0 0
45110 - 0 0 0 0 0 0 0 0 0 10 10 10
45111 - 30 30 30 78 78 78 46 46 46 22 22 22
45112 -137 92 6 210 162 10 239 182 13 238 190 10
45113 -238 202 15 241 208 19 246 215 20 246 215 20
45114 -241 208 19 203 166 17 185 133 11 210 150 10
45115 -216 158 10 210 150 10 102 78 10 2 2 6
45116 - 6 6 6 54 54 54 14 14 14 2 2 6
45117 - 2 2 6 62 62 62 74 74 74 30 30 30
45118 - 10 10 10 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 0 0 0
45129 - 0 0 0 0 0 0 0 0 0 0 0 0
45130 - 0 0 0 0 0 0 0 0 0 10 10 10
45131 - 34 34 34 78 78 78 50 50 50 6 6 6
45132 - 94 70 30 139 102 15 190 146 13 226 184 13
45133 -232 200 30 232 195 16 215 174 15 190 146 13
45134 -168 122 10 192 133 9 210 150 10 213 154 11
45135 -202 150 34 182 157 106 101 98 89 2 2 6
45136 - 2 2 6 78 78 78 116 116 116 58 58 58
45137 - 2 2 6 22 22 22 90 90 90 46 46 46
45138 - 18 18 18 6 6 6 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 0 0 0
45149 - 0 0 0 0 0 0 0 0 0 0 0 0
45150 - 0 0 0 0 0 0 0 0 0 10 10 10
45151 - 38 38 38 86 86 86 50 50 50 6 6 6
45152 -128 128 128 174 154 114 156 107 11 168 122 10
45153 -198 155 10 184 144 12 197 138 11 200 144 11
45154 -206 145 10 206 145 10 197 138 11 188 164 115
45155 -195 195 195 198 198 198 174 174 174 14 14 14
45156 - 2 2 6 22 22 22 116 116 116 116 116 116
45157 - 22 22 22 2 2 6 74 74 74 70 70 70
45158 - 30 30 30 10 10 10 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 0 0 0
45169 - 0 0 0 0 0 0 0 0 0 0 0 0
45170 - 0 0 0 0 0 0 6 6 6 18 18 18
45171 - 50 50 50 101 101 101 26 26 26 10 10 10
45172 -138 138 138 190 190 190 174 154 114 156 107 11
45173 -197 138 11 200 144 11 197 138 11 192 133 9
45174 -180 123 7 190 142 34 190 178 144 187 187 187
45175 -202 202 202 221 221 221 214 214 214 66 66 66
45176 - 2 2 6 2 2 6 50 50 50 62 62 62
45177 - 6 6 6 2 2 6 10 10 10 90 90 90
45178 - 50 50 50 18 18 18 6 6 6 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 0 0 0 0 0 0
45189 - 0 0 0 0 0 0 0 0 0 0 0 0
45190 - 0 0 0 0 0 0 10 10 10 34 34 34
45191 - 74 74 74 74 74 74 2 2 6 6 6 6
45192 -144 144 144 198 198 198 190 190 190 178 166 146
45193 -154 121 60 156 107 11 156 107 11 168 124 44
45194 -174 154 114 187 187 187 190 190 190 210 210 210
45195 -246 246 246 253 253 253 253 253 253 182 182 182
45196 - 6 6 6 2 2 6 2 2 6 2 2 6
45197 - 2 2 6 2 2 6 2 2 6 62 62 62
45198 - 74 74 74 34 34 34 14 14 14 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 0 0 0 0 0 0
45209 - 0 0 0 0 0 0 0 0 0 0 0 0
45210 - 0 0 0 10 10 10 22 22 22 54 54 54
45211 - 94 94 94 18 18 18 2 2 6 46 46 46
45212 -234 234 234 221 221 221 190 190 190 190 190 190
45213 -190 190 190 187 187 187 187 187 187 190 190 190
45214 -190 190 190 195 195 195 214 214 214 242 242 242
45215 -253 253 253 253 253 253 253 253 253 253 253 253
45216 - 82 82 82 2 2 6 2 2 6 2 2 6
45217 - 2 2 6 2 2 6 2 2 6 14 14 14
45218 - 86 86 86 54 54 54 22 22 22 6 6 6
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 0 0 0 0 0 0 0 0 0
45229 - 0 0 0 0 0 0 0 0 0 0 0 0
45230 - 6 6 6 18 18 18 46 46 46 90 90 90
45231 - 46 46 46 18 18 18 6 6 6 182 182 182
45232 -253 253 253 246 246 246 206 206 206 190 190 190
45233 -190 190 190 190 190 190 190 190 190 190 190 190
45234 -206 206 206 231 231 231 250 250 250 253 253 253
45235 -253 253 253 253 253 253 253 253 253 253 253 253
45236 -202 202 202 14 14 14 2 2 6 2 2 6
45237 - 2 2 6 2 2 6 2 2 6 2 2 6
45238 - 42 42 42 86 86 86 42 42 42 18 18 18
45239 - 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45249 - 0 0 0 0 0 0 0 0 0 6 6 6
45250 - 14 14 14 38 38 38 74 74 74 66 66 66
45251 - 2 2 6 6 6 6 90 90 90 250 250 250
45252 -253 253 253 253 253 253 238 238 238 198 198 198
45253 -190 190 190 190 190 190 195 195 195 221 221 221
45254 -246 246 246 253 253 253 253 253 253 253 253 253
45255 -253 253 253 253 253 253 253 253 253 253 253 253
45256 -253 253 253 82 82 82 2 2 6 2 2 6
45257 - 2 2 6 2 2 6 2 2 6 2 2 6
45258 - 2 2 6 78 78 78 70 70 70 34 34 34
45259 - 14 14 14 6 6 6 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 0 0 0
45268 - 0 0 0 0 0 0 0 0 0 0 0 0
45269 - 0 0 0 0 0 0 0 0 0 14 14 14
45270 - 34 34 34 66 66 66 78 78 78 6 6 6
45271 - 2 2 6 18 18 18 218 218 218 253 253 253
45272 -253 253 253 253 253 253 253 253 253 246 246 246
45273 -226 226 226 231 231 231 246 246 246 253 253 253
45274 -253 253 253 253 253 253 253 253 253 253 253 253
45275 -253 253 253 253 253 253 253 253 253 253 253 253
45276 -253 253 253 178 178 178 2 2 6 2 2 6
45277 - 2 2 6 2 2 6 2 2 6 2 2 6
45278 - 2 2 6 18 18 18 90 90 90 62 62 62
45279 - 30 30 30 10 10 10 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 0 0 0
45288 - 0 0 0 0 0 0 0 0 0 0 0 0
45289 - 0 0 0 0 0 0 10 10 10 26 26 26
45290 - 58 58 58 90 90 90 18 18 18 2 2 6
45291 - 2 2 6 110 110 110 253 253 253 253 253 253
45292 -253 253 253 253 253 253 253 253 253 253 253 253
45293 -250 250 250 253 253 253 253 253 253 253 253 253
45294 -253 253 253 253 253 253 253 253 253 253 253 253
45295 -253 253 253 253 253 253 253 253 253 253 253 253
45296 -253 253 253 231 231 231 18 18 18 2 2 6
45297 - 2 2 6 2 2 6 2 2 6 2 2 6
45298 - 2 2 6 2 2 6 18 18 18 94 94 94
45299 - 54 54 54 26 26 26 10 10 10 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 0 0 0 0 0 0
45308 - 0 0 0 0 0 0 0 0 0 0 0 0
45309 - 0 0 0 6 6 6 22 22 22 50 50 50
45310 - 90 90 90 26 26 26 2 2 6 2 2 6
45311 - 14 14 14 195 195 195 250 250 250 253 253 253
45312 -253 253 253 253 253 253 253 253 253 253 253 253
45313 -253 253 253 253 253 253 253 253 253 253 253 253
45314 -253 253 253 253 253 253 253 253 253 253 253 253
45315 -253 253 253 253 253 253 253 253 253 253 253 253
45316 -250 250 250 242 242 242 54 54 54 2 2 6
45317 - 2 2 6 2 2 6 2 2 6 2 2 6
45318 - 2 2 6 2 2 6 2 2 6 38 38 38
45319 - 86 86 86 50 50 50 22 22 22 6 6 6
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 0 0 0 0 0 0 0 0 0
45328 - 0 0 0 0 0 0 0 0 0 0 0 0
45329 - 6 6 6 14 14 14 38 38 38 82 82 82
45330 - 34 34 34 2 2 6 2 2 6 2 2 6
45331 - 42 42 42 195 195 195 246 246 246 253 253 253
45332 -253 253 253 253 253 253 253 253 253 250 250 250
45333 -242 242 242 242 242 242 250 250 250 253 253 253
45334 -253 253 253 253 253 253 253 253 253 253 253 253
45335 -253 253 253 250 250 250 246 246 246 238 238 238
45336 -226 226 226 231 231 231 101 101 101 6 6 6
45337 - 2 2 6 2 2 6 2 2 6 2 2 6
45338 - 2 2 6 2 2 6 2 2 6 2 2 6
45339 - 38 38 38 82 82 82 42 42 42 14 14 14
45340 - 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45348 - 0 0 0 0 0 0 0 0 0 0 0 0
45349 - 10 10 10 26 26 26 62 62 62 66 66 66
45350 - 2 2 6 2 2 6 2 2 6 6 6 6
45351 - 70 70 70 170 170 170 206 206 206 234 234 234
45352 -246 246 246 250 250 250 250 250 250 238 238 238
45353 -226 226 226 231 231 231 238 238 238 250 250 250
45354 -250 250 250 250 250 250 246 246 246 231 231 231
45355 -214 214 214 206 206 206 202 202 202 202 202 202
45356 -198 198 198 202 202 202 182 182 182 18 18 18
45357 - 2 2 6 2 2 6 2 2 6 2 2 6
45358 - 2 2 6 2 2 6 2 2 6 2 2 6
45359 - 2 2 6 62 62 62 66 66 66 30 30 30
45360 - 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45368 - 0 0 0 0 0 0 0 0 0 0 0 0
45369 - 14 14 14 42 42 42 82 82 82 18 18 18
45370 - 2 2 6 2 2 6 2 2 6 10 10 10
45371 - 94 94 94 182 182 182 218 218 218 242 242 242
45372 -250 250 250 253 253 253 253 253 253 250 250 250
45373 -234 234 234 253 253 253 253 253 253 253 253 253
45374 -253 253 253 253 253 253 253 253 253 246 246 246
45375 -238 238 238 226 226 226 210 210 210 202 202 202
45376 -195 195 195 195 195 195 210 210 210 158 158 158
45377 - 6 6 6 14 14 14 50 50 50 14 14 14
45378 - 2 2 6 2 2 6 2 2 6 2 2 6
45379 - 2 2 6 6 6 6 86 86 86 46 46 46
45380 - 18 18 18 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45388 - 0 0 0 0 0 0 0 0 0 6 6 6
45389 - 22 22 22 54 54 54 70 70 70 2 2 6
45390 - 2 2 6 10 10 10 2 2 6 22 22 22
45391 -166 166 166 231 231 231 250 250 250 253 253 253
45392 -253 253 253 253 253 253 253 253 253 250 250 250
45393 -242 242 242 253 253 253 253 253 253 253 253 253
45394 -253 253 253 253 253 253 253 253 253 253 253 253
45395 -253 253 253 253 253 253 253 253 253 246 246 246
45396 -231 231 231 206 206 206 198 198 198 226 226 226
45397 - 94 94 94 2 2 6 6 6 6 38 38 38
45398 - 30 30 30 2 2 6 2 2 6 2 2 6
45399 - 2 2 6 2 2 6 62 62 62 66 66 66
45400 - 26 26 26 10 10 10 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 0 0 0
45407 - 0 0 0 0 0 0 0 0 0 0 0 0
45408 - 0 0 0 0 0 0 0 0 0 10 10 10
45409 - 30 30 30 74 74 74 50 50 50 2 2 6
45410 - 26 26 26 26 26 26 2 2 6 106 106 106
45411 -238 238 238 253 253 253 253 253 253 253 253 253
45412 -253 253 253 253 253 253 253 253 253 253 253 253
45413 -253 253 253 253 253 253 253 253 253 253 253 253
45414 -253 253 253 253 253 253 253 253 253 253 253 253
45415 -253 253 253 253 253 253 253 253 253 253 253 253
45416 -253 253 253 246 246 246 218 218 218 202 202 202
45417 -210 210 210 14 14 14 2 2 6 2 2 6
45418 - 30 30 30 22 22 22 2 2 6 2 2 6
45419 - 2 2 6 2 2 6 18 18 18 86 86 86
45420 - 42 42 42 14 14 14 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 0 0 0
45427 - 0 0 0 0 0 0 0 0 0 0 0 0
45428 - 0 0 0 0 0 0 0 0 0 14 14 14
45429 - 42 42 42 90 90 90 22 22 22 2 2 6
45430 - 42 42 42 2 2 6 18 18 18 218 218 218
45431 -253 253 253 253 253 253 253 253 253 253 253 253
45432 -253 253 253 253 253 253 253 253 253 253 253 253
45433 -253 253 253 253 253 253 253 253 253 253 253 253
45434 -253 253 253 253 253 253 253 253 253 253 253 253
45435 -253 253 253 253 253 253 253 253 253 253 253 253
45436 -253 253 253 253 253 253 250 250 250 221 221 221
45437 -218 218 218 101 101 101 2 2 6 14 14 14
45438 - 18 18 18 38 38 38 10 10 10 2 2 6
45439 - 2 2 6 2 2 6 2 2 6 78 78 78
45440 - 58 58 58 22 22 22 6 6 6 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 0 0 0
45447 - 0 0 0 0 0 0 0 0 0 0 0 0
45448 - 0 0 0 0 0 0 6 6 6 18 18 18
45449 - 54 54 54 82 82 82 2 2 6 26 26 26
45450 - 22 22 22 2 2 6 123 123 123 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 253 253 253 253 253 253
45455 -253 253 253 253 253 253 253 253 253 253 253 253
45456 -253 253 253 253 253 253 253 253 253 250 250 250
45457 -238 238 238 198 198 198 6 6 6 38 38 38
45458 - 58 58 58 26 26 26 38 38 38 2 2 6
45459 - 2 2 6 2 2 6 2 2 6 46 46 46
45460 - 78 78 78 30 30 30 10 10 10 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 0 0 0 0 0 0
45467 - 0 0 0 0 0 0 0 0 0 0 0 0
45468 - 0 0 0 0 0 0 10 10 10 30 30 30
45469 - 74 74 74 58 58 58 2 2 6 42 42 42
45470 - 2 2 6 22 22 22 231 231 231 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 250 250 250
45473 -253 253 253 253 253 253 253 253 253 253 253 253
45474 -253 253 253 253 253 253 253 253 253 253 253 253
45475 -253 253 253 253 253 253 253 253 253 253 253 253
45476 -253 253 253 253 253 253 253 253 253 253 253 253
45477 -253 253 253 246 246 246 46 46 46 38 38 38
45478 - 42 42 42 14 14 14 38 38 38 14 14 14
45479 - 2 2 6 2 2 6 2 2 6 6 6 6
45480 - 86 86 86 46 46 46 14 14 14 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 0 0 0 0 0 0
45487 - 0 0 0 0 0 0 0 0 0 0 0 0
45488 - 0 0 0 6 6 6 14 14 14 42 42 42
45489 - 90 90 90 18 18 18 18 18 18 26 26 26
45490 - 2 2 6 116 116 116 253 253 253 253 253 253
45491 -253 253 253 253 253 253 253 253 253 253 253 253
45492 -253 253 253 253 253 253 250 250 250 238 238 238
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 253 253 253 253 253 253 253 253 253
45496 -253 253 253 253 253 253 253 253 253 253 253 253
45497 -253 253 253 253 253 253 94 94 94 6 6 6
45498 - 2 2 6 2 2 6 10 10 10 34 34 34
45499 - 2 2 6 2 2 6 2 2 6 2 2 6
45500 - 74 74 74 58 58 58 22 22 22 6 6 6
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 0 0 0 0 0 0 0 0 0
45507 - 0 0 0 0 0 0 0 0 0 0 0 0
45508 - 0 0 0 10 10 10 26 26 26 66 66 66
45509 - 82 82 82 2 2 6 38 38 38 6 6 6
45510 - 14 14 14 210 210 210 253 253 253 253 253 253
45511 -253 253 253 253 253 253 253 253 253 253 253 253
45512 -253 253 253 253 253 253 246 246 246 242 242 242
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 253 253 253 253 253 253
45516 -253 253 253 253 253 253 253 253 253 253 253 253
45517 -253 253 253 253 253 253 144 144 144 2 2 6
45518 - 2 2 6 2 2 6 2 2 6 46 46 46
45519 - 2 2 6 2 2 6 2 2 6 2 2 6
45520 - 42 42 42 74 74 74 30 30 30 10 10 10
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 0 0 0 0 0 0 0 0 0
45527 - 0 0 0 0 0 0 0 0 0 0 0 0
45528 - 6 6 6 14 14 14 42 42 42 90 90 90
45529 - 26 26 26 6 6 6 42 42 42 2 2 6
45530 - 74 74 74 250 250 250 253 253 253 253 253 253
45531 -253 253 253 253 253 253 253 253 253 253 253 253
45532 -253 253 253 253 253 253 242 242 242 242 242 242
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 253 253 253 253 253 253
45536 -253 253 253 253 253 253 253 253 253 253 253 253
45537 -253 253 253 253 253 253 182 182 182 2 2 6
45538 - 2 2 6 2 2 6 2 2 6 46 46 46
45539 - 2 2 6 2 2 6 2 2 6 2 2 6
45540 - 10 10 10 86 86 86 38 38 38 10 10 10
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 - 0 0 0 0 0 0 0 0 0 0 0 0
45547 - 0 0 0 0 0 0 0 0 0 0 0 0
45548 - 10 10 10 26 26 26 66 66 66 82 82 82
45549 - 2 2 6 22 22 22 18 18 18 2 2 6
45550 -149 149 149 253 253 253 253 253 253 253 253 253
45551 -253 253 253 253 253 253 253 253 253 253 253 253
45552 -253 253 253 253 253 253 234 234 234 242 242 242
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 253 253 253 253 253 253
45556 -253 253 253 253 253 253 253 253 253 253 253 253
45557 -253 253 253 253 253 253 206 206 206 2 2 6
45558 - 2 2 6 2 2 6 2 2 6 38 38 38
45559 - 2 2 6 2 2 6 2 2 6 2 2 6
45560 - 6 6 6 86 86 86 46 46 46 14 14 14
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 - 0 0 0 0 0 0 0 0 0 0 0 0
45567 - 0 0 0 0 0 0 0 0 0 6 6 6
45568 - 18 18 18 46 46 46 86 86 86 18 18 18
45569 - 2 2 6 34 34 34 10 10 10 6 6 6
45570 -210 210 210 253 253 253 253 253 253 253 253 253
45571 -253 253 253 253 253 253 253 253 253 253 253 253
45572 -253 253 253 253 253 253 234 234 234 242 242 242
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 253 253 253 253 253 253
45576 -253 253 253 253 253 253 253 253 253 253 253 253
45577 -253 253 253 253 253 253 221 221 221 6 6 6
45578 - 2 2 6 2 2 6 6 6 6 30 30 30
45579 - 2 2 6 2 2 6 2 2 6 2 2 6
45580 - 2 2 6 82 82 82 54 54 54 18 18 18
45581 - 6 6 6 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 0 0 0
45586 - 0 0 0 0 0 0 0 0 0 0 0 0
45587 - 0 0 0 0 0 0 0 0 0 10 10 10
45588 - 26 26 26 66 66 66 62 62 62 2 2 6
45589 - 2 2 6 38 38 38 10 10 10 26 26 26
45590 -238 238 238 253 253 253 253 253 253 253 253 253
45591 -253 253 253 253 253 253 253 253 253 253 253 253
45592 -253 253 253 253 253 253 231 231 231 238 238 238
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 253 253 253 253 253 253
45596 -253 253 253 253 253 253 253 253 253 253 253 253
45597 -253 253 253 253 253 253 231 231 231 6 6 6
45598 - 2 2 6 2 2 6 10 10 10 30 30 30
45599 - 2 2 6 2 2 6 2 2 6 2 2 6
45600 - 2 2 6 66 66 66 58 58 58 22 22 22
45601 - 6 6 6 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 0 0 0
45606 - 0 0 0 0 0 0 0 0 0 0 0 0
45607 - 0 0 0 0 0 0 0 0 0 10 10 10
45608 - 38 38 38 78 78 78 6 6 6 2 2 6
45609 - 2 2 6 46 46 46 14 14 14 42 42 42
45610 -246 246 246 253 253 253 253 253 253 253 253 253
45611 -253 253 253 253 253 253 253 253 253 253 253 253
45612 -253 253 253 253 253 253 231 231 231 242 242 242
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 253 253 253 253 253 253
45616 -253 253 253 253 253 253 253 253 253 253 253 253
45617 -253 253 253 253 253 253 234 234 234 10 10 10
45618 - 2 2 6 2 2 6 22 22 22 14 14 14
45619 - 2 2 6 2 2 6 2 2 6 2 2 6
45620 - 2 2 6 66 66 66 62 62 62 22 22 22
45621 - 6 6 6 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 0 0 0
45626 - 0 0 0 0 0 0 0 0 0 0 0 0
45627 - 0 0 0 0 0 0 6 6 6 18 18 18
45628 - 50 50 50 74 74 74 2 2 6 2 2 6
45629 - 14 14 14 70 70 70 34 34 34 62 62 62
45630 -250 250 250 253 253 253 253 253 253 253 253 253
45631 -253 253 253 253 253 253 253 253 253 253 253 253
45632 -253 253 253 253 253 253 231 231 231 246 246 246
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 253 253 253 253 253 253
45636 -253 253 253 253 253 253 253 253 253 253 253 253
45637 -253 253 253 253 253 253 234 234 234 14 14 14
45638 - 2 2 6 2 2 6 30 30 30 2 2 6
45639 - 2 2 6 2 2 6 2 2 6 2 2 6
45640 - 2 2 6 66 66 66 62 62 62 22 22 22
45641 - 6 6 6 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 0 0 0 0 0 0
45646 - 0 0 0 0 0 0 0 0 0 0 0 0
45647 - 0 0 0 0 0 0 6 6 6 18 18 18
45648 - 54 54 54 62 62 62 2 2 6 2 2 6
45649 - 2 2 6 30 30 30 46 46 46 70 70 70
45650 -250 250 250 253 253 253 253 253 253 253 253 253
45651 -253 253 253 253 253 253 253 253 253 253 253 253
45652 -253 253 253 253 253 253 231 231 231 246 246 246
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 253 253 253 253 253 253
45656 -253 253 253 253 253 253 253 253 253 253 253 253
45657 -253 253 253 253 253 253 226 226 226 10 10 10
45658 - 2 2 6 6 6 6 30 30 30 2 2 6
45659 - 2 2 6 2 2 6 2 2 6 2 2 6
45660 - 2 2 6 66 66 66 58 58 58 22 22 22
45661 - 6 6 6 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 0 0 0 0 0 0
45666 - 0 0 0 0 0 0 0 0 0 0 0 0
45667 - 0 0 0 0 0 0 6 6 6 22 22 22
45668 - 58 58 58 62 62 62 2 2 6 2 2 6
45669 - 2 2 6 2 2 6 30 30 30 78 78 78
45670 -250 250 250 253 253 253 253 253 253 253 253 253
45671 -253 253 253 253 253 253 253 253 253 253 253 253
45672 -253 253 253 253 253 253 231 231 231 246 246 246
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 253 253 253 253 253 253
45676 -253 253 253 253 253 253 253 253 253 253 253 253
45677 -253 253 253 253 253 253 206 206 206 2 2 6
45678 - 22 22 22 34 34 34 18 14 6 22 22 22
45679 - 26 26 26 18 18 18 6 6 6 2 2 6
45680 - 2 2 6 82 82 82 54 54 54 18 18 18
45681 - 6 6 6 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 0 0 0 0 0 0
45686 - 0 0 0 0 0 0 0 0 0 0 0 0
45687 - 0 0 0 0 0 0 6 6 6 26 26 26
45688 - 62 62 62 106 106 106 74 54 14 185 133 11
45689 -210 162 10 121 92 8 6 6 6 62 62 62
45690 -238 238 238 253 253 253 253 253 253 253 253 253
45691 -253 253 253 253 253 253 253 253 253 253 253 253
45692 -253 253 253 253 253 253 231 231 231 246 246 246
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 253 253 253 253 253 253
45696 -253 253 253 253 253 253 253 253 253 253 253 253
45697 -253 253 253 253 253 253 158 158 158 18 18 18
45698 - 14 14 14 2 2 6 2 2 6 2 2 6
45699 - 6 6 6 18 18 18 66 66 66 38 38 38
45700 - 6 6 6 94 94 94 50 50 50 18 18 18
45701 - 6 6 6 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 0 0 0 0 0 0
45706 - 0 0 0 0 0 0 0 0 0 6 6 6
45707 - 10 10 10 10 10 10 18 18 18 38 38 38
45708 - 78 78 78 142 134 106 216 158 10 242 186 14
45709 -246 190 14 246 190 14 156 118 10 10 10 10
45710 - 90 90 90 238 238 238 253 253 253 253 253 253
45711 -253 253 253 253 253 253 253 253 253 253 253 253
45712 -253 253 253 253 253 253 231 231 231 250 250 250
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 253 253 253 253 253 253
45716 -253 253 253 253 253 253 253 253 253 246 230 190
45717 -238 204 91 238 204 91 181 142 44 37 26 9
45718 - 2 2 6 2 2 6 2 2 6 2 2 6
45719 - 2 2 6 2 2 6 38 38 38 46 46 46
45720 - 26 26 26 106 106 106 54 54 54 18 18 18
45721 - 6 6 6 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 0 0 0
45725 - 0 0 0 0 0 0 0 0 0 0 0 0
45726 - 0 0 0 6 6 6 14 14 14 22 22 22
45727 - 30 30 30 38 38 38 50 50 50 70 70 70
45728 -106 106 106 190 142 34 226 170 11 242 186 14
45729 -246 190 14 246 190 14 246 190 14 154 114 10
45730 - 6 6 6 74 74 74 226 226 226 253 253 253
45731 -253 253 253 253 253 253 253 253 253 253 253 253
45732 -253 253 253 253 253 253 231 231 231 250 250 250
45733 -253 253 253 253 253 253 253 253 253 253 253 253
45734 -253 253 253 253 253 253 253 253 253 253 253 253
45735 -253 253 253 253 253 253 253 253 253 253 253 253
45736 -253 253 253 253 253 253 253 253 253 228 184 62
45737 -241 196 14 241 208 19 232 195 16 38 30 10
45738 - 2 2 6 2 2 6 2 2 6 2 2 6
45739 - 2 2 6 6 6 6 30 30 30 26 26 26
45740 -203 166 17 154 142 90 66 66 66 26 26 26
45741 - 6 6 6 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 0 0 0 0 0 0 0 0 0
45745 - 0 0 0 0 0 0 0 0 0 0 0 0
45746 - 6 6 6 18 18 18 38 38 38 58 58 58
45747 - 78 78 78 86 86 86 101 101 101 123 123 123
45748 -175 146 61 210 150 10 234 174 13 246 186 14
45749 -246 190 14 246 190 14 246 190 14 238 190 10
45750 -102 78 10 2 2 6 46 46 46 198 198 198
45751 -253 253 253 253 253 253 253 253 253 253 253 253
45752 -253 253 253 253 253 253 234 234 234 242 242 242
45753 -253 253 253 253 253 253 253 253 253 253 253 253
45754 -253 253 253 253 253 253 253 253 253 253 253 253
45755 -253 253 253 253 253 253 253 253 253 253 253 253
45756 -253 253 253 253 253 253 253 253 253 224 178 62
45757 -242 186 14 241 196 14 210 166 10 22 18 6
45758 - 2 2 6 2 2 6 2 2 6 2 2 6
45759 - 2 2 6 2 2 6 6 6 6 121 92 8
45760 -238 202 15 232 195 16 82 82 82 34 34 34
45761 - 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45765 - 0 0 0 0 0 0 0 0 0 0 0 0
45766 - 14 14 14 38 38 38 70 70 70 154 122 46
45767 -190 142 34 200 144 11 197 138 11 197 138 11
45768 -213 154 11 226 170 11 242 186 14 246 190 14
45769 -246 190 14 246 190 14 246 190 14 246 190 14
45770 -225 175 15 46 32 6 2 2 6 22 22 22
45771 -158 158 158 250 250 250 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 253 253 253
45775 -253 253 253 253 253 253 253 253 253 253 253 253
45776 -253 253 253 250 250 250 242 242 242 224 178 62
45777 -239 182 13 236 186 11 213 154 11 46 32 6
45778 - 2 2 6 2 2 6 2 2 6 2 2 6
45779 - 2 2 6 2 2 6 61 42 6 225 175 15
45780 -238 190 10 236 186 11 112 100 78 42 42 42
45781 - 14 14 14 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45785 - 0 0 0 0 0 0 0 0 0 6 6 6
45786 - 22 22 22 54 54 54 154 122 46 213 154 11
45787 -226 170 11 230 174 11 226 170 11 226 170 11
45788 -236 178 12 242 186 14 246 190 14 246 190 14
45789 -246 190 14 246 190 14 246 190 14 246 190 14
45790 -241 196 14 184 144 12 10 10 10 2 2 6
45791 - 6 6 6 116 116 116 242 242 242 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 253 253 253 253 253 253 253 253 253
45795 -253 253 253 253 253 253 253 253 253 253 253 253
45796 -253 253 253 231 231 231 198 198 198 214 170 54
45797 -236 178 12 236 178 12 210 150 10 137 92 6
45798 - 18 14 6 2 2 6 2 2 6 2 2 6
45799 - 6 6 6 70 47 6 200 144 11 236 178 12
45800 -239 182 13 239 182 13 124 112 88 58 58 58
45801 - 22 22 22 6 6 6 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 0 0 0
45804 - 0 0 0 0 0 0 0 0 0 0 0 0
45805 - 0 0 0 0 0 0 0 0 0 10 10 10
45806 - 30 30 30 70 70 70 180 133 36 226 170 11
45807 -239 182 13 242 186 14 242 186 14 246 186 14
45808 -246 190 14 246 190 14 246 190 14 246 190 14
45809 -246 190 14 246 190 14 246 190 14 246 190 14
45810 -246 190 14 232 195 16 98 70 6 2 2 6
45811 - 2 2 6 2 2 6 66 66 66 221 221 221
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 253 253 253 253 253 253 253 253 253
45815 -253 253 253 253 253 253 253 253 253 253 253 253
45816 -253 253 253 206 206 206 198 198 198 214 166 58
45817 -230 174 11 230 174 11 216 158 10 192 133 9
45818 -163 110 8 116 81 8 102 78 10 116 81 8
45819 -167 114 7 197 138 11 226 170 11 239 182 13
45820 -242 186 14 242 186 14 162 146 94 78 78 78
45821 - 34 34 34 14 14 14 6 6 6 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 0 0 0
45824 - 0 0 0 0 0 0 0 0 0 0 0 0
45825 - 0 0 0 0 0 0 0 0 0 6 6 6
45826 - 30 30 30 78 78 78 190 142 34 226 170 11
45827 -239 182 13 246 190 14 246 190 14 246 190 14
45828 -246 190 14 246 190 14 246 190 14 246 190 14
45829 -246 190 14 246 190 14 246 190 14 246 190 14
45830 -246 190 14 241 196 14 203 166 17 22 18 6
45831 - 2 2 6 2 2 6 2 2 6 38 38 38
45832 -218 218 218 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 253 253 253 253 253 253 253 253 253
45835 -253 253 253 253 253 253 253 253 253 253 253 253
45836 -250 250 250 206 206 206 198 198 198 202 162 69
45837 -226 170 11 236 178 12 224 166 10 210 150 10
45838 -200 144 11 197 138 11 192 133 9 197 138 11
45839 -210 150 10 226 170 11 242 186 14 246 190 14
45840 -246 190 14 246 186 14 225 175 15 124 112 88
45841 - 62 62 62 30 30 30 14 14 14 6 6 6
45842 - 0 0 0 0 0 0 0 0 0 0 0 0
45843 - 0 0 0 0 0 0 0 0 0 0 0 0
45844 - 0 0 0 0 0 0 0 0 0 0 0 0
45845 - 0 0 0 0 0 0 0 0 0 10 10 10
45846 - 30 30 30 78 78 78 174 135 50 224 166 10
45847 -239 182 13 246 190 14 246 190 14 246 190 14
45848 -246 190 14 246 190 14 246 190 14 246 190 14
45849 -246 190 14 246 190 14 246 190 14 246 190 14
45850 -246 190 14 246 190 14 241 196 14 139 102 15
45851 - 2 2 6 2 2 6 2 2 6 2 2 6
45852 - 78 78 78 250 250 250 253 253 253 253 253 253
45853 -253 253 253 253 253 253 253 253 253 253 253 253
45854 -253 253 253 253 253 253 253 253 253 253 253 253
45855 -253 253 253 253 253 253 253 253 253 253 253 253
45856 -250 250 250 214 214 214 198 198 198 190 150 46
45857 -219 162 10 236 178 12 234 174 13 224 166 10
45858 -216 158 10 213 154 11 213 154 11 216 158 10
45859 -226 170 11 239 182 13 246 190 14 246 190 14
45860 -246 190 14 246 190 14 242 186 14 206 162 42
45861 -101 101 101 58 58 58 30 30 30 14 14 14
45862 - 6 6 6 0 0 0 0 0 0 0 0 0
45863 - 0 0 0 0 0 0 0 0 0 0 0 0
45864 - 0 0 0 0 0 0 0 0 0 0 0 0
45865 - 0 0 0 0 0 0 0 0 0 10 10 10
45866 - 30 30 30 74 74 74 174 135 50 216 158 10
45867 -236 178 12 246 190 14 246 190 14 246 190 14
45868 -246 190 14 246 190 14 246 190 14 246 190 14
45869 -246 190 14 246 190 14 246 190 14 246 190 14
45870 -246 190 14 246 190 14 241 196 14 226 184 13
45871 - 61 42 6 2 2 6 2 2 6 2 2 6
45872 - 22 22 22 238 238 238 253 253 253 253 253 253
45873 -253 253 253 253 253 253 253 253 253 253 253 253
45874 -253 253 253 253 253 253 253 253 253 253 253 253
45875 -253 253 253 253 253 253 253 253 253 253 253 253
45876 -253 253 253 226 226 226 187 187 187 180 133 36
45877 -216 158 10 236 178 12 239 182 13 236 178 12
45878 -230 174 11 226 170 11 226 170 11 230 174 11
45879 -236 178 12 242 186 14 246 190 14 246 190 14
45880 -246 190 14 246 190 14 246 186 14 239 182 13
45881 -206 162 42 106 106 106 66 66 66 34 34 34
45882 - 14 14 14 6 6 6 0 0 0 0 0 0
45883 - 0 0 0 0 0 0 0 0 0 0 0 0
45884 - 0 0 0 0 0 0 0 0 0 0 0 0
45885 - 0 0 0 0 0 0 0 0 0 6 6 6
45886 - 26 26 26 70 70 70 163 133 67 213 154 11
45887 -236 178 12 246 190 14 246 190 14 246 190 14
45888 -246 190 14 246 190 14 246 190 14 246 190 14
45889 -246 190 14 246 190 14 246 190 14 246 190 14
45890 -246 190 14 246 190 14 246 190 14 241 196 14
45891 -190 146 13 18 14 6 2 2 6 2 2 6
45892 - 46 46 46 246 246 246 253 253 253 253 253 253
45893 -253 253 253 253 253 253 253 253 253 253 253 253
45894 -253 253 253 253 253 253 253 253 253 253 253 253
45895 -253 253 253 253 253 253 253 253 253 253 253 253
45896 -253 253 253 221 221 221 86 86 86 156 107 11
45897 -216 158 10 236 178 12 242 186 14 246 186 14
45898 -242 186 14 239 182 13 239 182 13 242 186 14
45899 -242 186 14 246 186 14 246 190 14 246 190 14
45900 -246 190 14 246 190 14 246 190 14 246 190 14
45901 -242 186 14 225 175 15 142 122 72 66 66 66
45902 - 30 30 30 10 10 10 0 0 0 0 0 0
45903 - 0 0 0 0 0 0 0 0 0 0 0 0
45904 - 0 0 0 0 0 0 0 0 0 0 0 0
45905 - 0 0 0 0 0 0 0 0 0 6 6 6
45906 - 26 26 26 70 70 70 163 133 67 210 150 10
45907 -236 178 12 246 190 14 246 190 14 246 190 14
45908 -246 190 14 246 190 14 246 190 14 246 190 14
45909 -246 190 14 246 190 14 246 190 14 246 190 14
45910 -246 190 14 246 190 14 246 190 14 246 190 14
45911 -232 195 16 121 92 8 34 34 34 106 106 106
45912 -221 221 221 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 253 253 253 253 253 253 253 253 253
45915 -253 253 253 253 253 253 253 253 253 253 253 253
45916 -242 242 242 82 82 82 18 14 6 163 110 8
45917 -216 158 10 236 178 12 242 186 14 246 190 14
45918 -246 190 14 246 190 14 246 190 14 246 190 14
45919 -246 190 14 246 190 14 246 190 14 246 190 14
45920 -246 190 14 246 190 14 246 190 14 246 190 14
45921 -246 190 14 246 190 14 242 186 14 163 133 67
45922 - 46 46 46 18 18 18 6 6 6 0 0 0
45923 - 0 0 0 0 0 0 0 0 0 0 0 0
45924 - 0 0 0 0 0 0 0 0 0 0 0 0
45925 - 0 0 0 0 0 0 0 0 0 10 10 10
45926 - 30 30 30 78 78 78 163 133 67 210 150 10
45927 -236 178 12 246 186 14 246 190 14 246 190 14
45928 -246 190 14 246 190 14 246 190 14 246 190 14
45929 -246 190 14 246 190 14 246 190 14 246 190 14
45930 -246 190 14 246 190 14 246 190 14 246 190 14
45931 -241 196 14 215 174 15 190 178 144 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 -253 253 253 253 253 253 253 253 253 253 253 253
45935 -253 253 253 253 253 253 253 253 253 218 218 218
45936 - 58 58 58 2 2 6 22 18 6 167 114 7
45937 -216 158 10 236 178 12 246 186 14 246 190 14
45938 -246 190 14 246 190 14 246 190 14 246 190 14
45939 -246 190 14 246 190 14 246 190 14 246 190 14
45940 -246 190 14 246 190 14 246 190 14 246 190 14
45941 -246 190 14 246 186 14 242 186 14 190 150 46
45942 - 54 54 54 22 22 22 6 6 6 0 0 0
45943 - 0 0 0 0 0 0 0 0 0 0 0 0
45944 - 0 0 0 0 0 0 0 0 0 0 0 0
45945 - 0 0 0 0 0 0 0 0 0 14 14 14
45946 - 38 38 38 86 86 86 180 133 36 213 154 11
45947 -236 178 12 246 186 14 246 190 14 246 190 14
45948 -246 190 14 246 190 14 246 190 14 246 190 14
45949 -246 190 14 246 190 14 246 190 14 246 190 14
45950 -246 190 14 246 190 14 246 190 14 246 190 14
45951 -246 190 14 232 195 16 190 146 13 214 214 214
45952 -253 253 253 253 253 253 253 253 253 253 253 253
45953 -253 253 253 253 253 253 253 253 253 253 253 253
45954 -253 253 253 253 253 253 253 253 253 253 253 253
45955 -253 253 253 250 250 250 170 170 170 26 26 26
45956 - 2 2 6 2 2 6 37 26 9 163 110 8
45957 -219 162 10 239 182 13 246 186 14 246 190 14
45958 -246 190 14 246 190 14 246 190 14 246 190 14
45959 -246 190 14 246 190 14 246 190 14 246 190 14
45960 -246 190 14 246 190 14 246 190 14 246 190 14
45961 -246 186 14 236 178 12 224 166 10 142 122 72
45962 - 46 46 46 18 18 18 6 6 6 0 0 0
45963 - 0 0 0 0 0 0 0 0 0 0 0 0
45964 - 0 0 0 0 0 0 0 0 0 0 0 0
45965 - 0 0 0 0 0 0 6 6 6 18 18 18
45966 - 50 50 50 109 106 95 192 133 9 224 166 10
45967 -242 186 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 246 190 14 246 190 14 246 190 14
45970 -246 190 14 246 190 14 246 190 14 246 190 14
45971 -242 186 14 226 184 13 210 162 10 142 110 46
45972 -226 226 226 253 253 253 253 253 253 253 253 253
45973 -253 253 253 253 253 253 253 253 253 253 253 253
45974 -253 253 253 253 253 253 253 253 253 253 253 253
45975 -198 198 198 66 66 66 2 2 6 2 2 6
45976 - 2 2 6 2 2 6 50 34 6 156 107 11
45977 -219 162 10 239 182 13 246 186 14 246 190 14
45978 -246 190 14 246 190 14 246 190 14 246 190 14
45979 -246 190 14 246 190 14 246 190 14 246 190 14
45980 -246 190 14 246 190 14 246 190 14 242 186 14
45981 -234 174 13 213 154 11 154 122 46 66 66 66
45982 - 30 30 30 10 10 10 0 0 0 0 0 0
45983 - 0 0 0 0 0 0 0 0 0 0 0 0
45984 - 0 0 0 0 0 0 0 0 0 0 0 0
45985 - 0 0 0 0 0 0 6 6 6 22 22 22
45986 - 58 58 58 154 121 60 206 145 10 234 174 13
45987 -242 186 14 246 186 14 246 190 14 246 190 14
45988 -246 190 14 246 190 14 246 190 14 246 190 14
45989 -246 190 14 246 190 14 246 190 14 246 190 14
45990 -246 190 14 246 190 14 246 190 14 246 190 14
45991 -246 186 14 236 178 12 210 162 10 163 110 8
45992 - 61 42 6 138 138 138 218 218 218 250 250 250
45993 -253 253 253 253 253 253 253 253 253 250 250 250
45994 -242 242 242 210 210 210 144 144 144 66 66 66
45995 - 6 6 6 2 2 6 2 2 6 2 2 6
45996 - 2 2 6 2 2 6 61 42 6 163 110 8
45997 -216 158 10 236 178 12 246 190 14 246 190 14
45998 -246 190 14 246 190 14 246 190 14 246 190 14
45999 -246 190 14 246 190 14 246 190 14 246 190 14
46000 -246 190 14 239 182 13 230 174 11 216 158 10
46001 -190 142 34 124 112 88 70 70 70 38 38 38
46002 - 18 18 18 6 6 6 0 0 0 0 0 0
46003 - 0 0 0 0 0 0 0 0 0 0 0 0
46004 - 0 0 0 0 0 0 0 0 0 0 0 0
46005 - 0 0 0 0 0 0 6 6 6 22 22 22
46006 - 62 62 62 168 124 44 206 145 10 224 166 10
46007 -236 178 12 239 182 13 242 186 14 242 186 14
46008 -246 186 14 246 190 14 246 190 14 246 190 14
46009 -246 190 14 246 190 14 246 190 14 246 190 14
46010 -246 190 14 246 190 14 246 190 14 246 190 14
46011 -246 190 14 236 178 12 216 158 10 175 118 6
46012 - 80 54 7 2 2 6 6 6 6 30 30 30
46013 - 54 54 54 62 62 62 50 50 50 38 38 38
46014 - 14 14 14 2 2 6 2 2 6 2 2 6
46015 - 2 2 6 2 2 6 2 2 6 2 2 6
46016 - 2 2 6 6 6 6 80 54 7 167 114 7
46017 -213 154 11 236 178 12 246 190 14 246 190 14
46018 -246 190 14 246 190 14 246 190 14 246 190 14
46019 -246 190 14 242 186 14 239 182 13 239 182 13
46020 -230 174 11 210 150 10 174 135 50 124 112 88
46021 - 82 82 82 54 54 54 34 34 34 18 18 18
46022 - 6 6 6 0 0 0 0 0 0 0 0 0
46023 - 0 0 0 0 0 0 0 0 0 0 0 0
46024 - 0 0 0 0 0 0 0 0 0 0 0 0
46025 - 0 0 0 0 0 0 6 6 6 18 18 18
46026 - 50 50 50 158 118 36 192 133 9 200 144 11
46027 -216 158 10 219 162 10 224 166 10 226 170 11
46028 -230 174 11 236 178 12 239 182 13 239 182 13
46029 -242 186 14 246 186 14 246 190 14 246 190 14
46030 -246 190 14 246 190 14 246 190 14 246 190 14
46031 -246 186 14 230 174 11 210 150 10 163 110 8
46032 -104 69 6 10 10 10 2 2 6 2 2 6
46033 - 2 2 6 2 2 6 2 2 6 2 2 6
46034 - 2 2 6 2 2 6 2 2 6 2 2 6
46035 - 2 2 6 2 2 6 2 2 6 2 2 6
46036 - 2 2 6 6 6 6 91 60 6 167 114 7
46037 -206 145 10 230 174 11 242 186 14 246 190 14
46038 -246 190 14 246 190 14 246 186 14 242 186 14
46039 -239 182 13 230 174 11 224 166 10 213 154 11
46040 -180 133 36 124 112 88 86 86 86 58 58 58
46041 - 38 38 38 22 22 22 10 10 10 6 6 6
46042 - 0 0 0 0 0 0 0 0 0 0 0 0
46043 - 0 0 0 0 0 0 0 0 0 0 0 0
46044 - 0 0 0 0 0 0 0 0 0 0 0 0
46045 - 0 0 0 0 0 0 0 0 0 14 14 14
46046 - 34 34 34 70 70 70 138 110 50 158 118 36
46047 -167 114 7 180 123 7 192 133 9 197 138 11
46048 -200 144 11 206 145 10 213 154 11 219 162 10
46049 -224 166 10 230 174 11 239 182 13 242 186 14
46050 -246 186 14 246 186 14 246 186 14 246 186 14
46051 -239 182 13 216 158 10 185 133 11 152 99 6
46052 -104 69 6 18 14 6 2 2 6 2 2 6
46053 - 2 2 6 2 2 6 2 2 6 2 2 6
46054 - 2 2 6 2 2 6 2 2 6 2 2 6
46055 - 2 2 6 2 2 6 2 2 6 2 2 6
46056 - 2 2 6 6 6 6 80 54 7 152 99 6
46057 -192 133 9 219 162 10 236 178 12 239 182 13
46058 -246 186 14 242 186 14 239 182 13 236 178 12
46059 -224 166 10 206 145 10 192 133 9 154 121 60
46060 - 94 94 94 62 62 62 42 42 42 22 22 22
46061 - 14 14 14 6 6 6 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 0 0 0
46064 - 0 0 0 0 0 0 0 0 0 0 0 0
46065 - 0 0 0 0 0 0 0 0 0 6 6 6
46066 - 18 18 18 34 34 34 58 58 58 78 78 78
46067 -101 98 89 124 112 88 142 110 46 156 107 11
46068 -163 110 8 167 114 7 175 118 6 180 123 7
46069 -185 133 11 197 138 11 210 150 10 219 162 10
46070 -226 170 11 236 178 12 236 178 12 234 174 13
46071 -219 162 10 197 138 11 163 110 8 130 83 6
46072 - 91 60 6 10 10 10 2 2 6 2 2 6
46073 - 18 18 18 38 38 38 38 38 38 38 38 38
46074 - 38 38 38 38 38 38 38 38 38 38 38 38
46075 - 38 38 38 38 38 38 26 26 26 2 2 6
46076 - 2 2 6 6 6 6 70 47 6 137 92 6
46077 -175 118 6 200 144 11 219 162 10 230 174 11
46078 -234 174 13 230 174 11 219 162 10 210 150 10
46079 -192 133 9 163 110 8 124 112 88 82 82 82
46080 - 50 50 50 30 30 30 14 14 14 6 6 6
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 0 0 0
46084 - 0 0 0 0 0 0 0 0 0 0 0 0
46085 - 0 0 0 0 0 0 0 0 0 0 0 0
46086 - 6 6 6 14 14 14 22 22 22 34 34 34
46087 - 42 42 42 58 58 58 74 74 74 86 86 86
46088 -101 98 89 122 102 70 130 98 46 121 87 25
46089 -137 92 6 152 99 6 163 110 8 180 123 7
46090 -185 133 11 197 138 11 206 145 10 200 144 11
46091 -180 123 7 156 107 11 130 83 6 104 69 6
46092 - 50 34 6 54 54 54 110 110 110 101 98 89
46093 - 86 86 86 82 82 82 78 78 78 78 78 78
46094 - 78 78 78 78 78 78 78 78 78 78 78 78
46095 - 78 78 78 82 82 82 86 86 86 94 94 94
46096 -106 106 106 101 101 101 86 66 34 124 80 6
46097 -156 107 11 180 123 7 192 133 9 200 144 11
46098 -206 145 10 200 144 11 192 133 9 175 118 6
46099 -139 102 15 109 106 95 70 70 70 42 42 42
46100 - 22 22 22 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
46105 - 0 0 0 0 0 0 0 0 0 0 0 0
46106 - 0 0 0 0 0 0 6 6 6 10 10 10
46107 - 14 14 14 22 22 22 30 30 30 38 38 38
46108 - 50 50 50 62 62 62 74 74 74 90 90 90
46109 -101 98 89 112 100 78 121 87 25 124 80 6
46110 -137 92 6 152 99 6 152 99 6 152 99 6
46111 -138 86 6 124 80 6 98 70 6 86 66 30
46112 -101 98 89 82 82 82 58 58 58 46 46 46
46113 - 38 38 38 34 34 34 34 34 34 34 34 34
46114 - 34 34 34 34 34 34 34 34 34 34 34 34
46115 - 34 34 34 34 34 34 38 38 38 42 42 42
46116 - 54 54 54 82 82 82 94 86 76 91 60 6
46117 -134 86 6 156 107 11 167 114 7 175 118 6
46118 -175 118 6 167 114 7 152 99 6 121 87 25
46119 -101 98 89 62 62 62 34 34 34 18 18 18
46120 - 6 6 6 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 0 0 0 0 0 0
46125 - 0 0 0 0 0 0 0 0 0 0 0 0
46126 - 0 0 0 0 0 0 0 0 0 0 0 0
46127 - 0 0 0 6 6 6 6 6 6 10 10 10
46128 - 18 18 18 22 22 22 30 30 30 42 42 42
46129 - 50 50 50 66 66 66 86 86 86 101 98 89
46130 -106 86 58 98 70 6 104 69 6 104 69 6
46131 -104 69 6 91 60 6 82 62 34 90 90 90
46132 - 62 62 62 38 38 38 22 22 22 14 14 14
46133 - 10 10 10 10 10 10 10 10 10 10 10 10
46134 - 10 10 10 10 10 10 6 6 6 10 10 10
46135 - 10 10 10 10 10 10 10 10 10 14 14 14
46136 - 22 22 22 42 42 42 70 70 70 89 81 66
46137 - 80 54 7 104 69 6 124 80 6 137 92 6
46138 -134 86 6 116 81 8 100 82 52 86 86 86
46139 - 58 58 58 30 30 30 14 14 14 6 6 6
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 0 0 0 0 0 0 0 0 0
46146 - 0 0 0 0 0 0 0 0 0 0 0 0
46147 - 0 0 0 0 0 0 0 0 0 0 0 0
46148 - 0 0 0 6 6 6 10 10 10 14 14 14
46149 - 18 18 18 26 26 26 38 38 38 54 54 54
46150 - 70 70 70 86 86 86 94 86 76 89 81 66
46151 - 89 81 66 86 86 86 74 74 74 50 50 50
46152 - 30 30 30 14 14 14 6 6 6 0 0 0
46153 - 0 0 0 0 0 0 0 0 0 0 0 0
46154 - 0 0 0 0 0 0 0 0 0 0 0 0
46155 - 0 0 0 0 0 0 0 0 0 0 0 0
46156 - 6 6 6 18 18 18 34 34 34 58 58 58
46157 - 82 82 82 89 81 66 89 81 66 89 81 66
46158 - 94 86 66 94 86 76 74 74 74 50 50 50
46159 - 26 26 26 14 14 14 6 6 6 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 0 0 0 0 0 0 0 0 0
46167 - 0 0 0 0 0 0 0 0 0 0 0 0
46168 - 0 0 0 0 0 0 0 0 0 0 0 0
46169 - 6 6 6 6 6 6 14 14 14 18 18 18
46170 - 30 30 30 38 38 38 46 46 46 54 54 54
46171 - 50 50 50 42 42 42 30 30 30 18 18 18
46172 - 10 10 10 0 0 0 0 0 0 0 0 0
46173 - 0 0 0 0 0 0 0 0 0 0 0 0
46174 - 0 0 0 0 0 0 0 0 0 0 0 0
46175 - 0 0 0 0 0 0 0 0 0 0 0 0
46176 - 0 0 0 6 6 6 14 14 14 26 26 26
46177 - 38 38 38 50 50 50 58 58 58 58 58 58
46178 - 54 54 54 42 42 42 30 30 30 18 18 18
46179 - 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
46188 - 0 0 0 0 0 0 0 0 0 0 0 0
46189 - 0 0 0 0 0 0 0 0 0 6 6 6
46190 - 6 6 6 10 10 10 14 14 14 18 18 18
46191 - 18 18 18 14 14 14 10 10 10 6 6 6
46192 - 0 0 0 0 0 0 0 0 0 0 0 0
46193 - 0 0 0 0 0 0 0 0 0 0 0 0
46194 - 0 0 0 0 0 0 0 0 0 0 0 0
46195 - 0 0 0 0 0 0 0 0 0 0 0 0
46196 - 0 0 0 0 0 0 0 0 0 6 6 6
46197 - 14 14 14 18 18 18 22 22 22 22 22 22
46198 - 18 18 18 14 14 14 10 10 10 6 6 6
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 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46205 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46206 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46207 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46208 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46209 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46210 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46211 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46212 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46213 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46214 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46215 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46216 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46217 +4 4 4 4 4 4
46218 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46219 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46220 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46221 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
46260 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46263 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46264 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46265 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46266 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46267 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46269 +4 4 4 4 4 4 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
46274 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46277 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46278 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46279 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46281 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46282 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46283 +4 4 4 4 4 4 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
46288 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46291 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46292 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46293 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 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 1 1 1 0 0 0
46298 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46299 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
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
46302 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46305 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46306 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46307 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46308 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46309 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46310 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46311 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46312 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46313 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46314 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46315 +4 4 4 4 4 4
46316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46319 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46320 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46321 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46322 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46323 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46325 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46326 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46327 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46328 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46329 +4 4 4 4 4 4
46330 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46333 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46334 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46335 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46336 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46338 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46339 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46340 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46341 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46342 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46343 +4 4 4 4 4 4
46344 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46345 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46347 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46348 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46349 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46350 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46351 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46352 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46353 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46354 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46355 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46356 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46357 +4 4 4 4 4 4
46358 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46361 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46362 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46363 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46364 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46365 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46366 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46367 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46368 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46369 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46370 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46371 +4 4 4 4 4 4
46372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46374 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46375 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46376 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46377 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46378 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46379 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46380 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46381 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46382 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46383 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46384 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46385 +4 4 4 4 4 4
46386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46388 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46389 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46390 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46391 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46392 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46393 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46394 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46395 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46396 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46397 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46398 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46399 +4 4 4 4 4 4
46400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46402 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46403 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46404 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46405 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46406 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46407 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46408 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46409 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46410 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46411 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46412 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46413 +4 4 4 4 4 4
46414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46416 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46417 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46418 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46419 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46420 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46421 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46422 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46423 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46424 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46425 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46426 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46427 +4 4 4 4 4 4
46428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46429 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46430 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46431 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46432 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46433 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46434 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46435 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46436 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46437 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46438 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46439 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46440 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46441 +4 4 4 4 4 4
46442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46443 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46444 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46445 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46446 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46447 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46448 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46449 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46450 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46451 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46452 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46453 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46454 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46455 +0 0 0 4 4 4
46456 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46457 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46458 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46459 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46460 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46461 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46462 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46463 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46464 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46465 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46466 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46467 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46468 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46469 +2 0 0 0 0 0
46470 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46471 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46472 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46473 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46474 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46475 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46476 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46477 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46478 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46479 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46480 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46481 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46482 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46483 +37 38 37 0 0 0
46484 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46485 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46486 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46487 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46488 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46489 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46490 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46491 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46492 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46493 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46494 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46495 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46496 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46497 +85 115 134 4 0 0
46498 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46499 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46500 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46501 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46502 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46503 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46504 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46505 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46506 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46507 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46508 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46509 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46510 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46511 +60 73 81 4 0 0
46512 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46513 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46514 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46515 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46516 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46517 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46518 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46519 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46520 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46521 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46522 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46523 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46524 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46525 +16 19 21 4 0 0
46526 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46527 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46528 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46529 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46530 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46531 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46532 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46533 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46534 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46535 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46536 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46537 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46538 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46539 +4 0 0 4 3 3
46540 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46541 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46542 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46544 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46545 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46546 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46547 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46548 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
46549 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
46550 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
46551 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
46552 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
46553 +3 2 2 4 4 4
46554 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
46555 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
46556 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
46557 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46558 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
46559 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
46560 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46561 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
46562 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
46563 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
46564 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
46565 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
46566 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
46567 +4 4 4 4 4 4
46568 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
46569 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
46570 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
46571 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
46572 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
46573 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
46574 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
46575 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
46576 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
46577 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
46578 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
46579 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
46580 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
46581 +4 4 4 4 4 4
46582 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
46583 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
46584 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
46585 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
46586 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
46587 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46588 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
46589 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
46590 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
46591 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
46592 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
46593 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
46594 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
46595 +5 5 5 5 5 5
46596 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
46597 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
46598 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
46599 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
46600 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
46601 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46602 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
46603 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
46604 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
46605 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
46606 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
46607 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
46608 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46609 +5 5 5 4 4 4
46610 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
46611 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
46612 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
46613 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
46614 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46615 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
46616 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
46617 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
46618 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
46619 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
46620 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
46621 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46623 +4 4 4 4 4 4
46624 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
46625 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
46626 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
46627 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
46628 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
46629 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46630 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46631 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
46632 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
46633 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
46634 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
46635 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
46636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46637 +4 4 4 4 4 4
46638 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
46639 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
46640 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
46641 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
46642 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46643 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
46644 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
46645 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
46646 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
46647 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
46648 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
46649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46651 +4 4 4 4 4 4
46652 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
46653 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
46654 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
46655 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
46656 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46657 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46658 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46659 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
46660 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
46661 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
46662 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
46663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46665 +4 4 4 4 4 4
46666 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
46667 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
46668 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
46669 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
46670 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46671 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
46672 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46673 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
46674 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
46675 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
46676 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46679 +4 4 4 4 4 4
46680 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
46681 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
46682 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
46683 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
46684 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46685 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
46686 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
46687 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
46688 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
46689 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
46690 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
46691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46693 +4 4 4 4 4 4
46694 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
46695 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
46696 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
46697 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
46698 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46699 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
46700 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
46701 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
46702 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
46703 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
46704 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
46705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46707 +4 4 4 4 4 4
46708 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
46709 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
46710 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
46711 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46712 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
46713 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
46714 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
46715 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
46716 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
46717 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
46718 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46721 +4 4 4 4 4 4
46722 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
46723 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
46724 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
46725 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46726 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46727 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
46728 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
46729 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
46730 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
46731 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
46732 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46735 +4 4 4 4 4 4
46736 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
46737 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
46738 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46739 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46740 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46741 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
46742 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
46743 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
46744 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
46745 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
46746 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46749 +4 4 4 4 4 4
46750 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
46751 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
46752 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46753 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46754 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46755 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
46756 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
46757 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
46758 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46759 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46760 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46763 +4 4 4 4 4 4
46764 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46765 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
46766 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46767 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
46768 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
46769 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
46770 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
46771 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
46772 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46773 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46774 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46777 +4 4 4 4 4 4
46778 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46779 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
46780 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46781 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
46782 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46783 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
46784 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
46785 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
46786 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46787 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46788 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46791 +4 4 4 4 4 4
46792 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
46793 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
46794 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46795 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
46796 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
46797 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
46798 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
46799 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
46800 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46801 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46802 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46805 +4 4 4 4 4 4
46806 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
46807 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
46808 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46809 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
46810 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
46811 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
46812 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
46813 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
46814 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46815 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46816 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46819 +4 4 4 4 4 4
46820 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46821 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
46822 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46823 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
46824 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
46825 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
46826 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
46827 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
46828 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46829 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46830 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46833 +4 4 4 4 4 4
46834 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
46835 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
46836 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46837 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
46838 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
46839 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
46840 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
46841 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
46842 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
46843 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46844 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46847 +4 4 4 4 4 4
46848 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46849 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
46850 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
46851 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
46852 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
46853 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
46854 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
46855 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
46856 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46857 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46858 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46861 +4 4 4 4 4 4
46862 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46863 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
46864 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46865 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
46866 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
46867 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
46868 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
46869 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
46870 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46871 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46872 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46875 +4 4 4 4 4 4
46876 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46877 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
46878 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
46879 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
46880 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
46881 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
46882 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46883 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
46884 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46885 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46886 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46889 +4 4 4 4 4 4
46890 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46891 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
46892 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
46893 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46894 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
46895 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
46896 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46897 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
46898 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46899 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46900 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46903 +4 4 4 4 4 4
46904 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46905 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
46906 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
46907 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
46908 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
46909 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
46910 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
46911 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
46912 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
46913 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46914 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46917 +4 4 4 4 4 4
46918 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46919 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
46920 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
46921 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
46922 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
46923 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
46924 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
46925 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
46926 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
46927 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46928 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46931 +4 4 4 4 4 4
46932 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
46933 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
46934 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
46935 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
46936 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46937 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
46938 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
46939 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
46940 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
46941 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46942 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46945 +4 4 4 4 4 4
46946 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46947 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
46948 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
46949 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
46950 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
46951 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
46952 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
46953 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
46954 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
46955 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46956 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46959 +4 4 4 4 4 4
46960 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
46961 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
46962 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
46963 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
46964 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
46965 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
46966 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
46967 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
46968 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
46969 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
46970 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46973 +4 4 4 4 4 4
46974 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
46975 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46976 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
46977 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
46978 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
46979 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
46980 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
46981 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
46982 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
46983 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
46984 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46987 +4 4 4 4 4 4
46988 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
46989 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46990 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
46991 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
46992 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
46993 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
46994 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46995 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
46996 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
46997 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
46998 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47001 +4 4 4 4 4 4
47002 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47003 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47004 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47005 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47006 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47007 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47008 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47009 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47010 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47011 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47012 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47015 +4 4 4 4 4 4
47016 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47017 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47018 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47019 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47020 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47021 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47022 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47023 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47024 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47025 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47026 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47029 +4 4 4 4 4 4
47030 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47031 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47032 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47033 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47034 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47035 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47036 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47037 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47038 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47039 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47040 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47043 +4 4 4 4 4 4
47044 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47045 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47046 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47047 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47048 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47049 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47050 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47051 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47052 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47053 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47054 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47057 +4 4 4 4 4 4
47058 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47059 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47060 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47061 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47062 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47063 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47064 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47065 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47066 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47067 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47068 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47069 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47070 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47071 +4 4 4 4 4 4
47072 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47073 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47074 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47075 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47076 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47077 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47078 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47079 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47080 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47081 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47082 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47083 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47085 +4 4 4 4 4 4
47086 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47087 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47088 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47089 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47090 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47091 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47092 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47093 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47094 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47095 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47096 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47097 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47098 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47099 +4 4 4 4 4 4
47100 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47101 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47102 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47103 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47104 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47105 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47106 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47107 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47108 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47109 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47110 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47111 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47112 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47113 +4 4 4 4 4 4
47114 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47115 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47116 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47117 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47118 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47119 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47120 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47121 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47122 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47123 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47124 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47125 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47126 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47127 +4 4 4 4 4 4
47128 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47129 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47130 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47131 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47132 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47133 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47134 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47135 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47136 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47137 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47138 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47139 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
47142 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47143 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47144 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47145 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47146 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47147 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47148 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47149 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47150 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47151 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47152 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47153 +4 4 4 4 4 4 4 4 4 4 4 4 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
47156 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47157 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47158 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47159 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47160 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47161 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47162 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47163 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47164 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47165 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47166 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47167 +4 4 4 4 4 4 4 4 4 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
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 5 5 5 5 5 5 5 5 5
47172 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47173 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47174 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47175 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47176 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47177 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47178 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47179 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47180 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47181 +4 4 4 4 4 4 4 4 4 4 4 4 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
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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47187 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47188 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47189 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47190 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47191 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47192 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47193 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47194 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47195 +4 4 4 4 4 4 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
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 5 5 5
47201 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47202 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47203 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47204 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47205 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47206 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47207 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47208 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47209 +4 4 4 4 4 4 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
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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47216 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47217 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47218 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47219 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47220 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47221 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47222 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47223 +4 4 4 4 4 4 4 4 4 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
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 5 5 5 4 3 3 5 5 5 6 6 6
47230 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47231 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47232 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47233 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47234 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47235 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47236 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47237 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47238 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47239 +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 4 4 4 5 5 5 4 3 3 5 5 5
47244 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47245 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47246 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47248 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47249 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47250 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47251 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47252 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47253 +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 4 4 4 4 4 4 4 4 4 5 5 5
47258 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47259 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47260 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47263 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47264 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47265 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47266 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47267 +4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
47272 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47273 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47274 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47277 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47278 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47279 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47281 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4
47286 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47287 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47288 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47291 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47292 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47293 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47295 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4
47300 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47301 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47302 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47305 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47306 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47307 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47308 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47309 +4 4 4 4 4 4
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 4 4 4 4 4 4 4 4 4 4 4 4
47314 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47315 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47319 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47321 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47323 +4 4 4 4 4 4
47324 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47325 index fe92eed..106e085 100644
47326 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47327 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47328 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47329 struct mb862xxfb_par *par = info->par;
47330
47331 if (info->var.bits_per_pixel == 32) {
47332 - info->fbops->fb_fillrect = cfb_fillrect;
47333 - info->fbops->fb_copyarea = cfb_copyarea;
47334 - info->fbops->fb_imageblit = cfb_imageblit;
47335 + pax_open_kernel();
47336 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47337 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47338 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47339 + pax_close_kernel();
47340 } else {
47341 outreg(disp, GC_L0EM, 3);
47342 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47343 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47344 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47345 + pax_open_kernel();
47346 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47347 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47348 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47349 + pax_close_kernel();
47350 }
47351 outreg(draw, GDC_REG_DRAW_BASE, 0);
47352 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47353 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47354 index ff22871..b129bed 100644
47355 --- a/drivers/video/nvidia/nvidia.c
47356 +++ b/drivers/video/nvidia/nvidia.c
47357 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47358 info->fix.line_length = (info->var.xres_virtual *
47359 info->var.bits_per_pixel) >> 3;
47360 if (info->var.accel_flags) {
47361 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47362 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47363 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47364 - info->fbops->fb_sync = nvidiafb_sync;
47365 + pax_open_kernel();
47366 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47367 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47368 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47369 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47370 + pax_close_kernel();
47371 info->pixmap.scan_align = 4;
47372 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47373 info->flags |= FBINFO_READS_FAST;
47374 NVResetGraphics(info);
47375 } else {
47376 - info->fbops->fb_imageblit = cfb_imageblit;
47377 - info->fbops->fb_fillrect = cfb_fillrect;
47378 - info->fbops->fb_copyarea = cfb_copyarea;
47379 - info->fbops->fb_sync = NULL;
47380 + pax_open_kernel();
47381 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47382 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47383 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47384 + *(void **)&info->fbops->fb_sync = NULL;
47385 + pax_close_kernel();
47386 info->pixmap.scan_align = 1;
47387 info->flags |= FBINFO_HWACCEL_DISABLED;
47388 info->flags &= ~FBINFO_READS_FAST;
47389 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47390 info->pixmap.size = 8 * 1024;
47391 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47392
47393 - if (!hwcur)
47394 - info->fbops->fb_cursor = NULL;
47395 + if (!hwcur) {
47396 + pax_open_kernel();
47397 + *(void **)&info->fbops->fb_cursor = NULL;
47398 + pax_close_kernel();
47399 + }
47400
47401 info->var.accel_flags = (!noaccel);
47402
47403 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47404 index 76d9053..dec2bfd 100644
47405 --- a/drivers/video/s1d13xxxfb.c
47406 +++ b/drivers/video/s1d13xxxfb.c
47407 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47408
47409 switch(prod_id) {
47410 case S1D13506_PROD_ID: /* activate acceleration */
47411 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47412 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47413 + pax_open_kernel();
47414 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47415 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47416 + pax_close_kernel();
47417 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47418 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47419 break;
47420 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47421 index 97bd662..39fab85 100644
47422 --- a/drivers/video/smscufx.c
47423 +++ b/drivers/video/smscufx.c
47424 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47425 fb_deferred_io_cleanup(info);
47426 kfree(info->fbdefio);
47427 info->fbdefio = NULL;
47428 - info->fbops->fb_mmap = ufx_ops_mmap;
47429 + pax_open_kernel();
47430 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47431 + pax_close_kernel();
47432 }
47433
47434 pr_debug("released /dev/fb%d user=%d count=%d",
47435 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47436 index 86d449e..8e04dc5 100644
47437 --- a/drivers/video/udlfb.c
47438 +++ b/drivers/video/udlfb.c
47439 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47440 dlfb_urb_completion(urb);
47441
47442 error:
47443 - atomic_add(bytes_sent, &dev->bytes_sent);
47444 - atomic_add(bytes_identical, &dev->bytes_identical);
47445 - atomic_add(width*height*2, &dev->bytes_rendered);
47446 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47447 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47448 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47449 end_cycles = get_cycles();
47450 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47451 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47452 >> 10)), /* Kcycles */
47453 &dev->cpu_kcycles_used);
47454
47455 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47456 dlfb_urb_completion(urb);
47457
47458 error:
47459 - atomic_add(bytes_sent, &dev->bytes_sent);
47460 - atomic_add(bytes_identical, &dev->bytes_identical);
47461 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47462 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47463 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47464 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47465 end_cycles = get_cycles();
47466 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47467 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47468 >> 10)), /* Kcycles */
47469 &dev->cpu_kcycles_used);
47470 }
47471 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47472 fb_deferred_io_cleanup(info);
47473 kfree(info->fbdefio);
47474 info->fbdefio = NULL;
47475 - info->fbops->fb_mmap = dlfb_ops_mmap;
47476 + pax_open_kernel();
47477 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47478 + pax_close_kernel();
47479 }
47480
47481 pr_warn("released /dev/fb%d user=%d count=%d\n",
47482 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47483 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47484 struct dlfb_data *dev = fb_info->par;
47485 return snprintf(buf, PAGE_SIZE, "%u\n",
47486 - atomic_read(&dev->bytes_rendered));
47487 + atomic_read_unchecked(&dev->bytes_rendered));
47488 }
47489
47490 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47491 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47492 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47493 struct dlfb_data *dev = fb_info->par;
47494 return snprintf(buf, PAGE_SIZE, "%u\n",
47495 - atomic_read(&dev->bytes_identical));
47496 + atomic_read_unchecked(&dev->bytes_identical));
47497 }
47498
47499 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47500 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_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_sent));
47505 + atomic_read_unchecked(&dev->bytes_sent));
47506 }
47507
47508 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47509 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_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->cpu_kcycles_used));
47514 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47515 }
47516
47517 static ssize_t edid_show(
47518 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47519 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47520 struct dlfb_data *dev = fb_info->par;
47521
47522 - atomic_set(&dev->bytes_rendered, 0);
47523 - atomic_set(&dev->bytes_identical, 0);
47524 - atomic_set(&dev->bytes_sent, 0);
47525 - atomic_set(&dev->cpu_kcycles_used, 0);
47526 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47527 + atomic_set_unchecked(&dev->bytes_identical, 0);
47528 + atomic_set_unchecked(&dev->bytes_sent, 0);
47529 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47530
47531 return count;
47532 }
47533 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47534 index d428445..79a78df 100644
47535 --- a/drivers/video/uvesafb.c
47536 +++ b/drivers/video/uvesafb.c
47537 @@ -19,6 +19,7 @@
47538 #include <linux/io.h>
47539 #include <linux/mutex.h>
47540 #include <linux/slab.h>
47541 +#include <linux/moduleloader.h>
47542 #include <video/edid.h>
47543 #include <video/uvesafb.h>
47544 #ifdef CONFIG_X86
47545 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
47546 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
47547 par->pmi_setpal = par->ypan = 0;
47548 } else {
47549 +
47550 +#ifdef CONFIG_PAX_KERNEXEC
47551 +#ifdef CONFIG_MODULES
47552 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
47553 +#endif
47554 + if (!par->pmi_code) {
47555 + par->pmi_setpal = par->ypan = 0;
47556 + return 0;
47557 + }
47558 +#endif
47559 +
47560 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
47561 + task->t.regs.edi);
47562 +
47563 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47564 + pax_open_kernel();
47565 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
47566 + pax_close_kernel();
47567 +
47568 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
47569 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
47570 +#else
47571 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
47572 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
47573 +#endif
47574 +
47575 printk(KERN_INFO "uvesafb: protected mode interface info at "
47576 "%04x:%04x\n",
47577 (u16)task->t.regs.es, (u16)task->t.regs.edi);
47578 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
47579 par->ypan = ypan;
47580
47581 if (par->pmi_setpal || par->ypan) {
47582 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
47583 if (__supported_pte_mask & _PAGE_NX) {
47584 par->pmi_setpal = par->ypan = 0;
47585 printk(KERN_WARNING "uvesafb: NX protection is actively."
47586 "We have better not to use the PMI.\n");
47587 - } else {
47588 + } else
47589 +#endif
47590 uvesafb_vbe_getpmi(task, par);
47591 - }
47592 }
47593 #else
47594 /* The protected mode interface is not available on non-x86. */
47595 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47596 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
47597
47598 /* Disable blanking if the user requested so. */
47599 - if (!blank)
47600 - info->fbops->fb_blank = NULL;
47601 + if (!blank) {
47602 + pax_open_kernel();
47603 + *(void **)&info->fbops->fb_blank = NULL;
47604 + pax_close_kernel();
47605 + }
47606
47607 /*
47608 * Find out how much IO memory is required for the mode with
47609 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47610 info->flags = FBINFO_FLAG_DEFAULT |
47611 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
47612
47613 - if (!par->ypan)
47614 - info->fbops->fb_pan_display = NULL;
47615 + if (!par->ypan) {
47616 + pax_open_kernel();
47617 + *(void **)&info->fbops->fb_pan_display = NULL;
47618 + pax_close_kernel();
47619 + }
47620 }
47621
47622 static void uvesafb_init_mtrr(struct fb_info *info)
47623 @@ -1836,6 +1866,11 @@ out:
47624 if (par->vbe_modes)
47625 kfree(par->vbe_modes);
47626
47627 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47628 + if (par->pmi_code)
47629 + module_free_exec(NULL, par->pmi_code);
47630 +#endif
47631 +
47632 framebuffer_release(info);
47633 return err;
47634 }
47635 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
47636 kfree(par->vbe_state_orig);
47637 if (par->vbe_state_saved)
47638 kfree(par->vbe_state_saved);
47639 +
47640 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47641 + if (par->pmi_code)
47642 + module_free_exec(NULL, par->pmi_code);
47643 +#endif
47644 +
47645 }
47646
47647 framebuffer_release(info);
47648 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
47649 index 501b340..d80aa17 100644
47650 --- a/drivers/video/vesafb.c
47651 +++ b/drivers/video/vesafb.c
47652 @@ -9,6 +9,7 @@
47653 */
47654
47655 #include <linux/module.h>
47656 +#include <linux/moduleloader.h>
47657 #include <linux/kernel.h>
47658 #include <linux/errno.h>
47659 #include <linux/string.h>
47660 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
47661 static int vram_total __initdata; /* Set total amount of memory */
47662 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
47663 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
47664 -static void (*pmi_start)(void) __read_mostly;
47665 -static void (*pmi_pal) (void) __read_mostly;
47666 +static void (*pmi_start)(void) __read_only;
47667 +static void (*pmi_pal) (void) __read_only;
47668 static int depth __read_mostly;
47669 static int vga_compat __read_mostly;
47670 /* --------------------------------------------------------------------- */
47671 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
47672 unsigned int size_vmode;
47673 unsigned int size_remap;
47674 unsigned int size_total;
47675 + void *pmi_code = NULL;
47676
47677 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
47678 return -ENODEV;
47679 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
47680 size_remap = size_total;
47681 vesafb_fix.smem_len = size_remap;
47682
47683 -#ifndef __i386__
47684 - screen_info.vesapm_seg = 0;
47685 -#endif
47686 -
47687 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
47688 printk(KERN_WARNING
47689 "vesafb: cannot reserve video memory at 0x%lx\n",
47690 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
47691 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
47692 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
47693
47694 +#ifdef __i386__
47695 +
47696 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47697 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
47698 + if (!pmi_code)
47699 +#elif !defined(CONFIG_PAX_KERNEXEC)
47700 + if (0)
47701 +#endif
47702 +
47703 +#endif
47704 + screen_info.vesapm_seg = 0;
47705 +
47706 if (screen_info.vesapm_seg) {
47707 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
47708 - screen_info.vesapm_seg,screen_info.vesapm_off);
47709 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
47710 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
47711 }
47712
47713 if (screen_info.vesapm_seg < 0xc000)
47714 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
47715
47716 if (ypan || pmi_setpal) {
47717 unsigned short *pmi_base;
47718 +
47719 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
47720 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
47721 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
47722 +
47723 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47724 + pax_open_kernel();
47725 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
47726 +#else
47727 + pmi_code = pmi_base;
47728 +#endif
47729 +
47730 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
47731 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
47732 +
47733 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47734 + pmi_start = ktva_ktla(pmi_start);
47735 + pmi_pal = ktva_ktla(pmi_pal);
47736 + pax_close_kernel();
47737 +#endif
47738 +
47739 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
47740 if (pmi_base[3]) {
47741 printk(KERN_INFO "vesafb: pmi: ports = ");
47742 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47743 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
47744 (ypan ? FBINFO_HWACCEL_YPAN : 0);
47745
47746 - if (!ypan)
47747 - info->fbops->fb_pan_display = NULL;
47748 + if (!ypan) {
47749 + pax_open_kernel();
47750 + *(void **)&info->fbops->fb_pan_display = NULL;
47751 + pax_close_kernel();
47752 + }
47753
47754 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
47755 err = -ENOMEM;
47756 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47757 info->node, info->fix.id);
47758 return 0;
47759 err:
47760 +
47761 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47762 + module_free_exec(NULL, pmi_code);
47763 +#endif
47764 +
47765 if (info->screen_base)
47766 iounmap(info->screen_base);
47767 framebuffer_release(info);
47768 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
47769 index 88714ae..16c2e11 100644
47770 --- a/drivers/video/via/via_clock.h
47771 +++ b/drivers/video/via/via_clock.h
47772 @@ -56,7 +56,7 @@ struct via_clock {
47773
47774 void (*set_engine_pll_state)(u8 state);
47775 void (*set_engine_pll)(struct via_pll_config config);
47776 -};
47777 +} __no_const;
47778
47779
47780 static inline u32 get_pll_internal_frequency(u32 ref_freq,
47781 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
47782 index fef20db..d28b1ab 100644
47783 --- a/drivers/xen/xenfs/xenstored.c
47784 +++ b/drivers/xen/xenfs/xenstored.c
47785 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
47786 static int xsd_kva_open(struct inode *inode, struct file *file)
47787 {
47788 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
47789 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47790 + NULL);
47791 +#else
47792 xen_store_interface);
47793 +#endif
47794 +
47795 if (!file->private_data)
47796 return -ENOMEM;
47797 return 0;
47798 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
47799 index 0ad61c6..f198bd7 100644
47800 --- a/fs/9p/vfs_addr.c
47801 +++ b/fs/9p/vfs_addr.c
47802 @@ -185,7 +185,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
47803
47804 retval = v9fs_file_write_internal(inode,
47805 v9inode->writeback_fid,
47806 - (__force const char __user *)buffer,
47807 + (const char __force_user *)buffer,
47808 len, &offset, 0);
47809 if (retval > 0)
47810 retval = 0;
47811 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
47812 index d86edc8..40ff2fb 100644
47813 --- a/fs/9p/vfs_inode.c
47814 +++ b/fs/9p/vfs_inode.c
47815 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
47816 void
47817 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47818 {
47819 - char *s = nd_get_link(nd);
47820 + const char *s = nd_get_link(nd);
47821
47822 p9_debug(P9_DEBUG_VFS, " %s %s\n",
47823 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
47824 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
47825 index 0efd152..b5802ad 100644
47826 --- a/fs/Kconfig.binfmt
47827 +++ b/fs/Kconfig.binfmt
47828 @@ -89,7 +89,7 @@ config HAVE_AOUT
47829
47830 config BINFMT_AOUT
47831 tristate "Kernel support for a.out and ECOFF binaries"
47832 - depends on HAVE_AOUT
47833 + depends on HAVE_AOUT && BROKEN
47834 ---help---
47835 A.out (Assembler.OUTput) is a set of formats for libraries and
47836 executables used in the earliest versions of UNIX. Linux used
47837 diff --git a/fs/aio.c b/fs/aio.c
47838 index 1dc8786..d3b29e8 100644
47839 --- a/fs/aio.c
47840 +++ b/fs/aio.c
47841 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
47842 size += sizeof(struct io_event) * nr_events;
47843 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
47844
47845 - if (nr_pages < 0)
47846 + if (nr_pages <= 0)
47847 return -EINVAL;
47848
47849 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
47850 @@ -1375,18 +1375,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
47851 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47852 {
47853 ssize_t ret;
47854 + struct iovec iovstack;
47855
47856 #ifdef CONFIG_COMPAT
47857 if (compat)
47858 ret = compat_rw_copy_check_uvector(type,
47859 (struct compat_iovec __user *)kiocb->ki_buf,
47860 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47861 + kiocb->ki_nbytes, 1, &iovstack,
47862 &kiocb->ki_iovec);
47863 else
47864 #endif
47865 ret = rw_copy_check_uvector(type,
47866 (struct iovec __user *)kiocb->ki_buf,
47867 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47868 + kiocb->ki_nbytes, 1, &iovstack,
47869 &kiocb->ki_iovec);
47870 if (ret < 0)
47871 goto out;
47872 @@ -1395,6 +1396,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47873 if (ret < 0)
47874 goto out;
47875
47876 + if (kiocb->ki_iovec == &iovstack) {
47877 + kiocb->ki_inline_vec = iovstack;
47878 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
47879 + }
47880 kiocb->ki_nr_segs = kiocb->ki_nbytes;
47881 kiocb->ki_cur_seg = 0;
47882 /* ki_nbytes/left now reflect bytes instead of segs */
47883 diff --git a/fs/attr.c b/fs/attr.c
47884 index 1449adb..a2038c2 100644
47885 --- a/fs/attr.c
47886 +++ b/fs/attr.c
47887 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
47888 unsigned long limit;
47889
47890 limit = rlimit(RLIMIT_FSIZE);
47891 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
47892 if (limit != RLIM_INFINITY && offset > limit)
47893 goto out_sig;
47894 if (offset > inode->i_sb->s_maxbytes)
47895 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
47896 index 3db70da..7aeec5b 100644
47897 --- a/fs/autofs4/waitq.c
47898 +++ b/fs/autofs4/waitq.c
47899 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
47900 {
47901 unsigned long sigpipe, flags;
47902 mm_segment_t fs;
47903 - const char *data = (const char *)addr;
47904 + const char __user *data = (const char __force_user *)addr;
47905 ssize_t wr = 0;
47906
47907 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
47908 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
47909 return 1;
47910 }
47911
47912 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47913 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
47914 +#endif
47915 +
47916 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47917 enum autofs_notify notify)
47918 {
47919 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47920
47921 /* If this is a direct mount request create a dummy name */
47922 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
47923 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47924 + /* this name does get written to userland via autofs4_write() */
47925 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
47926 +#else
47927 qstr.len = sprintf(name, "%p", dentry);
47928 +#endif
47929 else {
47930 qstr.len = autofs4_getpath(sbi, dentry, &name);
47931 if (!qstr.len) {
47932 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
47933 index 2722387..c8dd2a7 100644
47934 --- a/fs/befs/endian.h
47935 +++ b/fs/befs/endian.h
47936 @@ -11,7 +11,7 @@
47937
47938 #include <asm/byteorder.h>
47939
47940 -static inline u64
47941 +static inline u64 __intentional_overflow(-1)
47942 fs64_to_cpu(const struct super_block *sb, fs64 n)
47943 {
47944 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47945 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
47946 return (__force fs64)cpu_to_be64(n);
47947 }
47948
47949 -static inline u32
47950 +static inline u32 __intentional_overflow(-1)
47951 fs32_to_cpu(const struct super_block *sb, fs32 n)
47952 {
47953 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47954 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
47955 index 8615ee8..388ed68 100644
47956 --- a/fs/befs/linuxvfs.c
47957 +++ b/fs/befs/linuxvfs.c
47958 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47959 {
47960 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
47961 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
47962 - char *link = nd_get_link(nd);
47963 + const char *link = nd_get_link(nd);
47964 if (!IS_ERR(link))
47965 kfree(link);
47966 }
47967 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
47968 index bbc8f88..7c7ac97 100644
47969 --- a/fs/binfmt_aout.c
47970 +++ b/fs/binfmt_aout.c
47971 @@ -16,6 +16,7 @@
47972 #include <linux/string.h>
47973 #include <linux/fs.h>
47974 #include <linux/file.h>
47975 +#include <linux/security.h>
47976 #include <linux/stat.h>
47977 #include <linux/fcntl.h>
47978 #include <linux/ptrace.h>
47979 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
47980 #endif
47981 # define START_STACK(u) ((void __user *)u.start_stack)
47982
47983 + memset(&dump, 0, sizeof(dump));
47984 +
47985 fs = get_fs();
47986 set_fs(KERNEL_DS);
47987 has_dumped = 1;
47988 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
47989
47990 /* If the size of the dump file exceeds the rlimit, then see what would happen
47991 if we wrote the stack, but not the data area. */
47992 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
47993 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
47994 dump.u_dsize = 0;
47995
47996 /* Make sure we have enough room to write the stack and data areas. */
47997 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
47998 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
47999 dump.u_ssize = 0;
48000
48001 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48002 rlim = rlimit(RLIMIT_DATA);
48003 if (rlim >= RLIM_INFINITY)
48004 rlim = ~0;
48005 +
48006 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48007 if (ex.a_data + ex.a_bss > rlim)
48008 return -ENOMEM;
48009
48010 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48011
48012 install_exec_creds(bprm);
48013
48014 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48015 + current->mm->pax_flags = 0UL;
48016 +#endif
48017 +
48018 +#ifdef CONFIG_PAX_PAGEEXEC
48019 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48020 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48021 +
48022 +#ifdef CONFIG_PAX_EMUTRAMP
48023 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48024 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48025 +#endif
48026 +
48027 +#ifdef CONFIG_PAX_MPROTECT
48028 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48029 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48030 +#endif
48031 +
48032 + }
48033 +#endif
48034 +
48035 if (N_MAGIC(ex) == OMAGIC) {
48036 unsigned long text_addr, map_size;
48037 loff_t pos;
48038 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48039 }
48040
48041 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48042 - PROT_READ | PROT_WRITE | PROT_EXEC,
48043 + PROT_READ | PROT_WRITE,
48044 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48045 fd_offset + ex.a_text);
48046 if (error != N_DATADDR(ex)) {
48047 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48048 index 86af964..5d53bf6 100644
48049 --- a/fs/binfmt_elf.c
48050 +++ b/fs/binfmt_elf.c
48051 @@ -34,6 +34,7 @@
48052 #include <linux/utsname.h>
48053 #include <linux/coredump.h>
48054 #include <linux/sched.h>
48055 +#include <linux/xattr.h>
48056 #include <asm/uaccess.h>
48057 #include <asm/param.h>
48058 #include <asm/page.h>
48059 @@ -60,6 +61,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48060 #define elf_core_dump NULL
48061 #endif
48062
48063 +#ifdef CONFIG_PAX_MPROTECT
48064 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48065 +#endif
48066 +
48067 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48068 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48069 #else
48070 @@ -79,6 +84,11 @@ static struct linux_binfmt elf_format = {
48071 .load_binary = load_elf_binary,
48072 .load_shlib = load_elf_library,
48073 .core_dump = elf_core_dump,
48074 +
48075 +#ifdef CONFIG_PAX_MPROTECT
48076 + .handle_mprotect= elf_handle_mprotect,
48077 +#endif
48078 +
48079 .min_coredump = ELF_EXEC_PAGESIZE,
48080 };
48081
48082 @@ -86,6 +96,8 @@ static struct linux_binfmt elf_format = {
48083
48084 static int set_brk(unsigned long start, unsigned long end)
48085 {
48086 + unsigned long e = end;
48087 +
48088 start = ELF_PAGEALIGN(start);
48089 end = ELF_PAGEALIGN(end);
48090 if (end > start) {
48091 @@ -94,7 +106,7 @@ static int set_brk(unsigned long start, unsigned long end)
48092 if (BAD_ADDR(addr))
48093 return addr;
48094 }
48095 - current->mm->start_brk = current->mm->brk = end;
48096 + current->mm->start_brk = current->mm->brk = e;
48097 return 0;
48098 }
48099
48100 @@ -155,12 +167,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48101 elf_addr_t __user *u_rand_bytes;
48102 const char *k_platform = ELF_PLATFORM;
48103 const char *k_base_platform = ELF_BASE_PLATFORM;
48104 - unsigned char k_rand_bytes[16];
48105 + u32 k_rand_bytes[4];
48106 int items;
48107 elf_addr_t *elf_info;
48108 int ei_index = 0;
48109 const struct cred *cred = current_cred();
48110 struct vm_area_struct *vma;
48111 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48112
48113 /*
48114 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48115 @@ -202,8 +215,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48116 * Generate 16 random bytes for userspace PRNG seeding.
48117 */
48118 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48119 - u_rand_bytes = (elf_addr_t __user *)
48120 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48121 + srandom32(k_rand_bytes[0] ^ random32());
48122 + srandom32(k_rand_bytes[1] ^ random32());
48123 + srandom32(k_rand_bytes[2] ^ random32());
48124 + srandom32(k_rand_bytes[3] ^ random32());
48125 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48126 + u_rand_bytes = (elf_addr_t __user *) p;
48127 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48128 return -EFAULT;
48129
48130 @@ -315,9 +332,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48131 return -EFAULT;
48132 current->mm->env_end = p;
48133
48134 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48135 +
48136 /* Put the elf_info on the stack in the right place. */
48137 sp = (elf_addr_t __user *)envp + 1;
48138 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48139 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48140 return -EFAULT;
48141 return 0;
48142 }
48143 @@ -385,15 +404,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48144 an ELF header */
48145
48146 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48147 - struct file *interpreter, unsigned long *interp_map_addr,
48148 - unsigned long no_base)
48149 + struct file *interpreter, unsigned long no_base)
48150 {
48151 struct elf_phdr *elf_phdata;
48152 struct elf_phdr *eppnt;
48153 - unsigned long load_addr = 0;
48154 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48155 int load_addr_set = 0;
48156 unsigned long last_bss = 0, elf_bss = 0;
48157 - unsigned long error = ~0UL;
48158 + unsigned long error = -EINVAL;
48159 unsigned long total_size;
48160 int retval, i, size;
48161
48162 @@ -439,6 +457,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48163 goto out_close;
48164 }
48165
48166 +#ifdef CONFIG_PAX_SEGMEXEC
48167 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48168 + pax_task_size = SEGMEXEC_TASK_SIZE;
48169 +#endif
48170 +
48171 eppnt = elf_phdata;
48172 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48173 if (eppnt->p_type == PT_LOAD) {
48174 @@ -462,8 +485,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48175 map_addr = elf_map(interpreter, load_addr + vaddr,
48176 eppnt, elf_prot, elf_type, total_size);
48177 total_size = 0;
48178 - if (!*interp_map_addr)
48179 - *interp_map_addr = map_addr;
48180 error = map_addr;
48181 if (BAD_ADDR(map_addr))
48182 goto out_close;
48183 @@ -482,8 +503,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48184 k = load_addr + eppnt->p_vaddr;
48185 if (BAD_ADDR(k) ||
48186 eppnt->p_filesz > eppnt->p_memsz ||
48187 - eppnt->p_memsz > TASK_SIZE ||
48188 - TASK_SIZE - eppnt->p_memsz < k) {
48189 + eppnt->p_memsz > pax_task_size ||
48190 + pax_task_size - eppnt->p_memsz < k) {
48191 error = -ENOMEM;
48192 goto out_close;
48193 }
48194 @@ -535,6 +556,315 @@ out:
48195 return error;
48196 }
48197
48198 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48199 +#ifdef CONFIG_PAX_SOFTMODE
48200 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48201 +{
48202 + unsigned long pax_flags = 0UL;
48203 +
48204 +#ifdef CONFIG_PAX_PAGEEXEC
48205 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48206 + pax_flags |= MF_PAX_PAGEEXEC;
48207 +#endif
48208 +
48209 +#ifdef CONFIG_PAX_SEGMEXEC
48210 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48211 + pax_flags |= MF_PAX_SEGMEXEC;
48212 +#endif
48213 +
48214 +#ifdef CONFIG_PAX_EMUTRAMP
48215 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48216 + pax_flags |= MF_PAX_EMUTRAMP;
48217 +#endif
48218 +
48219 +#ifdef CONFIG_PAX_MPROTECT
48220 + if (elf_phdata->p_flags & PF_MPROTECT)
48221 + pax_flags |= MF_PAX_MPROTECT;
48222 +#endif
48223 +
48224 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48225 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48226 + pax_flags |= MF_PAX_RANDMMAP;
48227 +#endif
48228 +
48229 + return pax_flags;
48230 +}
48231 +#endif
48232 +
48233 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48234 +{
48235 + unsigned long pax_flags = 0UL;
48236 +
48237 +#ifdef CONFIG_PAX_PAGEEXEC
48238 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48239 + pax_flags |= MF_PAX_PAGEEXEC;
48240 +#endif
48241 +
48242 +#ifdef CONFIG_PAX_SEGMEXEC
48243 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48244 + pax_flags |= MF_PAX_SEGMEXEC;
48245 +#endif
48246 +
48247 +#ifdef CONFIG_PAX_EMUTRAMP
48248 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48249 + pax_flags |= MF_PAX_EMUTRAMP;
48250 +#endif
48251 +
48252 +#ifdef CONFIG_PAX_MPROTECT
48253 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48254 + pax_flags |= MF_PAX_MPROTECT;
48255 +#endif
48256 +
48257 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48258 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48259 + pax_flags |= MF_PAX_RANDMMAP;
48260 +#endif
48261 +
48262 + return pax_flags;
48263 +}
48264 +#endif
48265 +
48266 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48267 +#ifdef CONFIG_PAX_SOFTMODE
48268 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48269 +{
48270 + unsigned long pax_flags = 0UL;
48271 +
48272 +#ifdef CONFIG_PAX_PAGEEXEC
48273 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48274 + pax_flags |= MF_PAX_PAGEEXEC;
48275 +#endif
48276 +
48277 +#ifdef CONFIG_PAX_SEGMEXEC
48278 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48279 + pax_flags |= MF_PAX_SEGMEXEC;
48280 +#endif
48281 +
48282 +#ifdef CONFIG_PAX_EMUTRAMP
48283 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48284 + pax_flags |= MF_PAX_EMUTRAMP;
48285 +#endif
48286 +
48287 +#ifdef CONFIG_PAX_MPROTECT
48288 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48289 + pax_flags |= MF_PAX_MPROTECT;
48290 +#endif
48291 +
48292 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48293 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48294 + pax_flags |= MF_PAX_RANDMMAP;
48295 +#endif
48296 +
48297 + return pax_flags;
48298 +}
48299 +#endif
48300 +
48301 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48302 +{
48303 + unsigned long pax_flags = 0UL;
48304 +
48305 +#ifdef CONFIG_PAX_PAGEEXEC
48306 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48307 + pax_flags |= MF_PAX_PAGEEXEC;
48308 +#endif
48309 +
48310 +#ifdef CONFIG_PAX_SEGMEXEC
48311 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48312 + pax_flags |= MF_PAX_SEGMEXEC;
48313 +#endif
48314 +
48315 +#ifdef CONFIG_PAX_EMUTRAMP
48316 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48317 + pax_flags |= MF_PAX_EMUTRAMP;
48318 +#endif
48319 +
48320 +#ifdef CONFIG_PAX_MPROTECT
48321 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48322 + pax_flags |= MF_PAX_MPROTECT;
48323 +#endif
48324 +
48325 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48326 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48327 + pax_flags |= MF_PAX_RANDMMAP;
48328 +#endif
48329 +
48330 + return pax_flags;
48331 +}
48332 +#endif
48333 +
48334 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48335 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48336 +{
48337 + unsigned long pax_flags = 0UL;
48338 +
48339 +#ifdef CONFIG_PAX_EI_PAX
48340 +
48341 +#ifdef CONFIG_PAX_PAGEEXEC
48342 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48343 + pax_flags |= MF_PAX_PAGEEXEC;
48344 +#endif
48345 +
48346 +#ifdef CONFIG_PAX_SEGMEXEC
48347 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48348 + pax_flags |= MF_PAX_SEGMEXEC;
48349 +#endif
48350 +
48351 +#ifdef CONFIG_PAX_EMUTRAMP
48352 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48353 + pax_flags |= MF_PAX_EMUTRAMP;
48354 +#endif
48355 +
48356 +#ifdef CONFIG_PAX_MPROTECT
48357 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48358 + pax_flags |= MF_PAX_MPROTECT;
48359 +#endif
48360 +
48361 +#ifdef CONFIG_PAX_ASLR
48362 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48363 + pax_flags |= MF_PAX_RANDMMAP;
48364 +#endif
48365 +
48366 +#else
48367 +
48368 +#ifdef CONFIG_PAX_PAGEEXEC
48369 + pax_flags |= MF_PAX_PAGEEXEC;
48370 +#endif
48371 +
48372 +#ifdef CONFIG_PAX_SEGMEXEC
48373 + pax_flags |= MF_PAX_SEGMEXEC;
48374 +#endif
48375 +
48376 +#ifdef CONFIG_PAX_MPROTECT
48377 + pax_flags |= MF_PAX_MPROTECT;
48378 +#endif
48379 +
48380 +#ifdef CONFIG_PAX_RANDMMAP
48381 + if (randomize_va_space)
48382 + pax_flags |= MF_PAX_RANDMMAP;
48383 +#endif
48384 +
48385 +#endif
48386 +
48387 + return pax_flags;
48388 +}
48389 +
48390 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48391 +{
48392 +
48393 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48394 + unsigned long i;
48395 +
48396 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48397 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48398 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48399 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48400 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48401 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48402 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48403 + return ~0UL;
48404 +
48405 +#ifdef CONFIG_PAX_SOFTMODE
48406 + if (pax_softmode)
48407 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48408 + else
48409 +#endif
48410 +
48411 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48412 + break;
48413 + }
48414 +#endif
48415 +
48416 + return ~0UL;
48417 +}
48418 +
48419 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48420 +{
48421 +
48422 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48423 + ssize_t xattr_size, i;
48424 + unsigned char xattr_value[sizeof("pemrs") - 1];
48425 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48426 +
48427 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
48428 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
48429 + return ~0UL;
48430 +
48431 + for (i = 0; i < xattr_size; i++)
48432 + switch (xattr_value[i]) {
48433 + default:
48434 + return ~0UL;
48435 +
48436 +#define parse_flag(option1, option2, flag) \
48437 + case option1: \
48438 + if (pax_flags_hardmode & MF_PAX_##flag) \
48439 + return ~0UL; \
48440 + pax_flags_hardmode |= MF_PAX_##flag; \
48441 + break; \
48442 + case option2: \
48443 + if (pax_flags_softmode & MF_PAX_##flag) \
48444 + return ~0UL; \
48445 + pax_flags_softmode |= MF_PAX_##flag; \
48446 + break;
48447 +
48448 + parse_flag('p', 'P', PAGEEXEC);
48449 + parse_flag('e', 'E', EMUTRAMP);
48450 + parse_flag('m', 'M', MPROTECT);
48451 + parse_flag('r', 'R', RANDMMAP);
48452 + parse_flag('s', 'S', SEGMEXEC);
48453 +
48454 +#undef parse_flag
48455 + }
48456 +
48457 + if (pax_flags_hardmode & pax_flags_softmode)
48458 + return ~0UL;
48459 +
48460 +#ifdef CONFIG_PAX_SOFTMODE
48461 + if (pax_softmode)
48462 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48463 + else
48464 +#endif
48465 +
48466 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48467 +#else
48468 + return ~0UL;
48469 +#endif
48470 +
48471 +}
48472 +
48473 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48474 +{
48475 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48476 +
48477 + pax_flags = pax_parse_ei_pax(elf_ex);
48478 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48479 + xattr_pax_flags = pax_parse_xattr_pax(file);
48480 +
48481 + if (pt_pax_flags == ~0UL)
48482 + pt_pax_flags = xattr_pax_flags;
48483 + else if (xattr_pax_flags == ~0UL)
48484 + xattr_pax_flags = pt_pax_flags;
48485 + if (pt_pax_flags != xattr_pax_flags)
48486 + return -EINVAL;
48487 + if (pt_pax_flags != ~0UL)
48488 + pax_flags = pt_pax_flags;
48489 +
48490 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48491 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48492 + if ((__supported_pte_mask & _PAGE_NX))
48493 + pax_flags &= ~MF_PAX_SEGMEXEC;
48494 + else
48495 + pax_flags &= ~MF_PAX_PAGEEXEC;
48496 + }
48497 +#endif
48498 +
48499 + if (0 > pax_check_flags(&pax_flags))
48500 + return -EINVAL;
48501 +
48502 + current->mm->pax_flags = pax_flags;
48503 + return 0;
48504 +}
48505 +#endif
48506 +
48507 /*
48508 * These are the functions used to load ELF style executables and shared
48509 * libraries. There is no binary dependent code anywhere else.
48510 @@ -551,6 +881,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48511 {
48512 unsigned int random_variable = 0;
48513
48514 +#ifdef CONFIG_PAX_RANDUSTACK
48515 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48516 + return stack_top - current->mm->delta_stack;
48517 +#endif
48518 +
48519 if ((current->flags & PF_RANDOMIZE) &&
48520 !(current->personality & ADDR_NO_RANDOMIZE)) {
48521 random_variable = get_random_int() & STACK_RND_MASK;
48522 @@ -569,7 +904,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48523 unsigned long load_addr = 0, load_bias = 0;
48524 int load_addr_set = 0;
48525 char * elf_interpreter = NULL;
48526 - unsigned long error;
48527 + unsigned long error = 0;
48528 struct elf_phdr *elf_ppnt, *elf_phdata;
48529 unsigned long elf_bss, elf_brk;
48530 int retval, i;
48531 @@ -579,12 +914,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48532 unsigned long start_code, end_code, start_data, end_data;
48533 unsigned long reloc_func_desc __maybe_unused = 0;
48534 int executable_stack = EXSTACK_DEFAULT;
48535 - unsigned long def_flags = 0;
48536 struct pt_regs *regs = current_pt_regs();
48537 struct {
48538 struct elfhdr elf_ex;
48539 struct elfhdr interp_elf_ex;
48540 } *loc;
48541 + unsigned long pax_task_size = TASK_SIZE;
48542
48543 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
48544 if (!loc) {
48545 @@ -720,11 +1055,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
48546 goto out_free_dentry;
48547
48548 /* OK, This is the point of no return */
48549 - current->mm->def_flags = def_flags;
48550 +
48551 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48552 + current->mm->pax_flags = 0UL;
48553 +#endif
48554 +
48555 +#ifdef CONFIG_PAX_DLRESOLVE
48556 + current->mm->call_dl_resolve = 0UL;
48557 +#endif
48558 +
48559 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
48560 + current->mm->call_syscall = 0UL;
48561 +#endif
48562 +
48563 +#ifdef CONFIG_PAX_ASLR
48564 + current->mm->delta_mmap = 0UL;
48565 + current->mm->delta_stack = 0UL;
48566 +#endif
48567 +
48568 + current->mm->def_flags = 0;
48569 +
48570 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48571 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
48572 + send_sig(SIGKILL, current, 0);
48573 + goto out_free_dentry;
48574 + }
48575 +#endif
48576 +
48577 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
48578 + pax_set_initial_flags(bprm);
48579 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
48580 + if (pax_set_initial_flags_func)
48581 + (pax_set_initial_flags_func)(bprm);
48582 +#endif
48583 +
48584 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48585 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
48586 + current->mm->context.user_cs_limit = PAGE_SIZE;
48587 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
48588 + }
48589 +#endif
48590 +
48591 +#ifdef CONFIG_PAX_SEGMEXEC
48592 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
48593 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
48594 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
48595 + pax_task_size = SEGMEXEC_TASK_SIZE;
48596 + current->mm->def_flags |= VM_NOHUGEPAGE;
48597 + }
48598 +#endif
48599 +
48600 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
48601 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48602 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
48603 + put_cpu();
48604 + }
48605 +#endif
48606
48607 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
48608 may depend on the personality. */
48609 SET_PERSONALITY(loc->elf_ex);
48610 +
48611 +#ifdef CONFIG_PAX_ASLR
48612 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48613 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
48614 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
48615 + }
48616 +#endif
48617 +
48618 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
48619 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48620 + executable_stack = EXSTACK_DISABLE_X;
48621 + current->personality &= ~READ_IMPLIES_EXEC;
48622 + } else
48623 +#endif
48624 +
48625 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
48626 current->personality |= READ_IMPLIES_EXEC;
48627
48628 @@ -815,6 +1220,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
48629 #else
48630 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
48631 #endif
48632 +
48633 +#ifdef CONFIG_PAX_RANDMMAP
48634 + /* PaX: randomize base address at the default exe base if requested */
48635 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
48636 +#ifdef CONFIG_SPARC64
48637 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
48638 +#else
48639 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
48640 +#endif
48641 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
48642 + elf_flags |= MAP_FIXED;
48643 + }
48644 +#endif
48645 +
48646 }
48647
48648 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
48649 @@ -847,9 +1266,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
48650 * allowed task size. Note that p_filesz must always be
48651 * <= p_memsz so it is only necessary to check p_memsz.
48652 */
48653 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48654 - elf_ppnt->p_memsz > TASK_SIZE ||
48655 - TASK_SIZE - elf_ppnt->p_memsz < k) {
48656 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48657 + elf_ppnt->p_memsz > pax_task_size ||
48658 + pax_task_size - elf_ppnt->p_memsz < k) {
48659 /* set_brk can never work. Avoid overflows. */
48660 send_sig(SIGKILL, current, 0);
48661 retval = -EINVAL;
48662 @@ -888,17 +1307,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
48663 goto out_free_dentry;
48664 }
48665 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
48666 - send_sig(SIGSEGV, current, 0);
48667 - retval = -EFAULT; /* Nobody gets to see this, but.. */
48668 - goto out_free_dentry;
48669 + /*
48670 + * This bss-zeroing can fail if the ELF
48671 + * file specifies odd protections. So
48672 + * we don't check the return value
48673 + */
48674 }
48675
48676 +#ifdef CONFIG_PAX_RANDMMAP
48677 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48678 + unsigned long start, size, flags;
48679 + vm_flags_t vm_flags;
48680 +
48681 + start = ELF_PAGEALIGN(elf_brk);
48682 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
48683 + flags = MAP_FIXED | MAP_PRIVATE;
48684 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
48685 +
48686 + down_write(&current->mm->mmap_sem);
48687 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
48688 + retval = -ENOMEM;
48689 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
48690 +// if (current->personality & ADDR_NO_RANDOMIZE)
48691 +// vm_flags |= VM_READ | VM_MAYREAD;
48692 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
48693 + retval = IS_ERR_VALUE(start) ? start : 0;
48694 + }
48695 + up_write(&current->mm->mmap_sem);
48696 + if (retval == 0)
48697 + retval = set_brk(start + size, start + size + PAGE_SIZE);
48698 + if (retval < 0) {
48699 + send_sig(SIGKILL, current, 0);
48700 + goto out_free_dentry;
48701 + }
48702 + }
48703 +#endif
48704 +
48705 if (elf_interpreter) {
48706 - unsigned long interp_map_addr = 0;
48707 -
48708 elf_entry = load_elf_interp(&loc->interp_elf_ex,
48709 interpreter,
48710 - &interp_map_addr,
48711 load_bias);
48712 if (!IS_ERR((void *)elf_entry)) {
48713 /*
48714 @@ -1120,7 +1567,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
48715 * Decide what to dump of a segment, part, all or none.
48716 */
48717 static unsigned long vma_dump_size(struct vm_area_struct *vma,
48718 - unsigned long mm_flags)
48719 + unsigned long mm_flags, long signr)
48720 {
48721 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
48722
48723 @@ -1158,7 +1605,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
48724 if (vma->vm_file == NULL)
48725 return 0;
48726
48727 - if (FILTER(MAPPED_PRIVATE))
48728 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
48729 goto whole;
48730
48731 /*
48732 @@ -1383,9 +1830,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
48733 {
48734 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
48735 int i = 0;
48736 - do
48737 + do {
48738 i += 2;
48739 - while (auxv[i - 2] != AT_NULL);
48740 + } while (auxv[i - 2] != AT_NULL);
48741 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
48742 }
48743
48744 @@ -1394,7 +1841,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
48745 {
48746 mm_segment_t old_fs = get_fs();
48747 set_fs(KERNEL_DS);
48748 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
48749 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
48750 set_fs(old_fs);
48751 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
48752 }
48753 @@ -2015,14 +2462,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
48754 }
48755
48756 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
48757 - unsigned long mm_flags)
48758 + struct coredump_params *cprm)
48759 {
48760 struct vm_area_struct *vma;
48761 size_t size = 0;
48762
48763 for (vma = first_vma(current, gate_vma); vma != NULL;
48764 vma = next_vma(vma, gate_vma))
48765 - size += vma_dump_size(vma, mm_flags);
48766 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48767 return size;
48768 }
48769
48770 @@ -2116,7 +2563,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48771
48772 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
48773
48774 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
48775 + offset += elf_core_vma_data_size(gate_vma, cprm);
48776 offset += elf_core_extra_data_size();
48777 e_shoff = offset;
48778
48779 @@ -2130,10 +2577,12 @@ static int elf_core_dump(struct coredump_params *cprm)
48780 offset = dataoff;
48781
48782 size += sizeof(*elf);
48783 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48784 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
48785 goto end_coredump;
48786
48787 size += sizeof(*phdr4note);
48788 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48789 if (size > cprm->limit
48790 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
48791 goto end_coredump;
48792 @@ -2147,7 +2596,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48793 phdr.p_offset = offset;
48794 phdr.p_vaddr = vma->vm_start;
48795 phdr.p_paddr = 0;
48796 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
48797 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48798 phdr.p_memsz = vma->vm_end - vma->vm_start;
48799 offset += phdr.p_filesz;
48800 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
48801 @@ -2158,6 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48802 phdr.p_align = ELF_EXEC_PAGESIZE;
48803
48804 size += sizeof(phdr);
48805 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48806 if (size > cprm->limit
48807 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
48808 goto end_coredump;
48809 @@ -2182,7 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48810 unsigned long addr;
48811 unsigned long end;
48812
48813 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
48814 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48815
48816 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
48817 struct page *page;
48818 @@ -2191,6 +2641,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48819 page = get_dump_page(addr);
48820 if (page) {
48821 void *kaddr = kmap(page);
48822 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
48823 stop = ((size += PAGE_SIZE) > cprm->limit) ||
48824 !dump_write(cprm->file, kaddr,
48825 PAGE_SIZE);
48826 @@ -2208,6 +2659,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48827
48828 if (e_phnum == PN_XNUM) {
48829 size += sizeof(*shdr4extnum);
48830 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48831 if (size > cprm->limit
48832 || !dump_write(cprm->file, shdr4extnum,
48833 sizeof(*shdr4extnum)))
48834 @@ -2228,6 +2680,97 @@ out:
48835
48836 #endif /* CONFIG_ELF_CORE */
48837
48838 +#ifdef CONFIG_PAX_MPROTECT
48839 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
48840 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
48841 + * we'll remove VM_MAYWRITE for good on RELRO segments.
48842 + *
48843 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
48844 + * basis because we want to allow the common case and not the special ones.
48845 + */
48846 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
48847 +{
48848 + struct elfhdr elf_h;
48849 + struct elf_phdr elf_p;
48850 + unsigned long i;
48851 + unsigned long oldflags;
48852 + bool is_textrel_rw, is_textrel_rx, is_relro;
48853 +
48854 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
48855 + return;
48856 +
48857 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
48858 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
48859 +
48860 +#ifdef CONFIG_PAX_ELFRELOCS
48861 + /* possible TEXTREL */
48862 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
48863 + 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);
48864 +#else
48865 + is_textrel_rw = false;
48866 + is_textrel_rx = false;
48867 +#endif
48868 +
48869 + /* possible RELRO */
48870 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
48871 +
48872 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
48873 + return;
48874 +
48875 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
48876 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
48877 +
48878 +#ifdef CONFIG_PAX_ETEXECRELOCS
48879 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48880 +#else
48881 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
48882 +#endif
48883 +
48884 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48885 + !elf_check_arch(&elf_h) ||
48886 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
48887 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
48888 + return;
48889 +
48890 + for (i = 0UL; i < elf_h.e_phnum; i++) {
48891 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
48892 + return;
48893 + switch (elf_p.p_type) {
48894 + case PT_DYNAMIC:
48895 + if (!is_textrel_rw && !is_textrel_rx)
48896 + continue;
48897 + i = 0UL;
48898 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
48899 + elf_dyn dyn;
48900 +
48901 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
48902 + return;
48903 + if (dyn.d_tag == DT_NULL)
48904 + return;
48905 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
48906 + gr_log_textrel(vma);
48907 + if (is_textrel_rw)
48908 + vma->vm_flags |= VM_MAYWRITE;
48909 + else
48910 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
48911 + vma->vm_flags &= ~VM_MAYWRITE;
48912 + return;
48913 + }
48914 + i++;
48915 + }
48916 + return;
48917 +
48918 + case PT_GNU_RELRO:
48919 + if (!is_relro)
48920 + continue;
48921 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
48922 + vma->vm_flags &= ~VM_MAYWRITE;
48923 + return;
48924 + }
48925 + }
48926 +}
48927 +#endif
48928 +
48929 static int __init init_elf_binfmt(void)
48930 {
48931 register_binfmt(&elf_format);
48932 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
48933 index 2036d21..b0430d0 100644
48934 --- a/fs/binfmt_flat.c
48935 +++ b/fs/binfmt_flat.c
48936 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
48937 realdatastart = (unsigned long) -ENOMEM;
48938 printk("Unable to allocate RAM for process data, errno %d\n",
48939 (int)-realdatastart);
48940 + down_write(&current->mm->mmap_sem);
48941 vm_munmap(textpos, text_len);
48942 + up_write(&current->mm->mmap_sem);
48943 ret = realdatastart;
48944 goto err;
48945 }
48946 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48947 }
48948 if (IS_ERR_VALUE(result)) {
48949 printk("Unable to read data+bss, errno %d\n", (int)-result);
48950 + down_write(&current->mm->mmap_sem);
48951 vm_munmap(textpos, text_len);
48952 vm_munmap(realdatastart, len);
48953 + up_write(&current->mm->mmap_sem);
48954 ret = result;
48955 goto err;
48956 }
48957 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48958 }
48959 if (IS_ERR_VALUE(result)) {
48960 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
48961 + down_write(&current->mm->mmap_sem);
48962 vm_munmap(textpos, text_len + data_len + extra +
48963 MAX_SHARED_LIBS * sizeof(unsigned long));
48964 + up_write(&current->mm->mmap_sem);
48965 ret = result;
48966 goto err;
48967 }
48968 diff --git a/fs/bio.c b/fs/bio.c
48969 index b96fc6c..431d628 100644
48970 --- a/fs/bio.c
48971 +++ b/fs/bio.c
48972 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
48973 /*
48974 * Overflow, abort
48975 */
48976 - if (end < start)
48977 + if (end < start || end - start > INT_MAX - nr_pages)
48978 return ERR_PTR(-EINVAL);
48979
48980 nr_pages += end - start;
48981 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
48982 /*
48983 * Overflow, abort
48984 */
48985 - if (end < start)
48986 + if (end < start || end - start > INT_MAX - nr_pages)
48987 return ERR_PTR(-EINVAL);
48988
48989 nr_pages += end - start;
48990 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
48991 const int read = bio_data_dir(bio) == READ;
48992 struct bio_map_data *bmd = bio->bi_private;
48993 int i;
48994 - char *p = bmd->sgvecs[0].iov_base;
48995 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
48996
48997 __bio_for_each_segment(bvec, bio, i, 0) {
48998 char *addr = page_address(bvec->bv_page);
48999 diff --git a/fs/block_dev.c b/fs/block_dev.c
49000 index aae187a..fd790ba 100644
49001 --- a/fs/block_dev.c
49002 +++ b/fs/block_dev.c
49003 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49004 else if (bdev->bd_contains == bdev)
49005 return true; /* is a whole device which isn't held */
49006
49007 - else if (whole->bd_holder == bd_may_claim)
49008 + else if (whole->bd_holder == (void *)bd_may_claim)
49009 return true; /* is a partition of a device that is being partitioned */
49010 else if (whole->bd_holder != NULL)
49011 return false; /* is a partition of a held device */
49012 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49013 index ca9d8f1..8c0142d 100644
49014 --- a/fs/btrfs/ctree.c
49015 +++ b/fs/btrfs/ctree.c
49016 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49017 free_extent_buffer(buf);
49018 add_root_to_dirty_list(root);
49019 } else {
49020 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49021 - parent_start = parent->start;
49022 - else
49023 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49024 + if (parent)
49025 + parent_start = parent->start;
49026 + else
49027 + parent_start = 0;
49028 + } else
49029 parent_start = 0;
49030
49031 WARN_ON(trans->transid != btrfs_header_generation(parent));
49032 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49033 index f49b62f..07834ab 100644
49034 --- a/fs/btrfs/ioctl.c
49035 +++ b/fs/btrfs/ioctl.c
49036 @@ -3077,9 +3077,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49037 for (i = 0; i < num_types; i++) {
49038 struct btrfs_space_info *tmp;
49039
49040 + /* Don't copy in more than we allocated */
49041 if (!slot_count)
49042 break;
49043
49044 + slot_count--;
49045 +
49046 info = NULL;
49047 rcu_read_lock();
49048 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49049 @@ -3101,10 +3104,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49050 memcpy(dest, &space, sizeof(space));
49051 dest++;
49052 space_args.total_spaces++;
49053 - slot_count--;
49054 }
49055 - if (!slot_count)
49056 - break;
49057 }
49058 up_read(&info->groups_sem);
49059 }
49060 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49061 index f6b8859..54fe8c5 100644
49062 --- a/fs/btrfs/super.c
49063 +++ b/fs/btrfs/super.c
49064 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49065 function, line, errstr);
49066 return;
49067 }
49068 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49069 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49070 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49071 }
49072 /*
49073 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49074 index 622f469..e8d2d55 100644
49075 --- a/fs/cachefiles/bind.c
49076 +++ b/fs/cachefiles/bind.c
49077 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49078 args);
49079
49080 /* start by checking things over */
49081 - ASSERT(cache->fstop_percent >= 0 &&
49082 - cache->fstop_percent < cache->fcull_percent &&
49083 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49084 cache->fcull_percent < cache->frun_percent &&
49085 cache->frun_percent < 100);
49086
49087 - ASSERT(cache->bstop_percent >= 0 &&
49088 - cache->bstop_percent < cache->bcull_percent &&
49089 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49090 cache->bcull_percent < cache->brun_percent &&
49091 cache->brun_percent < 100);
49092
49093 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49094 index 0a1467b..6a53245 100644
49095 --- a/fs/cachefiles/daemon.c
49096 +++ b/fs/cachefiles/daemon.c
49097 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49098 if (n > buflen)
49099 return -EMSGSIZE;
49100
49101 - if (copy_to_user(_buffer, buffer, n) != 0)
49102 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49103 return -EFAULT;
49104
49105 return n;
49106 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49107 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49108 return -EIO;
49109
49110 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49111 + if (datalen > PAGE_SIZE - 1)
49112 return -EOPNOTSUPP;
49113
49114 /* drag the command string into the kernel so we can parse it */
49115 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49116 if (args[0] != '%' || args[1] != '\0')
49117 return -EINVAL;
49118
49119 - if (fstop < 0 || fstop >= cache->fcull_percent)
49120 + if (fstop >= cache->fcull_percent)
49121 return cachefiles_daemon_range_error(cache, args);
49122
49123 cache->fstop_percent = fstop;
49124 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49125 if (args[0] != '%' || args[1] != '\0')
49126 return -EINVAL;
49127
49128 - if (bstop < 0 || bstop >= cache->bcull_percent)
49129 + if (bstop >= cache->bcull_percent)
49130 return cachefiles_daemon_range_error(cache, args);
49131
49132 cache->bstop_percent = bstop;
49133 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49134 index 4938251..7e01445 100644
49135 --- a/fs/cachefiles/internal.h
49136 +++ b/fs/cachefiles/internal.h
49137 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49138 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49139 struct rb_root active_nodes; /* active nodes (can't be culled) */
49140 rwlock_t active_lock; /* lock for active_nodes */
49141 - atomic_t gravecounter; /* graveyard uniquifier */
49142 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49143 unsigned frun_percent; /* when to stop culling (% files) */
49144 unsigned fcull_percent; /* when to start culling (% files) */
49145 unsigned fstop_percent; /* when to stop allocating (% files) */
49146 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49147 * proc.c
49148 */
49149 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49150 -extern atomic_t cachefiles_lookup_histogram[HZ];
49151 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49152 -extern atomic_t cachefiles_create_histogram[HZ];
49153 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49154 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49155 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49156
49157 extern int __init cachefiles_proc_init(void);
49158 extern void cachefiles_proc_cleanup(void);
49159 static inline
49160 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49161 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49162 {
49163 unsigned long jif = jiffies - start_jif;
49164 if (jif >= HZ)
49165 jif = HZ - 1;
49166 - atomic_inc(&histogram[jif]);
49167 + atomic_inc_unchecked(&histogram[jif]);
49168 }
49169
49170 #else
49171 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49172 index 8c01c5fc..15f982e 100644
49173 --- a/fs/cachefiles/namei.c
49174 +++ b/fs/cachefiles/namei.c
49175 @@ -317,7 +317,7 @@ try_again:
49176 /* first step is to make up a grave dentry in the graveyard */
49177 sprintf(nbuffer, "%08x%08x",
49178 (uint32_t) get_seconds(),
49179 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49180 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49181
49182 /* do the multiway lock magic */
49183 trap = lock_rename(cache->graveyard, dir);
49184 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49185 index eccd339..4c1d995 100644
49186 --- a/fs/cachefiles/proc.c
49187 +++ b/fs/cachefiles/proc.c
49188 @@ -14,9 +14,9 @@
49189 #include <linux/seq_file.h>
49190 #include "internal.h"
49191
49192 -atomic_t cachefiles_lookup_histogram[HZ];
49193 -atomic_t cachefiles_mkdir_histogram[HZ];
49194 -atomic_t cachefiles_create_histogram[HZ];
49195 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49196 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49197 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49198
49199 /*
49200 * display the latency histogram
49201 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49202 return 0;
49203 default:
49204 index = (unsigned long) v - 3;
49205 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49206 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49207 - z = atomic_read(&cachefiles_create_histogram[index]);
49208 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49209 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49210 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49211 if (x == 0 && y == 0 && z == 0)
49212 return 0;
49213
49214 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49215 index 4809922..aab2c39 100644
49216 --- a/fs/cachefiles/rdwr.c
49217 +++ b/fs/cachefiles/rdwr.c
49218 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49219 old_fs = get_fs();
49220 set_fs(KERNEL_DS);
49221 ret = file->f_op->write(
49222 - file, (const void __user *) data, len, &pos);
49223 + file, (const void __force_user *) data, len, &pos);
49224 set_fs(old_fs);
49225 kunmap(page);
49226 if (ret != len)
49227 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49228 index 6d797f4..0ace2e5 100644
49229 --- a/fs/ceph/dir.c
49230 +++ b/fs/ceph/dir.c
49231 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49232 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49233 struct ceph_mds_client *mdsc = fsc->mdsc;
49234 unsigned frag = fpos_frag(filp->f_pos);
49235 - int off = fpos_off(filp->f_pos);
49236 + unsigned int off = fpos_off(filp->f_pos);
49237 int err;
49238 u32 ftype;
49239 struct ceph_mds_reply_info_parsed *rinfo;
49240 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49241 index d9ea6ed..1e6c8ac 100644
49242 --- a/fs/cifs/cifs_debug.c
49243 +++ b/fs/cifs/cifs_debug.c
49244 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49245
49246 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49247 #ifdef CONFIG_CIFS_STATS2
49248 - atomic_set(&totBufAllocCount, 0);
49249 - atomic_set(&totSmBufAllocCount, 0);
49250 + atomic_set_unchecked(&totBufAllocCount, 0);
49251 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49252 #endif /* CONFIG_CIFS_STATS2 */
49253 spin_lock(&cifs_tcp_ses_lock);
49254 list_for_each(tmp1, &cifs_tcp_ses_list) {
49255 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49256 tcon = list_entry(tmp3,
49257 struct cifs_tcon,
49258 tcon_list);
49259 - atomic_set(&tcon->num_smbs_sent, 0);
49260 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49261 if (server->ops->clear_stats)
49262 server->ops->clear_stats(tcon);
49263 }
49264 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49265 smBufAllocCount.counter, cifs_min_small);
49266 #ifdef CONFIG_CIFS_STATS2
49267 seq_printf(m, "Total Large %d Small %d Allocations\n",
49268 - atomic_read(&totBufAllocCount),
49269 - atomic_read(&totSmBufAllocCount));
49270 + atomic_read_unchecked(&totBufAllocCount),
49271 + atomic_read_unchecked(&totSmBufAllocCount));
49272 #endif /* CONFIG_CIFS_STATS2 */
49273
49274 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49275 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49276 if (tcon->need_reconnect)
49277 seq_puts(m, "\tDISCONNECTED ");
49278 seq_printf(m, "\nSMBs: %d",
49279 - atomic_read(&tcon->num_smbs_sent));
49280 + atomic_read_unchecked(&tcon->num_smbs_sent));
49281 if (server->ops->print_stats)
49282 server->ops->print_stats(m, tcon);
49283 }
49284 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49285 index 345fc89..b2acae5 100644
49286 --- a/fs/cifs/cifsfs.c
49287 +++ b/fs/cifs/cifsfs.c
49288 @@ -1033,7 +1033,7 @@ cifs_init_request_bufs(void)
49289 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49290 cifs_req_cachep = kmem_cache_create("cifs_request",
49291 CIFSMaxBufSize + max_hdr_size, 0,
49292 - SLAB_HWCACHE_ALIGN, NULL);
49293 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49294 if (cifs_req_cachep == NULL)
49295 return -ENOMEM;
49296
49297 @@ -1060,7 +1060,7 @@ cifs_init_request_bufs(void)
49298 efficient to alloc 1 per page off the slab compared to 17K (5page)
49299 alloc of large cifs buffers even when page debugging is on */
49300 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49301 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49302 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49303 NULL);
49304 if (cifs_sm_req_cachep == NULL) {
49305 mempool_destroy(cifs_req_poolp);
49306 @@ -1145,8 +1145,8 @@ init_cifs(void)
49307 atomic_set(&bufAllocCount, 0);
49308 atomic_set(&smBufAllocCount, 0);
49309 #ifdef CONFIG_CIFS_STATS2
49310 - atomic_set(&totBufAllocCount, 0);
49311 - atomic_set(&totSmBufAllocCount, 0);
49312 + atomic_set_unchecked(&totBufAllocCount, 0);
49313 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49314 #endif /* CONFIG_CIFS_STATS2 */
49315
49316 atomic_set(&midCount, 0);
49317 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49318 index 4f07f6f..55de8ce 100644
49319 --- a/fs/cifs/cifsglob.h
49320 +++ b/fs/cifs/cifsglob.h
49321 @@ -751,35 +751,35 @@ struct cifs_tcon {
49322 __u16 Flags; /* optional support bits */
49323 enum statusEnum tidStatus;
49324 #ifdef CONFIG_CIFS_STATS
49325 - atomic_t num_smbs_sent;
49326 + atomic_unchecked_t num_smbs_sent;
49327 union {
49328 struct {
49329 - atomic_t num_writes;
49330 - atomic_t num_reads;
49331 - atomic_t num_flushes;
49332 - atomic_t num_oplock_brks;
49333 - atomic_t num_opens;
49334 - atomic_t num_closes;
49335 - atomic_t num_deletes;
49336 - atomic_t num_mkdirs;
49337 - atomic_t num_posixopens;
49338 - atomic_t num_posixmkdirs;
49339 - atomic_t num_rmdirs;
49340 - atomic_t num_renames;
49341 - atomic_t num_t2renames;
49342 - atomic_t num_ffirst;
49343 - atomic_t num_fnext;
49344 - atomic_t num_fclose;
49345 - atomic_t num_hardlinks;
49346 - atomic_t num_symlinks;
49347 - atomic_t num_locks;
49348 - atomic_t num_acl_get;
49349 - atomic_t num_acl_set;
49350 + atomic_unchecked_t num_writes;
49351 + atomic_unchecked_t num_reads;
49352 + atomic_unchecked_t num_flushes;
49353 + atomic_unchecked_t num_oplock_brks;
49354 + atomic_unchecked_t num_opens;
49355 + atomic_unchecked_t num_closes;
49356 + atomic_unchecked_t num_deletes;
49357 + atomic_unchecked_t num_mkdirs;
49358 + atomic_unchecked_t num_posixopens;
49359 + atomic_unchecked_t num_posixmkdirs;
49360 + atomic_unchecked_t num_rmdirs;
49361 + atomic_unchecked_t num_renames;
49362 + atomic_unchecked_t num_t2renames;
49363 + atomic_unchecked_t num_ffirst;
49364 + atomic_unchecked_t num_fnext;
49365 + atomic_unchecked_t num_fclose;
49366 + atomic_unchecked_t num_hardlinks;
49367 + atomic_unchecked_t num_symlinks;
49368 + atomic_unchecked_t num_locks;
49369 + atomic_unchecked_t num_acl_get;
49370 + atomic_unchecked_t num_acl_set;
49371 } cifs_stats;
49372 #ifdef CONFIG_CIFS_SMB2
49373 struct {
49374 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49375 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49376 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49377 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49378 } smb2_stats;
49379 #endif /* CONFIG_CIFS_SMB2 */
49380 } stats;
49381 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49382 }
49383
49384 #ifdef CONFIG_CIFS_STATS
49385 -#define cifs_stats_inc atomic_inc
49386 +#define cifs_stats_inc atomic_inc_unchecked
49387
49388 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49389 unsigned int bytes)
49390 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49391 /* Various Debug counters */
49392 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49393 #ifdef CONFIG_CIFS_STATS2
49394 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49395 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49396 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49397 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49398 #endif
49399 GLOBAL_EXTERN atomic_t smBufAllocCount;
49400 GLOBAL_EXTERN atomic_t midCount;
49401 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49402 index 9f6c4c4..8de307a 100644
49403 --- a/fs/cifs/link.c
49404 +++ b/fs/cifs/link.c
49405 @@ -616,7 +616,7 @@ symlink_exit:
49406
49407 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49408 {
49409 - char *p = nd_get_link(nd);
49410 + const char *p = nd_get_link(nd);
49411 if (!IS_ERR(p))
49412 kfree(p);
49413 }
49414 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49415 index 1b15bf8..1ce489e 100644
49416 --- a/fs/cifs/misc.c
49417 +++ b/fs/cifs/misc.c
49418 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49419 memset(ret_buf, 0, buf_size + 3);
49420 atomic_inc(&bufAllocCount);
49421 #ifdef CONFIG_CIFS_STATS2
49422 - atomic_inc(&totBufAllocCount);
49423 + atomic_inc_unchecked(&totBufAllocCount);
49424 #endif /* CONFIG_CIFS_STATS2 */
49425 }
49426
49427 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49428 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49429 atomic_inc(&smBufAllocCount);
49430 #ifdef CONFIG_CIFS_STATS2
49431 - atomic_inc(&totSmBufAllocCount);
49432 + atomic_inc_unchecked(&totSmBufAllocCount);
49433 #endif /* CONFIG_CIFS_STATS2 */
49434
49435 }
49436 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49437 index 47bc5a8..10decbe 100644
49438 --- a/fs/cifs/smb1ops.c
49439 +++ b/fs/cifs/smb1ops.c
49440 @@ -586,27 +586,27 @@ static void
49441 cifs_clear_stats(struct cifs_tcon *tcon)
49442 {
49443 #ifdef CONFIG_CIFS_STATS
49444 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49445 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49446 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49447 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49448 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49449 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49450 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49451 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49452 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49453 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49454 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49455 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49456 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49457 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49458 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49459 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49460 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49461 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49462 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49463 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49464 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
49465 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
49466 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
49467 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
49468 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49469 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
49470 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
49471 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49472 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
49473 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
49474 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
49475 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
49476 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
49477 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
49478 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
49479 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
49480 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49481 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49482 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49483 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49484 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49485 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49486 #endif
49487 }
49488
49489 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49490 {
49491 #ifdef CONFIG_CIFS_STATS
49492 seq_printf(m, " Oplocks breaks: %d",
49493 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49494 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49495 seq_printf(m, "\nReads: %d Bytes: %llu",
49496 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49497 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49498 (long long)(tcon->bytes_read));
49499 seq_printf(m, "\nWrites: %d Bytes: %llu",
49500 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49501 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49502 (long long)(tcon->bytes_written));
49503 seq_printf(m, "\nFlushes: %d",
49504 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49505 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49506 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49507 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49508 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49509 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49510 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49511 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49512 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49513 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49514 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49515 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49516 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49517 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49518 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49519 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49520 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49521 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49522 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49523 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49524 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49525 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49526 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49527 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49528 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49529 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49530 seq_printf(m, "\nRenames: %d T2 Renames %d",
49531 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49532 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49533 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49534 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49535 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
49536 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
49537 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
49538 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
49539 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
49540 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
49541 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
49542 #endif
49543 }
49544
49545 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
49546 index bceffe7..cd1ae59 100644
49547 --- a/fs/cifs/smb2ops.c
49548 +++ b/fs/cifs/smb2ops.c
49549 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
49550 #ifdef CONFIG_CIFS_STATS
49551 int i;
49552 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
49553 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49554 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49555 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49556 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49557 }
49558 #endif
49559 }
49560 @@ -284,66 +284,66 @@ static void
49561 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49562 {
49563 #ifdef CONFIG_CIFS_STATS
49564 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49565 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49566 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49567 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49568 seq_printf(m, "\nNegotiates: %d sent %d failed",
49569 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
49570 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
49571 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
49572 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
49573 seq_printf(m, "\nSessionSetups: %d sent %d failed",
49574 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
49575 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
49576 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
49577 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
49578 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
49579 seq_printf(m, "\nLogoffs: %d sent %d failed",
49580 - atomic_read(&sent[SMB2_LOGOFF_HE]),
49581 - atomic_read(&failed[SMB2_LOGOFF_HE]));
49582 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
49583 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
49584 seq_printf(m, "\nTreeConnects: %d sent %d failed",
49585 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
49586 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
49587 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
49588 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
49589 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
49590 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
49591 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
49592 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
49593 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
49594 seq_printf(m, "\nCreates: %d sent %d failed",
49595 - atomic_read(&sent[SMB2_CREATE_HE]),
49596 - atomic_read(&failed[SMB2_CREATE_HE]));
49597 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
49598 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
49599 seq_printf(m, "\nCloses: %d sent %d failed",
49600 - atomic_read(&sent[SMB2_CLOSE_HE]),
49601 - atomic_read(&failed[SMB2_CLOSE_HE]));
49602 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
49603 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
49604 seq_printf(m, "\nFlushes: %d sent %d failed",
49605 - atomic_read(&sent[SMB2_FLUSH_HE]),
49606 - atomic_read(&failed[SMB2_FLUSH_HE]));
49607 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
49608 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
49609 seq_printf(m, "\nReads: %d sent %d failed",
49610 - atomic_read(&sent[SMB2_READ_HE]),
49611 - atomic_read(&failed[SMB2_READ_HE]));
49612 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
49613 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
49614 seq_printf(m, "\nWrites: %d sent %d failed",
49615 - atomic_read(&sent[SMB2_WRITE_HE]),
49616 - atomic_read(&failed[SMB2_WRITE_HE]));
49617 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
49618 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
49619 seq_printf(m, "\nLocks: %d sent %d failed",
49620 - atomic_read(&sent[SMB2_LOCK_HE]),
49621 - atomic_read(&failed[SMB2_LOCK_HE]));
49622 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
49623 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
49624 seq_printf(m, "\nIOCTLs: %d sent %d failed",
49625 - atomic_read(&sent[SMB2_IOCTL_HE]),
49626 - atomic_read(&failed[SMB2_IOCTL_HE]));
49627 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
49628 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
49629 seq_printf(m, "\nCancels: %d sent %d failed",
49630 - atomic_read(&sent[SMB2_CANCEL_HE]),
49631 - atomic_read(&failed[SMB2_CANCEL_HE]));
49632 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
49633 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
49634 seq_printf(m, "\nEchos: %d sent %d failed",
49635 - atomic_read(&sent[SMB2_ECHO_HE]),
49636 - atomic_read(&failed[SMB2_ECHO_HE]));
49637 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
49638 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
49639 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
49640 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
49641 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
49642 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
49643 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
49644 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
49645 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
49646 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
49647 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
49648 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
49649 seq_printf(m, "\nQueryInfos: %d sent %d failed",
49650 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
49651 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
49652 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
49653 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
49654 seq_printf(m, "\nSetInfos: %d sent %d failed",
49655 - atomic_read(&sent[SMB2_SET_INFO_HE]),
49656 - atomic_read(&failed[SMB2_SET_INFO_HE]));
49657 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
49658 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
49659 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
49660 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
49661 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
49662 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
49663 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
49664 #endif
49665 }
49666
49667 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
49668 index 41d9d07..dbb4772 100644
49669 --- a/fs/cifs/smb2pdu.c
49670 +++ b/fs/cifs/smb2pdu.c
49671 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
49672 default:
49673 cERROR(1, "info level %u isn't supported",
49674 srch_inf->info_level);
49675 - rc = -EINVAL;
49676 - goto qdir_exit;
49677 + return -EINVAL;
49678 }
49679
49680 req->FileIndex = cpu_to_le32(index);
49681 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
49682 index 1da168c..8bc7ff6 100644
49683 --- a/fs/coda/cache.c
49684 +++ b/fs/coda/cache.c
49685 @@ -24,7 +24,7 @@
49686 #include "coda_linux.h"
49687 #include "coda_cache.h"
49688
49689 -static atomic_t permission_epoch = ATOMIC_INIT(0);
49690 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
49691
49692 /* replace or extend an acl cache hit */
49693 void coda_cache_enter(struct inode *inode, int mask)
49694 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
49695 struct coda_inode_info *cii = ITOC(inode);
49696
49697 spin_lock(&cii->c_lock);
49698 - cii->c_cached_epoch = atomic_read(&permission_epoch);
49699 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
49700 if (!uid_eq(cii->c_uid, current_fsuid())) {
49701 cii->c_uid = current_fsuid();
49702 cii->c_cached_perm = mask;
49703 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
49704 {
49705 struct coda_inode_info *cii = ITOC(inode);
49706 spin_lock(&cii->c_lock);
49707 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
49708 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
49709 spin_unlock(&cii->c_lock);
49710 }
49711
49712 /* remove all acl caches */
49713 void coda_cache_clear_all(struct super_block *sb)
49714 {
49715 - atomic_inc(&permission_epoch);
49716 + atomic_inc_unchecked(&permission_epoch);
49717 }
49718
49719
49720 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
49721 spin_lock(&cii->c_lock);
49722 hit = (mask & cii->c_cached_perm) == mask &&
49723 uid_eq(cii->c_uid, current_fsuid()) &&
49724 - cii->c_cached_epoch == atomic_read(&permission_epoch);
49725 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
49726 spin_unlock(&cii->c_lock);
49727
49728 return hit;
49729 diff --git a/fs/compat.c b/fs/compat.c
49730 index d487985..c9e04b1 100644
49731 --- a/fs/compat.c
49732 +++ b/fs/compat.c
49733 @@ -54,7 +54,7 @@
49734 #include <asm/ioctls.h>
49735 #include "internal.h"
49736
49737 -int compat_log = 1;
49738 +int compat_log = 0;
49739
49740 int compat_printk(const char *fmt, ...)
49741 {
49742 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
49743
49744 set_fs(KERNEL_DS);
49745 /* The __user pointer cast is valid because of the set_fs() */
49746 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
49747 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
49748 set_fs(oldfs);
49749 /* truncating is ok because it's a user address */
49750 if (!ret)
49751 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
49752 goto out;
49753
49754 ret = -EINVAL;
49755 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
49756 + if (nr_segs > UIO_MAXIOV)
49757 goto out;
49758 if (nr_segs > fast_segs) {
49759 ret = -ENOMEM;
49760 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
49761
49762 struct compat_readdir_callback {
49763 struct compat_old_linux_dirent __user *dirent;
49764 + struct file * file;
49765 int result;
49766 };
49767
49768 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
49769 buf->result = -EOVERFLOW;
49770 return -EOVERFLOW;
49771 }
49772 +
49773 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49774 + return 0;
49775 +
49776 buf->result++;
49777 dirent = buf->dirent;
49778 if (!access_ok(VERIFY_WRITE, dirent,
49779 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
49780
49781 buf.result = 0;
49782 buf.dirent = dirent;
49783 + buf.file = f.file;
49784
49785 error = vfs_readdir(f.file, compat_fillonedir, &buf);
49786 if (buf.result)
49787 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
49788 struct compat_getdents_callback {
49789 struct compat_linux_dirent __user *current_dir;
49790 struct compat_linux_dirent __user *previous;
49791 + struct file * file;
49792 int count;
49793 int error;
49794 };
49795 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
49796 buf->error = -EOVERFLOW;
49797 return -EOVERFLOW;
49798 }
49799 +
49800 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49801 + return 0;
49802 +
49803 dirent = buf->previous;
49804 if (dirent) {
49805 if (__put_user(offset, &dirent->d_off))
49806 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49807 buf.previous = NULL;
49808 buf.count = count;
49809 buf.error = 0;
49810 + buf.file = f.file;
49811
49812 error = vfs_readdir(f.file, compat_filldir, &buf);
49813 if (error >= 0)
49814 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49815 struct compat_getdents_callback64 {
49816 struct linux_dirent64 __user *current_dir;
49817 struct linux_dirent64 __user *previous;
49818 + struct file * file;
49819 int count;
49820 int error;
49821 };
49822 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
49823 buf->error = -EINVAL; /* only used if we fail.. */
49824 if (reclen > buf->count)
49825 return -EINVAL;
49826 +
49827 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49828 + return 0;
49829 +
49830 dirent = buf->previous;
49831
49832 if (dirent) {
49833 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
49834 buf.previous = NULL;
49835 buf.count = count;
49836 buf.error = 0;
49837 + buf.file = f.file;
49838
49839 error = vfs_readdir(f.file, compat_filldir64, &buf);
49840 if (error >= 0)
49841 error = buf.error;
49842 lastdirent = buf.previous;
49843 if (lastdirent) {
49844 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
49845 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
49846 if (__put_user_unaligned(d_off, &lastdirent->d_off))
49847 error = -EFAULT;
49848 else
49849 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
49850 index a81147e..20bf2b5 100644
49851 --- a/fs/compat_binfmt_elf.c
49852 +++ b/fs/compat_binfmt_elf.c
49853 @@ -30,11 +30,13 @@
49854 #undef elf_phdr
49855 #undef elf_shdr
49856 #undef elf_note
49857 +#undef elf_dyn
49858 #undef elf_addr_t
49859 #define elfhdr elf32_hdr
49860 #define elf_phdr elf32_phdr
49861 #define elf_shdr elf32_shdr
49862 #define elf_note elf32_note
49863 +#define elf_dyn Elf32_Dyn
49864 #define elf_addr_t Elf32_Addr
49865
49866 /*
49867 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
49868 index 3ced75f..b28d192 100644
49869 --- a/fs/compat_ioctl.c
49870 +++ b/fs/compat_ioctl.c
49871 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
49872 return -EFAULT;
49873 if (__get_user(udata, &ss32->iomem_base))
49874 return -EFAULT;
49875 - ss.iomem_base = compat_ptr(udata);
49876 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
49877 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
49878 __get_user(ss.port_high, &ss32->port_high))
49879 return -EFAULT;
49880 @@ -704,8 +704,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
49881 for (i = 0; i < nmsgs; i++) {
49882 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
49883 return -EFAULT;
49884 - if (get_user(datap, &umsgs[i].buf) ||
49885 - put_user(compat_ptr(datap), &tmsgs[i].buf))
49886 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
49887 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
49888 return -EFAULT;
49889 }
49890 return sys_ioctl(fd, cmd, (unsigned long)tdata);
49891 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
49892 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
49893 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
49894 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
49895 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49896 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49897 return -EFAULT;
49898
49899 return ioctl_preallocate(file, p);
49900 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
49901 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
49902 {
49903 unsigned int a, b;
49904 - a = *(unsigned int *)p;
49905 - b = *(unsigned int *)q;
49906 + a = *(const unsigned int *)p;
49907 + b = *(const unsigned int *)q;
49908 if (a > b)
49909 return 1;
49910 if (a < b)
49911 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
49912 index 7aabc6a..34c1197 100644
49913 --- a/fs/configfs/dir.c
49914 +++ b/fs/configfs/dir.c
49915 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49916 }
49917 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
49918 struct configfs_dirent *next;
49919 - const char * name;
49920 + const unsigned char * name;
49921 + char d_name[sizeof(next->s_dentry->d_iname)];
49922 int len;
49923 struct inode *inode = NULL;
49924
49925 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49926 continue;
49927
49928 name = configfs_get_name(next);
49929 - len = strlen(name);
49930 + if (next->s_dentry && name == next->s_dentry->d_iname) {
49931 + len = next->s_dentry->d_name.len;
49932 + memcpy(d_name, name, len);
49933 + name = d_name;
49934 + } else
49935 + len = strlen(name);
49936
49937 /*
49938 * We'll have a dentry and an inode for
49939 diff --git a/fs/coredump.c b/fs/coredump.c
49940 index c647965..a77bff3 100644
49941 --- a/fs/coredump.c
49942 +++ b/fs/coredump.c
49943 @@ -52,7 +52,7 @@ struct core_name {
49944 char *corename;
49945 int used, size;
49946 };
49947 -static atomic_t call_count = ATOMIC_INIT(1);
49948 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
49949
49950 /* The maximal length of core_pattern is also specified in sysctl.c */
49951
49952 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
49953 {
49954 char *old_corename = cn->corename;
49955
49956 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
49957 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
49958 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
49959
49960 if (!cn->corename) {
49961 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
49962 int pid_in_pattern = 0;
49963 int err = 0;
49964
49965 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
49966 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
49967 cn->corename = kmalloc(cn->size, GFP_KERNEL);
49968 cn->used = 0;
49969
49970 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
49971 pipe = file_inode(file)->i_pipe;
49972
49973 pipe_lock(pipe);
49974 - pipe->readers++;
49975 - pipe->writers--;
49976 + atomic_inc(&pipe->readers);
49977 + atomic_dec(&pipe->writers);
49978
49979 - while ((pipe->readers > 1) && (!signal_pending(current))) {
49980 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
49981 wake_up_interruptible_sync(&pipe->wait);
49982 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
49983 pipe_wait(pipe);
49984 }
49985
49986 - pipe->readers--;
49987 - pipe->writers++;
49988 + atomic_dec(&pipe->readers);
49989 + atomic_inc(&pipe->writers);
49990 pipe_unlock(pipe);
49991
49992 }
49993 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
49994 int ispipe;
49995 struct files_struct *displaced;
49996 bool need_nonrelative = false;
49997 - static atomic_t core_dump_count = ATOMIC_INIT(0);
49998 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
49999 + long signr = siginfo->si_signo;
50000 struct coredump_params cprm = {
50001 .siginfo = siginfo,
50002 .regs = signal_pt_regs(),
50003 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50004 .mm_flags = mm->flags,
50005 };
50006
50007 - audit_core_dumps(siginfo->si_signo);
50008 + audit_core_dumps(signr);
50009 +
50010 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50011 + gr_handle_brute_attach(cprm.mm_flags);
50012
50013 binfmt = mm->binfmt;
50014 if (!binfmt || !binfmt->core_dump)
50015 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50016 need_nonrelative = true;
50017 }
50018
50019 - retval = coredump_wait(siginfo->si_signo, &core_state);
50020 + retval = coredump_wait(signr, &core_state);
50021 if (retval < 0)
50022 goto fail_creds;
50023
50024 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50025 }
50026 cprm.limit = RLIM_INFINITY;
50027
50028 - dump_count = atomic_inc_return(&core_dump_count);
50029 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50030 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50031 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50032 task_tgid_vnr(current), current->comm);
50033 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50034 } else {
50035 struct inode *inode;
50036
50037 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50038 +
50039 if (cprm.limit < binfmt->min_coredump)
50040 goto fail_unlock;
50041
50042 @@ -640,7 +646,7 @@ close_fail:
50043 filp_close(cprm.file, NULL);
50044 fail_dropcount:
50045 if (ispipe)
50046 - atomic_dec(&core_dump_count);
50047 + atomic_dec_unchecked(&core_dump_count);
50048 fail_unlock:
50049 kfree(cn.corename);
50050 fail_corename:
50051 @@ -659,7 +665,7 @@ fail:
50052 */
50053 int dump_write(struct file *file, const void *addr, int nr)
50054 {
50055 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50056 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50057 }
50058 EXPORT_SYMBOL(dump_write);
50059
50060 diff --git a/fs/dcache.c b/fs/dcache.c
50061 index e689268..f36956e 100644
50062 --- a/fs/dcache.c
50063 +++ b/fs/dcache.c
50064 @@ -3100,7 +3100,7 @@ void __init vfs_caches_init(unsigned long mempages)
50065 mempages -= reserve;
50066
50067 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50068 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50069 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50070
50071 dcache_init();
50072 inode_init();
50073 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50074 index 4888cb3..e0f7cf8 100644
50075 --- a/fs/debugfs/inode.c
50076 +++ b/fs/debugfs/inode.c
50077 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50078 */
50079 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50080 {
50081 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50082 + return __create_file(name, S_IFDIR | S_IRWXU,
50083 +#else
50084 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50085 +#endif
50086 parent, NULL, NULL);
50087 }
50088 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50089 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50090 index 5eab400..810a3f5 100644
50091 --- a/fs/ecryptfs/inode.c
50092 +++ b/fs/ecryptfs/inode.c
50093 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50094 old_fs = get_fs();
50095 set_fs(get_ds());
50096 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50097 - (char __user *)lower_buf,
50098 + (char __force_user *)lower_buf,
50099 PATH_MAX);
50100 set_fs(old_fs);
50101 if (rc < 0)
50102 @@ -706,7 +706,7 @@ out:
50103 static void
50104 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50105 {
50106 - char *buf = nd_get_link(nd);
50107 + const char *buf = nd_get_link(nd);
50108 if (!IS_ERR(buf)) {
50109 /* Free the char* */
50110 kfree(buf);
50111 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50112 index e4141f2..d8263e8 100644
50113 --- a/fs/ecryptfs/miscdev.c
50114 +++ b/fs/ecryptfs/miscdev.c
50115 @@ -304,7 +304,7 @@ check_list:
50116 goto out_unlock_msg_ctx;
50117 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50118 if (msg_ctx->msg) {
50119 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50120 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50121 goto out_unlock_msg_ctx;
50122 i += packet_length_size;
50123 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50124 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50125 index 6a16053..2155147 100644
50126 --- a/fs/ecryptfs/read_write.c
50127 +++ b/fs/ecryptfs/read_write.c
50128 @@ -240,7 +240,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50129 return -EIO;
50130 fs_save = get_fs();
50131 set_fs(get_ds());
50132 - rc = vfs_read(lower_file, data, size, &offset);
50133 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50134 set_fs(fs_save);
50135 return rc;
50136 }
50137 diff --git a/fs/exec.c b/fs/exec.c
50138 index 6d56ff2..3bc6638 100644
50139 --- a/fs/exec.c
50140 +++ b/fs/exec.c
50141 @@ -55,8 +55,20 @@
50142 #include <linux/pipe_fs_i.h>
50143 #include <linux/oom.h>
50144 #include <linux/compat.h>
50145 +#include <linux/random.h>
50146 +#include <linux/seq_file.h>
50147 +#include <linux/coredump.h>
50148 +#include <linux/mman.h>
50149 +
50150 +#ifdef CONFIG_PAX_REFCOUNT
50151 +#include <linux/kallsyms.h>
50152 +#include <linux/kdebug.h>
50153 +#endif
50154 +
50155 +#include <trace/events/fs.h>
50156
50157 #include <asm/uaccess.h>
50158 +#include <asm/sections.h>
50159 #include <asm/mmu_context.h>
50160 #include <asm/tlb.h>
50161
50162 @@ -66,6 +78,18 @@
50163
50164 #include <trace/events/sched.h>
50165
50166 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50167 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50168 +{
50169 + 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");
50170 +}
50171 +#endif
50172 +
50173 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50174 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50175 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50176 +#endif
50177 +
50178 int suid_dumpable = 0;
50179
50180 static LIST_HEAD(formats);
50181 @@ -75,8 +99,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50182 {
50183 BUG_ON(!fmt);
50184 write_lock(&binfmt_lock);
50185 - insert ? list_add(&fmt->lh, &formats) :
50186 - list_add_tail(&fmt->lh, &formats);
50187 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50188 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50189 write_unlock(&binfmt_lock);
50190 }
50191
50192 @@ -85,7 +109,7 @@ EXPORT_SYMBOL(__register_binfmt);
50193 void unregister_binfmt(struct linux_binfmt * fmt)
50194 {
50195 write_lock(&binfmt_lock);
50196 - list_del(&fmt->lh);
50197 + pax_list_del((struct list_head *)&fmt->lh);
50198 write_unlock(&binfmt_lock);
50199 }
50200
50201 @@ -180,18 +204,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50202 int write)
50203 {
50204 struct page *page;
50205 - int ret;
50206
50207 -#ifdef CONFIG_STACK_GROWSUP
50208 - if (write) {
50209 - ret = expand_downwards(bprm->vma, pos);
50210 - if (ret < 0)
50211 - return NULL;
50212 - }
50213 -#endif
50214 - ret = get_user_pages(current, bprm->mm, pos,
50215 - 1, write, 1, &page, NULL);
50216 - if (ret <= 0)
50217 + if (0 > expand_downwards(bprm->vma, pos))
50218 + return NULL;
50219 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50220 return NULL;
50221
50222 if (write) {
50223 @@ -207,6 +223,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50224 if (size <= ARG_MAX)
50225 return page;
50226
50227 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50228 + // only allow 512KB for argv+env on suid/sgid binaries
50229 + // to prevent easy ASLR exhaustion
50230 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50231 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50232 + (size > (512 * 1024))) {
50233 + put_page(page);
50234 + return NULL;
50235 + }
50236 +#endif
50237 +
50238 /*
50239 * Limit to 1/4-th the stack size for the argv+env strings.
50240 * This ensures that:
50241 @@ -266,6 +293,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50242 vma->vm_end = STACK_TOP_MAX;
50243 vma->vm_start = vma->vm_end - PAGE_SIZE;
50244 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50245 +
50246 +#ifdef CONFIG_PAX_SEGMEXEC
50247 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50248 +#endif
50249 +
50250 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50251 INIT_LIST_HEAD(&vma->anon_vma_chain);
50252
50253 @@ -276,6 +308,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50254 mm->stack_vm = mm->total_vm = 1;
50255 up_write(&mm->mmap_sem);
50256 bprm->p = vma->vm_end - sizeof(void *);
50257 +
50258 +#ifdef CONFIG_PAX_RANDUSTACK
50259 + if (randomize_va_space)
50260 + bprm->p ^= random32() & ~PAGE_MASK;
50261 +#endif
50262 +
50263 return 0;
50264 err:
50265 up_write(&mm->mmap_sem);
50266 @@ -396,7 +434,7 @@ struct user_arg_ptr {
50267 } ptr;
50268 };
50269
50270 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50271 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50272 {
50273 const char __user *native;
50274
50275 @@ -405,14 +443,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50276 compat_uptr_t compat;
50277
50278 if (get_user(compat, argv.ptr.compat + nr))
50279 - return ERR_PTR(-EFAULT);
50280 + return (const char __force_user *)ERR_PTR(-EFAULT);
50281
50282 return compat_ptr(compat);
50283 }
50284 #endif
50285
50286 if (get_user(native, argv.ptr.native + nr))
50287 - return ERR_PTR(-EFAULT);
50288 + return (const char __force_user *)ERR_PTR(-EFAULT);
50289
50290 return native;
50291 }
50292 @@ -431,7 +469,7 @@ static int count(struct user_arg_ptr argv, int max)
50293 if (!p)
50294 break;
50295
50296 - if (IS_ERR(p))
50297 + if (IS_ERR((const char __force_kernel *)p))
50298 return -EFAULT;
50299
50300 if (i >= max)
50301 @@ -466,7 +504,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50302
50303 ret = -EFAULT;
50304 str = get_user_arg_ptr(argv, argc);
50305 - if (IS_ERR(str))
50306 + if (IS_ERR((const char __force_kernel *)str))
50307 goto out;
50308
50309 len = strnlen_user(str, MAX_ARG_STRLEN);
50310 @@ -548,7 +586,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50311 int r;
50312 mm_segment_t oldfs = get_fs();
50313 struct user_arg_ptr argv = {
50314 - .ptr.native = (const char __user *const __user *)__argv,
50315 + .ptr.native = (const char __force_user * const __force_user *)__argv,
50316 };
50317
50318 set_fs(KERNEL_DS);
50319 @@ -583,7 +621,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50320 unsigned long new_end = old_end - shift;
50321 struct mmu_gather tlb;
50322
50323 - BUG_ON(new_start > new_end);
50324 + if (new_start >= new_end || new_start < mmap_min_addr)
50325 + return -ENOMEM;
50326
50327 /*
50328 * ensure there are no vmas between where we want to go
50329 @@ -592,6 +631,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50330 if (vma != find_vma(mm, new_start))
50331 return -EFAULT;
50332
50333 +#ifdef CONFIG_PAX_SEGMEXEC
50334 + BUG_ON(pax_find_mirror_vma(vma));
50335 +#endif
50336 +
50337 /*
50338 * cover the whole range: [new_start, old_end)
50339 */
50340 @@ -672,10 +715,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50341 stack_top = arch_align_stack(stack_top);
50342 stack_top = PAGE_ALIGN(stack_top);
50343
50344 - if (unlikely(stack_top < mmap_min_addr) ||
50345 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50346 - return -ENOMEM;
50347 -
50348 stack_shift = vma->vm_end - stack_top;
50349
50350 bprm->p -= stack_shift;
50351 @@ -687,8 +726,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50352 bprm->exec -= stack_shift;
50353
50354 down_write(&mm->mmap_sem);
50355 +
50356 + /* Move stack pages down in memory. */
50357 + if (stack_shift) {
50358 + ret = shift_arg_pages(vma, stack_shift);
50359 + if (ret)
50360 + goto out_unlock;
50361 + }
50362 +
50363 vm_flags = VM_STACK_FLAGS;
50364
50365 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50366 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50367 + vm_flags &= ~VM_EXEC;
50368 +
50369 +#ifdef CONFIG_PAX_MPROTECT
50370 + if (mm->pax_flags & MF_PAX_MPROTECT)
50371 + vm_flags &= ~VM_MAYEXEC;
50372 +#endif
50373 +
50374 + }
50375 +#endif
50376 +
50377 /*
50378 * Adjust stack execute permissions; explicitly enable for
50379 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50380 @@ -707,13 +766,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50381 goto out_unlock;
50382 BUG_ON(prev != vma);
50383
50384 - /* Move stack pages down in memory. */
50385 - if (stack_shift) {
50386 - ret = shift_arg_pages(vma, stack_shift);
50387 - if (ret)
50388 - goto out_unlock;
50389 - }
50390 -
50391 /* mprotect_fixup is overkill to remove the temporary stack flags */
50392 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50393
50394 @@ -737,6 +789,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50395 #endif
50396 current->mm->start_stack = bprm->p;
50397 ret = expand_stack(vma, stack_base);
50398 +
50399 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50400 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50401 + unsigned long size;
50402 + vm_flags_t vm_flags;
50403 +
50404 + size = STACK_TOP - vma->vm_end;
50405 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50406 +
50407 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
50408 +
50409 +#ifdef CONFIG_X86
50410 + if (!ret) {
50411 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50412 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
50413 + }
50414 +#endif
50415 +
50416 + }
50417 +#endif
50418 +
50419 if (ret)
50420 ret = -EFAULT;
50421
50422 @@ -772,6 +845,8 @@ struct file *open_exec(const char *name)
50423
50424 fsnotify_open(file);
50425
50426 + trace_open_exec(name);
50427 +
50428 err = deny_write_access(file);
50429 if (err)
50430 goto exit;
50431 @@ -795,7 +870,7 @@ int kernel_read(struct file *file, loff_t offset,
50432 old_fs = get_fs();
50433 set_fs(get_ds());
50434 /* The cast to a user pointer is valid due to the set_fs() */
50435 - result = vfs_read(file, (void __user *)addr, count, &pos);
50436 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
50437 set_fs(old_fs);
50438 return result;
50439 }
50440 @@ -1250,7 +1325,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
50441 }
50442 rcu_read_unlock();
50443
50444 - if (p->fs->users > n_fs) {
50445 + if (atomic_read(&p->fs->users) > n_fs) {
50446 bprm->unsafe |= LSM_UNSAFE_SHARE;
50447 } else {
50448 res = -EAGAIN;
50449 @@ -1450,6 +1525,31 @@ int search_binary_handler(struct linux_binprm *bprm)
50450
50451 EXPORT_SYMBOL(search_binary_handler);
50452
50453 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50454 +static DEFINE_PER_CPU(u64, exec_counter);
50455 +static int __init init_exec_counters(void)
50456 +{
50457 + unsigned int cpu;
50458 +
50459 + for_each_possible_cpu(cpu) {
50460 + per_cpu(exec_counter, cpu) = (u64)cpu;
50461 + }
50462 +
50463 + return 0;
50464 +}
50465 +early_initcall(init_exec_counters);
50466 +static inline void increment_exec_counter(void)
50467 +{
50468 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
50469 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
50470 +}
50471 +#else
50472 +static inline void increment_exec_counter(void) {}
50473 +#endif
50474 +
50475 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
50476 + struct user_arg_ptr argv);
50477 +
50478 /*
50479 * sys_execve() executes a new program.
50480 */
50481 @@ -1457,6 +1557,11 @@ static int do_execve_common(const char *filename,
50482 struct user_arg_ptr argv,
50483 struct user_arg_ptr envp)
50484 {
50485 +#ifdef CONFIG_GRKERNSEC
50486 + struct file *old_exec_file;
50487 + struct acl_subject_label *old_acl;
50488 + struct rlimit old_rlim[RLIM_NLIMITS];
50489 +#endif
50490 struct linux_binprm *bprm;
50491 struct file *file;
50492 struct files_struct *displaced;
50493 @@ -1464,6 +1569,8 @@ static int do_execve_common(const char *filename,
50494 int retval;
50495 const struct cred *cred = current_cred();
50496
50497 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
50498 +
50499 /*
50500 * We move the actual failure in case of RLIMIT_NPROC excess from
50501 * set*uid() to execve() because too many poorly written programs
50502 @@ -1504,12 +1611,27 @@ static int do_execve_common(const char *filename,
50503 if (IS_ERR(file))
50504 goto out_unmark;
50505
50506 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50507 + retval = -EPERM;
50508 + goto out_file;
50509 + }
50510 +
50511 sched_exec();
50512
50513 bprm->file = file;
50514 bprm->filename = filename;
50515 bprm->interp = filename;
50516
50517 + if (gr_process_user_ban()) {
50518 + retval = -EPERM;
50519 + goto out_file;
50520 + }
50521 +
50522 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
50523 + retval = -EACCES;
50524 + goto out_file;
50525 + }
50526 +
50527 retval = bprm_mm_init(bprm);
50528 if (retval)
50529 goto out_file;
50530 @@ -1526,24 +1648,65 @@ static int do_execve_common(const char *filename,
50531 if (retval < 0)
50532 goto out;
50533
50534 +#ifdef CONFIG_GRKERNSEC
50535 + old_acl = current->acl;
50536 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50537 + old_exec_file = current->exec_file;
50538 + get_file(file);
50539 + current->exec_file = file;
50540 +#endif
50541 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50542 + /* limit suid stack to 8MB
50543 + * we saved the old limits above and will restore them if this exec fails
50544 + */
50545 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
50546 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
50547 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
50548 +#endif
50549 +
50550 + if (!gr_tpe_allow(file)) {
50551 + retval = -EACCES;
50552 + goto out_fail;
50553 + }
50554 +
50555 + if (gr_check_crash_exec(file)) {
50556 + retval = -EACCES;
50557 + goto out_fail;
50558 + }
50559 +
50560 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
50561 + bprm->unsafe);
50562 + if (retval < 0)
50563 + goto out_fail;
50564 +
50565 retval = copy_strings_kernel(1, &bprm->filename, bprm);
50566 if (retval < 0)
50567 - goto out;
50568 + goto out_fail;
50569
50570 bprm->exec = bprm->p;
50571 retval = copy_strings(bprm->envc, envp, bprm);
50572 if (retval < 0)
50573 - goto out;
50574 + goto out_fail;
50575
50576 retval = copy_strings(bprm->argc, argv, bprm);
50577 if (retval < 0)
50578 - goto out;
50579 + goto out_fail;
50580 +
50581 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
50582 +
50583 + gr_handle_exec_args(bprm, argv);
50584
50585 retval = search_binary_handler(bprm);
50586 if (retval < 0)
50587 - goto out;
50588 + goto out_fail;
50589 +#ifdef CONFIG_GRKERNSEC
50590 + if (old_exec_file)
50591 + fput(old_exec_file);
50592 +#endif
50593
50594 /* execve succeeded */
50595 +
50596 + increment_exec_counter();
50597 current->fs->in_exec = 0;
50598 current->in_execve = 0;
50599 acct_update_integrals(current);
50600 @@ -1552,6 +1715,14 @@ static int do_execve_common(const char *filename,
50601 put_files_struct(displaced);
50602 return retval;
50603
50604 +out_fail:
50605 +#ifdef CONFIG_GRKERNSEC
50606 + current->acl = old_acl;
50607 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
50608 + fput(current->exec_file);
50609 + current->exec_file = old_exec_file;
50610 +#endif
50611 +
50612 out:
50613 if (bprm->mm) {
50614 acct_arg_size(bprm, 0);
50615 @@ -1700,3 +1871,283 @@ asmlinkage long compat_sys_execve(const char __user * filename,
50616 return error;
50617 }
50618 #endif
50619 +
50620 +int pax_check_flags(unsigned long *flags)
50621 +{
50622 + int retval = 0;
50623 +
50624 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
50625 + if (*flags & MF_PAX_SEGMEXEC)
50626 + {
50627 + *flags &= ~MF_PAX_SEGMEXEC;
50628 + retval = -EINVAL;
50629 + }
50630 +#endif
50631 +
50632 + if ((*flags & MF_PAX_PAGEEXEC)
50633 +
50634 +#ifdef CONFIG_PAX_PAGEEXEC
50635 + && (*flags & MF_PAX_SEGMEXEC)
50636 +#endif
50637 +
50638 + )
50639 + {
50640 + *flags &= ~MF_PAX_PAGEEXEC;
50641 + retval = -EINVAL;
50642 + }
50643 +
50644 + if ((*flags & MF_PAX_MPROTECT)
50645 +
50646 +#ifdef CONFIG_PAX_MPROTECT
50647 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50648 +#endif
50649 +
50650 + )
50651 + {
50652 + *flags &= ~MF_PAX_MPROTECT;
50653 + retval = -EINVAL;
50654 + }
50655 +
50656 + if ((*flags & MF_PAX_EMUTRAMP)
50657 +
50658 +#ifdef CONFIG_PAX_EMUTRAMP
50659 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50660 +#endif
50661 +
50662 + )
50663 + {
50664 + *flags &= ~MF_PAX_EMUTRAMP;
50665 + retval = -EINVAL;
50666 + }
50667 +
50668 + return retval;
50669 +}
50670 +
50671 +EXPORT_SYMBOL(pax_check_flags);
50672 +
50673 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50674 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
50675 +{
50676 + struct task_struct *tsk = current;
50677 + struct mm_struct *mm = current->mm;
50678 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
50679 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
50680 + char *path_exec = NULL;
50681 + char *path_fault = NULL;
50682 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
50683 + siginfo_t info = { };
50684 +
50685 + if (buffer_exec && buffer_fault) {
50686 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
50687 +
50688 + down_read(&mm->mmap_sem);
50689 + vma = mm->mmap;
50690 + while (vma && (!vma_exec || !vma_fault)) {
50691 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
50692 + vma_exec = vma;
50693 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
50694 + vma_fault = vma;
50695 + vma = vma->vm_next;
50696 + }
50697 + if (vma_exec) {
50698 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
50699 + if (IS_ERR(path_exec))
50700 + path_exec = "<path too long>";
50701 + else {
50702 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
50703 + if (path_exec) {
50704 + *path_exec = 0;
50705 + path_exec = buffer_exec;
50706 + } else
50707 + path_exec = "<path too long>";
50708 + }
50709 + }
50710 + if (vma_fault) {
50711 + start = vma_fault->vm_start;
50712 + end = vma_fault->vm_end;
50713 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
50714 + if (vma_fault->vm_file) {
50715 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
50716 + if (IS_ERR(path_fault))
50717 + path_fault = "<path too long>";
50718 + else {
50719 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
50720 + if (path_fault) {
50721 + *path_fault = 0;
50722 + path_fault = buffer_fault;
50723 + } else
50724 + path_fault = "<path too long>";
50725 + }
50726 + } else
50727 + path_fault = "<anonymous mapping>";
50728 + }
50729 + up_read(&mm->mmap_sem);
50730 + }
50731 + if (tsk->signal->curr_ip)
50732 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
50733 + else
50734 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
50735 + 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),
50736 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
50737 + free_page((unsigned long)buffer_exec);
50738 + free_page((unsigned long)buffer_fault);
50739 + pax_report_insns(regs, pc, sp);
50740 + info.si_signo = SIGKILL;
50741 + info.si_errno = 0;
50742 + info.si_code = SI_KERNEL;
50743 + info.si_pid = 0;
50744 + info.si_uid = 0;
50745 + do_coredump(&info);
50746 +}
50747 +#endif
50748 +
50749 +#ifdef CONFIG_PAX_REFCOUNT
50750 +void pax_report_refcount_overflow(struct pt_regs *regs)
50751 +{
50752 + if (current->signal->curr_ip)
50753 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
50754 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
50755 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50756 + else
50757 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
50758 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50759 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
50760 + show_regs(regs);
50761 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
50762 +}
50763 +#endif
50764 +
50765 +#ifdef CONFIG_PAX_USERCOPY
50766 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
50767 +static noinline int check_stack_object(const void *obj, unsigned long len)
50768 +{
50769 + const void * const stack = task_stack_page(current);
50770 + const void * const stackend = stack + THREAD_SIZE;
50771 +
50772 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50773 + const void *frame = NULL;
50774 + const void *oldframe;
50775 +#endif
50776 +
50777 + if (obj + len < obj)
50778 + return -1;
50779 +
50780 + if (obj + len <= stack || stackend <= obj)
50781 + return 0;
50782 +
50783 + if (obj < stack || stackend < obj + len)
50784 + return -1;
50785 +
50786 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50787 + oldframe = __builtin_frame_address(1);
50788 + if (oldframe)
50789 + frame = __builtin_frame_address(2);
50790 + /*
50791 + low ----------------------------------------------> high
50792 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
50793 + ^----------------^
50794 + allow copies only within here
50795 + */
50796 + while (stack <= frame && frame < stackend) {
50797 + /* if obj + len extends past the last frame, this
50798 + check won't pass and the next frame will be 0,
50799 + causing us to bail out and correctly report
50800 + the copy as invalid
50801 + */
50802 + if (obj + len <= frame)
50803 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
50804 + oldframe = frame;
50805 + frame = *(const void * const *)frame;
50806 + }
50807 + return -1;
50808 +#else
50809 + return 1;
50810 +#endif
50811 +}
50812 +
50813 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
50814 +{
50815 + if (current->signal->curr_ip)
50816 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50817 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50818 + else
50819 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50820 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50821 + dump_stack();
50822 + gr_handle_kernel_exploit();
50823 + do_group_exit(SIGKILL);
50824 +}
50825 +#endif
50826 +
50827 +#ifdef CONFIG_PAX_USERCOPY
50828 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
50829 +{
50830 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
50831 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
50832 +#ifdef CONFIG_MODULES
50833 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
50834 +#else
50835 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
50836 +#endif
50837 +
50838 +#else
50839 + unsigned long textlow = (unsigned long)_stext;
50840 + unsigned long texthigh = (unsigned long)_etext;
50841 +#endif
50842 +
50843 + if (high <= textlow || low > texthigh)
50844 + return false;
50845 + else
50846 + return true;
50847 +}
50848 +#endif
50849 +
50850 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
50851 +{
50852 +
50853 +#ifdef CONFIG_PAX_USERCOPY
50854 + const char *type;
50855 +
50856 + if (!n)
50857 + return;
50858 +
50859 + type = check_heap_object(ptr, n);
50860 + if (!type) {
50861 + int ret = check_stack_object(ptr, n);
50862 + if (ret == 1 || ret == 2)
50863 + return;
50864 + if (ret == 0) {
50865 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
50866 + type = "<kernel text>";
50867 + else
50868 + return;
50869 + } else
50870 + type = "<process stack>";
50871 + }
50872 +
50873 + pax_report_usercopy(ptr, n, to_user, type);
50874 +#endif
50875 +
50876 +}
50877 +EXPORT_SYMBOL(__check_object_size);
50878 +
50879 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
50880 +void pax_track_stack(void)
50881 +{
50882 + unsigned long sp = (unsigned long)&sp;
50883 + if (sp < current_thread_info()->lowest_stack &&
50884 + sp > (unsigned long)task_stack_page(current))
50885 + current_thread_info()->lowest_stack = sp;
50886 +}
50887 +EXPORT_SYMBOL(pax_track_stack);
50888 +#endif
50889 +
50890 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
50891 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
50892 +{
50893 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
50894 + dump_stack();
50895 + do_group_exit(SIGKILL);
50896 +}
50897 +EXPORT_SYMBOL(report_size_overflow);
50898 +#endif
50899 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
50900 index 9f9992b..8b59411 100644
50901 --- a/fs/ext2/balloc.c
50902 +++ b/fs/ext2/balloc.c
50903 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
50904
50905 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50906 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50907 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50908 + if (free_blocks < root_blocks + 1 &&
50909 !uid_eq(sbi->s_resuid, current_fsuid()) &&
50910 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50911 - !in_group_p (sbi->s_resgid))) {
50912 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50913 return 0;
50914 }
50915 return 1;
50916 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
50917 index 22548f5..41521d8 100644
50918 --- a/fs/ext3/balloc.c
50919 +++ b/fs/ext3/balloc.c
50920 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
50921
50922 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50923 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50924 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50925 + if (free_blocks < root_blocks + 1 &&
50926 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
50927 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50928 - !in_group_p (sbi->s_resgid))) {
50929 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50930 return 0;
50931 }
50932 return 1;
50933 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
50934 index 92e68b3..115d987 100644
50935 --- a/fs/ext4/balloc.c
50936 +++ b/fs/ext4/balloc.c
50937 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
50938 /* Hm, nope. Are (enough) root reserved clusters available? */
50939 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
50940 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
50941 - capable(CAP_SYS_RESOURCE) ||
50942 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
50943 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
50944 + capable_nolog(CAP_SYS_RESOURCE)) {
50945
50946 if (free_clusters >= (nclusters + dirty_clusters))
50947 return 1;
50948 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
50949 index 3b83cd6..0f34dcd 100644
50950 --- a/fs/ext4/ext4.h
50951 +++ b/fs/ext4/ext4.h
50952 @@ -1254,19 +1254,19 @@ struct ext4_sb_info {
50953 unsigned long s_mb_last_start;
50954
50955 /* stats for buddy allocator */
50956 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
50957 - atomic_t s_bal_success; /* we found long enough chunks */
50958 - atomic_t s_bal_allocated; /* in blocks */
50959 - atomic_t s_bal_ex_scanned; /* total extents scanned */
50960 - atomic_t s_bal_goals; /* goal hits */
50961 - atomic_t s_bal_breaks; /* too long searches */
50962 - atomic_t s_bal_2orders; /* 2^order hits */
50963 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
50964 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
50965 + atomic_unchecked_t s_bal_allocated; /* in blocks */
50966 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
50967 + atomic_unchecked_t s_bal_goals; /* goal hits */
50968 + atomic_unchecked_t s_bal_breaks; /* too long searches */
50969 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
50970 spinlock_t s_bal_lock;
50971 unsigned long s_mb_buddies_generated;
50972 unsigned long long s_mb_generation_time;
50973 - atomic_t s_mb_lost_chunks;
50974 - atomic_t s_mb_preallocated;
50975 - atomic_t s_mb_discarded;
50976 + atomic_unchecked_t s_mb_lost_chunks;
50977 + atomic_unchecked_t s_mb_preallocated;
50978 + atomic_unchecked_t s_mb_discarded;
50979 atomic_t s_lock_busy;
50980
50981 /* locality groups */
50982 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
50983 index f3190ab..84ffb21 100644
50984 --- a/fs/ext4/mballoc.c
50985 +++ b/fs/ext4/mballoc.c
50986 @@ -1754,7 +1754,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
50987 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
50988
50989 if (EXT4_SB(sb)->s_mb_stats)
50990 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
50991 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
50992
50993 break;
50994 }
50995 @@ -2059,7 +2059,7 @@ repeat:
50996 ac->ac_status = AC_STATUS_CONTINUE;
50997 ac->ac_flags |= EXT4_MB_HINT_FIRST;
50998 cr = 3;
50999 - atomic_inc(&sbi->s_mb_lost_chunks);
51000 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51001 goto repeat;
51002 }
51003 }
51004 @@ -2567,25 +2567,25 @@ int ext4_mb_release(struct super_block *sb)
51005 if (sbi->s_mb_stats) {
51006 ext4_msg(sb, KERN_INFO,
51007 "mballoc: %u blocks %u reqs (%u success)",
51008 - atomic_read(&sbi->s_bal_allocated),
51009 - atomic_read(&sbi->s_bal_reqs),
51010 - atomic_read(&sbi->s_bal_success));
51011 + atomic_read_unchecked(&sbi->s_bal_allocated),
51012 + atomic_read_unchecked(&sbi->s_bal_reqs),
51013 + atomic_read_unchecked(&sbi->s_bal_success));
51014 ext4_msg(sb, KERN_INFO,
51015 "mballoc: %u extents scanned, %u goal hits, "
51016 "%u 2^N hits, %u breaks, %u lost",
51017 - atomic_read(&sbi->s_bal_ex_scanned),
51018 - atomic_read(&sbi->s_bal_goals),
51019 - atomic_read(&sbi->s_bal_2orders),
51020 - atomic_read(&sbi->s_bal_breaks),
51021 - atomic_read(&sbi->s_mb_lost_chunks));
51022 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51023 + atomic_read_unchecked(&sbi->s_bal_goals),
51024 + atomic_read_unchecked(&sbi->s_bal_2orders),
51025 + atomic_read_unchecked(&sbi->s_bal_breaks),
51026 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51027 ext4_msg(sb, KERN_INFO,
51028 "mballoc: %lu generated and it took %Lu",
51029 sbi->s_mb_buddies_generated,
51030 sbi->s_mb_generation_time);
51031 ext4_msg(sb, KERN_INFO,
51032 "mballoc: %u preallocated, %u discarded",
51033 - atomic_read(&sbi->s_mb_preallocated),
51034 - atomic_read(&sbi->s_mb_discarded));
51035 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51036 + atomic_read_unchecked(&sbi->s_mb_discarded));
51037 }
51038
51039 free_percpu(sbi->s_locality_groups);
51040 @@ -3039,16 +3039,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51041 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51042
51043 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51044 - atomic_inc(&sbi->s_bal_reqs);
51045 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51046 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51047 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51048 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51049 - atomic_inc(&sbi->s_bal_success);
51050 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51051 + atomic_inc_unchecked(&sbi->s_bal_success);
51052 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51053 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51054 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51055 - atomic_inc(&sbi->s_bal_goals);
51056 + atomic_inc_unchecked(&sbi->s_bal_goals);
51057 if (ac->ac_found > sbi->s_mb_max_to_scan)
51058 - atomic_inc(&sbi->s_bal_breaks);
51059 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51060 }
51061
51062 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51063 @@ -3448,7 +3448,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51064 trace_ext4_mb_new_inode_pa(ac, pa);
51065
51066 ext4_mb_use_inode_pa(ac, pa);
51067 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51068 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51069
51070 ei = EXT4_I(ac->ac_inode);
51071 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51072 @@ -3508,7 +3508,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51073 trace_ext4_mb_new_group_pa(ac, pa);
51074
51075 ext4_mb_use_group_pa(ac, pa);
51076 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51077 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51078
51079 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51080 lg = ac->ac_lg;
51081 @@ -3597,7 +3597,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51082 * from the bitmap and continue.
51083 */
51084 }
51085 - atomic_add(free, &sbi->s_mb_discarded);
51086 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51087
51088 return err;
51089 }
51090 @@ -3615,7 +3615,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51091 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51092 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51093 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51094 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51095 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51096 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51097
51098 return 0;
51099 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51100 index febbe0e..782c4fd 100644
51101 --- a/fs/ext4/super.c
51102 +++ b/fs/ext4/super.c
51103 @@ -2380,7 +2380,7 @@ struct ext4_attr {
51104 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51105 const char *, size_t);
51106 int offset;
51107 -};
51108 +} __do_const;
51109
51110 static int parse_strtoul(const char *buf,
51111 unsigned long max, unsigned long *value)
51112 diff --git a/fs/fat/inode.c b/fs/fat/inode.c
51113 index acf6e47..e7a7fde 100644
51114 --- a/fs/fat/inode.c
51115 +++ b/fs/fat/inode.c
51116 @@ -1223,6 +1223,19 @@ static int fat_read_root(struct inode *inode)
51117 return 0;
51118 }
51119
51120 +static unsigned long calc_fat_clusters(struct super_block *sb)
51121 +{
51122 + struct msdos_sb_info *sbi = MSDOS_SB(sb);
51123 +
51124 + /* Divide first to avoid overflow */
51125 + if (sbi->fat_bits != 12) {
51126 + unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
51127 + return ent_per_sec * sbi->fat_length;
51128 + }
51129 +
51130 + return sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
51131 +}
51132 +
51133 /*
51134 * Read the super block of an MS-DOS FS.
51135 */
51136 @@ -1427,7 +1440,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
51137 sbi->dirty = b->fat16.state & FAT_STATE_DIRTY;
51138
51139 /* check that FAT table does not overflow */
51140 - fat_clusters = sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
51141 + fat_clusters = calc_fat_clusters(sb);
51142 total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT);
51143 if (total_clusters > MAX_FAT(sb)) {
51144 if (!silent)
51145 diff --git a/fs/fcntl.c b/fs/fcntl.c
51146 index 6599222..e7bf0de 100644
51147 --- a/fs/fcntl.c
51148 +++ b/fs/fcntl.c
51149 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51150 if (err)
51151 return err;
51152
51153 + if (gr_handle_chroot_fowner(pid, type))
51154 + return -ENOENT;
51155 + if (gr_check_protected_task_fowner(pid, type))
51156 + return -EACCES;
51157 +
51158 f_modown(filp, pid, type, force);
51159 return 0;
51160 }
51161 diff --git a/fs/fhandle.c b/fs/fhandle.c
51162 index 999ff5c..41f4109 100644
51163 --- a/fs/fhandle.c
51164 +++ b/fs/fhandle.c
51165 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51166 } else
51167 retval = 0;
51168 /* copy the mount id */
51169 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51170 - sizeof(*mnt_id)) ||
51171 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51172 copy_to_user(ufh, handle,
51173 sizeof(struct file_handle) + handle_bytes))
51174 retval = -EFAULT;
51175 diff --git a/fs/fifo.c b/fs/fifo.c
51176 index cf6f434..3d7942c 100644
51177 --- a/fs/fifo.c
51178 +++ b/fs/fifo.c
51179 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51180 */
51181 filp->f_op = &read_pipefifo_fops;
51182 pipe->r_counter++;
51183 - if (pipe->readers++ == 0)
51184 + if (atomic_inc_return(&pipe->readers) == 1)
51185 wake_up_partner(inode);
51186
51187 - if (!pipe->writers) {
51188 + if (!atomic_read(&pipe->writers)) {
51189 if ((filp->f_flags & O_NONBLOCK)) {
51190 /* suppress POLLHUP until we have
51191 * seen a writer */
51192 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51193 * errno=ENXIO when there is no process reading the FIFO.
51194 */
51195 ret = -ENXIO;
51196 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51197 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51198 goto err;
51199
51200 filp->f_op = &write_pipefifo_fops;
51201 pipe->w_counter++;
51202 - if (!pipe->writers++)
51203 + if (atomic_inc_return(&pipe->writers) == 1)
51204 wake_up_partner(inode);
51205
51206 - if (!pipe->readers) {
51207 + if (!atomic_read(&pipe->readers)) {
51208 if (wait_for_partner(inode, &pipe->r_counter))
51209 goto err_wr;
51210 }
51211 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51212 */
51213 filp->f_op = &rdwr_pipefifo_fops;
51214
51215 - pipe->readers++;
51216 - pipe->writers++;
51217 + atomic_inc(&pipe->readers);
51218 + atomic_inc(&pipe->writers);
51219 pipe->r_counter++;
51220 pipe->w_counter++;
51221 - if (pipe->readers == 1 || pipe->writers == 1)
51222 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51223 wake_up_partner(inode);
51224 break;
51225
51226 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51227 return 0;
51228
51229 err_rd:
51230 - if (!--pipe->readers)
51231 + if (atomic_dec_and_test(&pipe->readers))
51232 wake_up_interruptible(&pipe->wait);
51233 ret = -ERESTARTSYS;
51234 goto err;
51235
51236 err_wr:
51237 - if (!--pipe->writers)
51238 + if (atomic_dec_and_test(&pipe->writers))
51239 wake_up_interruptible(&pipe->wait);
51240 ret = -ERESTARTSYS;
51241 goto err;
51242
51243 err:
51244 - if (!pipe->readers && !pipe->writers)
51245 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51246 free_pipe_info(inode);
51247
51248 err_nocleanup:
51249 diff --git a/fs/file.c b/fs/file.c
51250 index 3906d95..5fe379b 100644
51251 --- a/fs/file.c
51252 +++ b/fs/file.c
51253 @@ -16,6 +16,7 @@
51254 #include <linux/slab.h>
51255 #include <linux/vmalloc.h>
51256 #include <linux/file.h>
51257 +#include <linux/security.h>
51258 #include <linux/fdtable.h>
51259 #include <linux/bitops.h>
51260 #include <linux/interrupt.h>
51261 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51262 if (!file)
51263 return __close_fd(files, fd);
51264
51265 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51266 if (fd >= rlimit(RLIMIT_NOFILE))
51267 return -EBADF;
51268
51269 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51270 if (unlikely(oldfd == newfd))
51271 return -EINVAL;
51272
51273 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51274 if (newfd >= rlimit(RLIMIT_NOFILE))
51275 return -EBADF;
51276
51277 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51278 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51279 {
51280 int err;
51281 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51282 if (from >= rlimit(RLIMIT_NOFILE))
51283 return -EINVAL;
51284 err = alloc_fd(from, flags);
51285 diff --git a/fs/filesystems.c b/fs/filesystems.c
51286 index 92567d9..fcd8cbf 100644
51287 --- a/fs/filesystems.c
51288 +++ b/fs/filesystems.c
51289 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
51290 int len = dot ? dot - name : strlen(name);
51291
51292 fs = __get_fs_type(name, len);
51293 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51294 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
51295 +#else
51296 if (!fs && (request_module("fs-%.*s", len, name) == 0))
51297 +#endif
51298 fs = __get_fs_type(name, len);
51299
51300 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51301 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51302 index d8ac61d..79a36f0 100644
51303 --- a/fs/fs_struct.c
51304 +++ b/fs/fs_struct.c
51305 @@ -4,6 +4,7 @@
51306 #include <linux/path.h>
51307 #include <linux/slab.h>
51308 #include <linux/fs_struct.h>
51309 +#include <linux/grsecurity.h>
51310 #include "internal.h"
51311
51312 /*
51313 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
51314 write_seqcount_begin(&fs->seq);
51315 old_root = fs->root;
51316 fs->root = *path;
51317 + gr_set_chroot_entries(current, path);
51318 write_seqcount_end(&fs->seq);
51319 spin_unlock(&fs->lock);
51320 if (old_root.dentry)
51321 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
51322 int hits = 0;
51323 spin_lock(&fs->lock);
51324 write_seqcount_begin(&fs->seq);
51325 + /* this root replacement is only done by pivot_root,
51326 + leave grsec's chroot tagging alone for this task
51327 + so that a pivoted root isn't treated as a chroot
51328 + */
51329 hits += replace_path(&fs->root, old_root, new_root);
51330 hits += replace_path(&fs->pwd, old_root, new_root);
51331 write_seqcount_end(&fs->seq);
51332 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
51333 task_lock(tsk);
51334 spin_lock(&fs->lock);
51335 tsk->fs = NULL;
51336 - kill = !--fs->users;
51337 + gr_clear_chroot_entries(tsk);
51338 + kill = !atomic_dec_return(&fs->users);
51339 spin_unlock(&fs->lock);
51340 task_unlock(tsk);
51341 if (kill)
51342 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51343 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51344 /* We don't need to lock fs - think why ;-) */
51345 if (fs) {
51346 - fs->users = 1;
51347 + atomic_set(&fs->users, 1);
51348 fs->in_exec = 0;
51349 spin_lock_init(&fs->lock);
51350 seqcount_init(&fs->seq);
51351 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51352 spin_lock(&old->lock);
51353 fs->root = old->root;
51354 path_get(&fs->root);
51355 + /* instead of calling gr_set_chroot_entries here,
51356 + we call it from every caller of this function
51357 + */
51358 fs->pwd = old->pwd;
51359 path_get(&fs->pwd);
51360 spin_unlock(&old->lock);
51361 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
51362
51363 task_lock(current);
51364 spin_lock(&fs->lock);
51365 - kill = !--fs->users;
51366 + kill = !atomic_dec_return(&fs->users);
51367 current->fs = new_fs;
51368 + gr_set_chroot_entries(current, &new_fs->root);
51369 spin_unlock(&fs->lock);
51370 task_unlock(current);
51371
51372 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51373
51374 int current_umask(void)
51375 {
51376 - return current->fs->umask;
51377 + return current->fs->umask | gr_acl_umask();
51378 }
51379 EXPORT_SYMBOL(current_umask);
51380
51381 /* to be mentioned only in INIT_TASK */
51382 struct fs_struct init_fs = {
51383 - .users = 1,
51384 + .users = ATOMIC_INIT(1),
51385 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51386 .seq = SEQCNT_ZERO,
51387 .umask = 0022,
51388 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51389 index e2cba1f..17a25bb 100644
51390 --- a/fs/fscache/cookie.c
51391 +++ b/fs/fscache/cookie.c
51392 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51393 parent ? (char *) parent->def->name : "<no-parent>",
51394 def->name, netfs_data);
51395
51396 - fscache_stat(&fscache_n_acquires);
51397 + fscache_stat_unchecked(&fscache_n_acquires);
51398
51399 /* if there's no parent cookie, then we don't create one here either */
51400 if (!parent) {
51401 - fscache_stat(&fscache_n_acquires_null);
51402 + fscache_stat_unchecked(&fscache_n_acquires_null);
51403 _leave(" [no parent]");
51404 return NULL;
51405 }
51406 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51407 /* allocate and initialise a cookie */
51408 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51409 if (!cookie) {
51410 - fscache_stat(&fscache_n_acquires_oom);
51411 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51412 _leave(" [ENOMEM]");
51413 return NULL;
51414 }
51415 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51416
51417 switch (cookie->def->type) {
51418 case FSCACHE_COOKIE_TYPE_INDEX:
51419 - fscache_stat(&fscache_n_cookie_index);
51420 + fscache_stat_unchecked(&fscache_n_cookie_index);
51421 break;
51422 case FSCACHE_COOKIE_TYPE_DATAFILE:
51423 - fscache_stat(&fscache_n_cookie_data);
51424 + fscache_stat_unchecked(&fscache_n_cookie_data);
51425 break;
51426 default:
51427 - fscache_stat(&fscache_n_cookie_special);
51428 + fscache_stat_unchecked(&fscache_n_cookie_special);
51429 break;
51430 }
51431
51432 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51433 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51434 atomic_dec(&parent->n_children);
51435 __fscache_cookie_put(cookie);
51436 - fscache_stat(&fscache_n_acquires_nobufs);
51437 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51438 _leave(" = NULL");
51439 return NULL;
51440 }
51441 }
51442
51443 - fscache_stat(&fscache_n_acquires_ok);
51444 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51445 _leave(" = %p", cookie);
51446 return cookie;
51447 }
51448 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51449 cache = fscache_select_cache_for_object(cookie->parent);
51450 if (!cache) {
51451 up_read(&fscache_addremove_sem);
51452 - fscache_stat(&fscache_n_acquires_no_cache);
51453 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51454 _leave(" = -ENOMEDIUM [no cache]");
51455 return -ENOMEDIUM;
51456 }
51457 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51458 object = cache->ops->alloc_object(cache, cookie);
51459 fscache_stat_d(&fscache_n_cop_alloc_object);
51460 if (IS_ERR(object)) {
51461 - fscache_stat(&fscache_n_object_no_alloc);
51462 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51463 ret = PTR_ERR(object);
51464 goto error;
51465 }
51466
51467 - fscache_stat(&fscache_n_object_alloc);
51468 + fscache_stat_unchecked(&fscache_n_object_alloc);
51469
51470 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51471
51472 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51473
51474 _enter("{%s}", cookie->def->name);
51475
51476 - fscache_stat(&fscache_n_invalidates);
51477 + fscache_stat_unchecked(&fscache_n_invalidates);
51478
51479 /* Only permit invalidation of data files. Invalidating an index will
51480 * require the caller to release all its attachments to the tree rooted
51481 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
51482 {
51483 struct fscache_object *object;
51484
51485 - fscache_stat(&fscache_n_updates);
51486 + fscache_stat_unchecked(&fscache_n_updates);
51487
51488 if (!cookie) {
51489 - fscache_stat(&fscache_n_updates_null);
51490 + fscache_stat_unchecked(&fscache_n_updates_null);
51491 _leave(" [no cookie]");
51492 return;
51493 }
51494 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51495 struct fscache_object *object;
51496 unsigned long event;
51497
51498 - fscache_stat(&fscache_n_relinquishes);
51499 + fscache_stat_unchecked(&fscache_n_relinquishes);
51500 if (retire)
51501 - fscache_stat(&fscache_n_relinquishes_retire);
51502 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
51503
51504 if (!cookie) {
51505 - fscache_stat(&fscache_n_relinquishes_null);
51506 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
51507 _leave(" [no cookie]");
51508 return;
51509 }
51510 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51511
51512 /* wait for the cookie to finish being instantiated (or to fail) */
51513 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
51514 - fscache_stat(&fscache_n_relinquishes_waitcrt);
51515 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
51516 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
51517 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
51518 }
51519 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
51520 index ee38fef..0a326d4 100644
51521 --- a/fs/fscache/internal.h
51522 +++ b/fs/fscache/internal.h
51523 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
51524 * stats.c
51525 */
51526 #ifdef CONFIG_FSCACHE_STATS
51527 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51528 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51529 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51530 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51531
51532 -extern atomic_t fscache_n_op_pend;
51533 -extern atomic_t fscache_n_op_run;
51534 -extern atomic_t fscache_n_op_enqueue;
51535 -extern atomic_t fscache_n_op_deferred_release;
51536 -extern atomic_t fscache_n_op_release;
51537 -extern atomic_t fscache_n_op_gc;
51538 -extern atomic_t fscache_n_op_cancelled;
51539 -extern atomic_t fscache_n_op_rejected;
51540 +extern atomic_unchecked_t fscache_n_op_pend;
51541 +extern atomic_unchecked_t fscache_n_op_run;
51542 +extern atomic_unchecked_t fscache_n_op_enqueue;
51543 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51544 +extern atomic_unchecked_t fscache_n_op_release;
51545 +extern atomic_unchecked_t fscache_n_op_gc;
51546 +extern atomic_unchecked_t fscache_n_op_cancelled;
51547 +extern atomic_unchecked_t fscache_n_op_rejected;
51548
51549 -extern atomic_t fscache_n_attr_changed;
51550 -extern atomic_t fscache_n_attr_changed_ok;
51551 -extern atomic_t fscache_n_attr_changed_nobufs;
51552 -extern atomic_t fscache_n_attr_changed_nomem;
51553 -extern atomic_t fscache_n_attr_changed_calls;
51554 +extern atomic_unchecked_t fscache_n_attr_changed;
51555 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
51556 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
51557 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
51558 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
51559
51560 -extern atomic_t fscache_n_allocs;
51561 -extern atomic_t fscache_n_allocs_ok;
51562 -extern atomic_t fscache_n_allocs_wait;
51563 -extern atomic_t fscache_n_allocs_nobufs;
51564 -extern atomic_t fscache_n_allocs_intr;
51565 -extern atomic_t fscache_n_allocs_object_dead;
51566 -extern atomic_t fscache_n_alloc_ops;
51567 -extern atomic_t fscache_n_alloc_op_waits;
51568 +extern atomic_unchecked_t fscache_n_allocs;
51569 +extern atomic_unchecked_t fscache_n_allocs_ok;
51570 +extern atomic_unchecked_t fscache_n_allocs_wait;
51571 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
51572 +extern atomic_unchecked_t fscache_n_allocs_intr;
51573 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
51574 +extern atomic_unchecked_t fscache_n_alloc_ops;
51575 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
51576
51577 -extern atomic_t fscache_n_retrievals;
51578 -extern atomic_t fscache_n_retrievals_ok;
51579 -extern atomic_t fscache_n_retrievals_wait;
51580 -extern atomic_t fscache_n_retrievals_nodata;
51581 -extern atomic_t fscache_n_retrievals_nobufs;
51582 -extern atomic_t fscache_n_retrievals_intr;
51583 -extern atomic_t fscache_n_retrievals_nomem;
51584 -extern atomic_t fscache_n_retrievals_object_dead;
51585 -extern atomic_t fscache_n_retrieval_ops;
51586 -extern atomic_t fscache_n_retrieval_op_waits;
51587 +extern atomic_unchecked_t fscache_n_retrievals;
51588 +extern atomic_unchecked_t fscache_n_retrievals_ok;
51589 +extern atomic_unchecked_t fscache_n_retrievals_wait;
51590 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
51591 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
51592 +extern atomic_unchecked_t fscache_n_retrievals_intr;
51593 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
51594 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
51595 +extern atomic_unchecked_t fscache_n_retrieval_ops;
51596 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
51597
51598 -extern atomic_t fscache_n_stores;
51599 -extern atomic_t fscache_n_stores_ok;
51600 -extern atomic_t fscache_n_stores_again;
51601 -extern atomic_t fscache_n_stores_nobufs;
51602 -extern atomic_t fscache_n_stores_oom;
51603 -extern atomic_t fscache_n_store_ops;
51604 -extern atomic_t fscache_n_store_calls;
51605 -extern atomic_t fscache_n_store_pages;
51606 -extern atomic_t fscache_n_store_radix_deletes;
51607 -extern atomic_t fscache_n_store_pages_over_limit;
51608 +extern atomic_unchecked_t fscache_n_stores;
51609 +extern atomic_unchecked_t fscache_n_stores_ok;
51610 +extern atomic_unchecked_t fscache_n_stores_again;
51611 +extern atomic_unchecked_t fscache_n_stores_nobufs;
51612 +extern atomic_unchecked_t fscache_n_stores_oom;
51613 +extern atomic_unchecked_t fscache_n_store_ops;
51614 +extern atomic_unchecked_t fscache_n_store_calls;
51615 +extern atomic_unchecked_t fscache_n_store_pages;
51616 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
51617 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
51618
51619 -extern atomic_t fscache_n_store_vmscan_not_storing;
51620 -extern atomic_t fscache_n_store_vmscan_gone;
51621 -extern atomic_t fscache_n_store_vmscan_busy;
51622 -extern atomic_t fscache_n_store_vmscan_cancelled;
51623 -extern atomic_t fscache_n_store_vmscan_wait;
51624 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
51625 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
51626 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
51627 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
51628 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
51629
51630 -extern atomic_t fscache_n_marks;
51631 -extern atomic_t fscache_n_uncaches;
51632 +extern atomic_unchecked_t fscache_n_marks;
51633 +extern atomic_unchecked_t fscache_n_uncaches;
51634
51635 -extern atomic_t fscache_n_acquires;
51636 -extern atomic_t fscache_n_acquires_null;
51637 -extern atomic_t fscache_n_acquires_no_cache;
51638 -extern atomic_t fscache_n_acquires_ok;
51639 -extern atomic_t fscache_n_acquires_nobufs;
51640 -extern atomic_t fscache_n_acquires_oom;
51641 +extern atomic_unchecked_t fscache_n_acquires;
51642 +extern atomic_unchecked_t fscache_n_acquires_null;
51643 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
51644 +extern atomic_unchecked_t fscache_n_acquires_ok;
51645 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
51646 +extern atomic_unchecked_t fscache_n_acquires_oom;
51647
51648 -extern atomic_t fscache_n_invalidates;
51649 -extern atomic_t fscache_n_invalidates_run;
51650 +extern atomic_unchecked_t fscache_n_invalidates;
51651 +extern atomic_unchecked_t fscache_n_invalidates_run;
51652
51653 -extern atomic_t fscache_n_updates;
51654 -extern atomic_t fscache_n_updates_null;
51655 -extern atomic_t fscache_n_updates_run;
51656 +extern atomic_unchecked_t fscache_n_updates;
51657 +extern atomic_unchecked_t fscache_n_updates_null;
51658 +extern atomic_unchecked_t fscache_n_updates_run;
51659
51660 -extern atomic_t fscache_n_relinquishes;
51661 -extern atomic_t fscache_n_relinquishes_null;
51662 -extern atomic_t fscache_n_relinquishes_waitcrt;
51663 -extern atomic_t fscache_n_relinquishes_retire;
51664 +extern atomic_unchecked_t fscache_n_relinquishes;
51665 +extern atomic_unchecked_t fscache_n_relinquishes_null;
51666 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
51667 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
51668
51669 -extern atomic_t fscache_n_cookie_index;
51670 -extern atomic_t fscache_n_cookie_data;
51671 -extern atomic_t fscache_n_cookie_special;
51672 +extern atomic_unchecked_t fscache_n_cookie_index;
51673 +extern atomic_unchecked_t fscache_n_cookie_data;
51674 +extern atomic_unchecked_t fscache_n_cookie_special;
51675
51676 -extern atomic_t fscache_n_object_alloc;
51677 -extern atomic_t fscache_n_object_no_alloc;
51678 -extern atomic_t fscache_n_object_lookups;
51679 -extern atomic_t fscache_n_object_lookups_negative;
51680 -extern atomic_t fscache_n_object_lookups_positive;
51681 -extern atomic_t fscache_n_object_lookups_timed_out;
51682 -extern atomic_t fscache_n_object_created;
51683 -extern atomic_t fscache_n_object_avail;
51684 -extern atomic_t fscache_n_object_dead;
51685 +extern atomic_unchecked_t fscache_n_object_alloc;
51686 +extern atomic_unchecked_t fscache_n_object_no_alloc;
51687 +extern atomic_unchecked_t fscache_n_object_lookups;
51688 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
51689 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
51690 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
51691 +extern atomic_unchecked_t fscache_n_object_created;
51692 +extern atomic_unchecked_t fscache_n_object_avail;
51693 +extern atomic_unchecked_t fscache_n_object_dead;
51694
51695 -extern atomic_t fscache_n_checkaux_none;
51696 -extern atomic_t fscache_n_checkaux_okay;
51697 -extern atomic_t fscache_n_checkaux_update;
51698 -extern atomic_t fscache_n_checkaux_obsolete;
51699 +extern atomic_unchecked_t fscache_n_checkaux_none;
51700 +extern atomic_unchecked_t fscache_n_checkaux_okay;
51701 +extern atomic_unchecked_t fscache_n_checkaux_update;
51702 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
51703
51704 extern atomic_t fscache_n_cop_alloc_object;
51705 extern atomic_t fscache_n_cop_lookup_object;
51706 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
51707 atomic_inc(stat);
51708 }
51709
51710 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
51711 +{
51712 + atomic_inc_unchecked(stat);
51713 +}
51714 +
51715 static inline void fscache_stat_d(atomic_t *stat)
51716 {
51717 atomic_dec(stat);
51718 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
51719
51720 #define __fscache_stat(stat) (NULL)
51721 #define fscache_stat(stat) do {} while (0)
51722 +#define fscache_stat_unchecked(stat) do {} while (0)
51723 #define fscache_stat_d(stat) do {} while (0)
51724 #endif
51725
51726 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
51727 index 50d41c1..10ee117 100644
51728 --- a/fs/fscache/object.c
51729 +++ b/fs/fscache/object.c
51730 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51731 /* Invalidate an object on disk */
51732 case FSCACHE_OBJECT_INVALIDATING:
51733 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
51734 - fscache_stat(&fscache_n_invalidates_run);
51735 + fscache_stat_unchecked(&fscache_n_invalidates_run);
51736 fscache_stat(&fscache_n_cop_invalidate_object);
51737 fscache_invalidate_object(object);
51738 fscache_stat_d(&fscache_n_cop_invalidate_object);
51739 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51740 /* update the object metadata on disk */
51741 case FSCACHE_OBJECT_UPDATING:
51742 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
51743 - fscache_stat(&fscache_n_updates_run);
51744 + fscache_stat_unchecked(&fscache_n_updates_run);
51745 fscache_stat(&fscache_n_cop_update_object);
51746 object->cache->ops->update_object(object);
51747 fscache_stat_d(&fscache_n_cop_update_object);
51748 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51749 spin_lock(&object->lock);
51750 object->state = FSCACHE_OBJECT_DEAD;
51751 spin_unlock(&object->lock);
51752 - fscache_stat(&fscache_n_object_dead);
51753 + fscache_stat_unchecked(&fscache_n_object_dead);
51754 goto terminal_transit;
51755
51756 /* handle the parent cache of this object being withdrawn from
51757 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51758 spin_lock(&object->lock);
51759 object->state = FSCACHE_OBJECT_DEAD;
51760 spin_unlock(&object->lock);
51761 - fscache_stat(&fscache_n_object_dead);
51762 + fscache_stat_unchecked(&fscache_n_object_dead);
51763 goto terminal_transit;
51764
51765 /* complain about the object being woken up once it is
51766 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51767 parent->cookie->def->name, cookie->def->name,
51768 object->cache->tag->name);
51769
51770 - fscache_stat(&fscache_n_object_lookups);
51771 + fscache_stat_unchecked(&fscache_n_object_lookups);
51772 fscache_stat(&fscache_n_cop_lookup_object);
51773 ret = object->cache->ops->lookup_object(object);
51774 fscache_stat_d(&fscache_n_cop_lookup_object);
51775 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51776 if (ret == -ETIMEDOUT) {
51777 /* probably stuck behind another object, so move this one to
51778 * the back of the queue */
51779 - fscache_stat(&fscache_n_object_lookups_timed_out);
51780 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
51781 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51782 }
51783
51784 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
51785
51786 spin_lock(&object->lock);
51787 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51788 - fscache_stat(&fscache_n_object_lookups_negative);
51789 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
51790
51791 /* transit here to allow write requests to begin stacking up
51792 * and read requests to begin returning ENODATA */
51793 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
51794 * result, in which case there may be data available */
51795 spin_lock(&object->lock);
51796 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51797 - fscache_stat(&fscache_n_object_lookups_positive);
51798 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
51799
51800 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
51801
51802 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
51803 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51804 } else {
51805 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
51806 - fscache_stat(&fscache_n_object_created);
51807 + fscache_stat_unchecked(&fscache_n_object_created);
51808
51809 object->state = FSCACHE_OBJECT_AVAILABLE;
51810 spin_unlock(&object->lock);
51811 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
51812 fscache_enqueue_dependents(object);
51813
51814 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
51815 - fscache_stat(&fscache_n_object_avail);
51816 + fscache_stat_unchecked(&fscache_n_object_avail);
51817
51818 _leave("");
51819 }
51820 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51821 enum fscache_checkaux result;
51822
51823 if (!object->cookie->def->check_aux) {
51824 - fscache_stat(&fscache_n_checkaux_none);
51825 + fscache_stat_unchecked(&fscache_n_checkaux_none);
51826 return FSCACHE_CHECKAUX_OKAY;
51827 }
51828
51829 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51830 switch (result) {
51831 /* entry okay as is */
51832 case FSCACHE_CHECKAUX_OKAY:
51833 - fscache_stat(&fscache_n_checkaux_okay);
51834 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
51835 break;
51836
51837 /* entry requires update */
51838 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
51839 - fscache_stat(&fscache_n_checkaux_update);
51840 + fscache_stat_unchecked(&fscache_n_checkaux_update);
51841 break;
51842
51843 /* entry requires deletion */
51844 case FSCACHE_CHECKAUX_OBSOLETE:
51845 - fscache_stat(&fscache_n_checkaux_obsolete);
51846 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
51847 break;
51848
51849 default:
51850 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
51851 index 762a9ec..2023284 100644
51852 --- a/fs/fscache/operation.c
51853 +++ b/fs/fscache/operation.c
51854 @@ -17,7 +17,7 @@
51855 #include <linux/slab.h>
51856 #include "internal.h"
51857
51858 -atomic_t fscache_op_debug_id;
51859 +atomic_unchecked_t fscache_op_debug_id;
51860 EXPORT_SYMBOL(fscache_op_debug_id);
51861
51862 /**
51863 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
51864 ASSERTCMP(atomic_read(&op->usage), >, 0);
51865 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
51866
51867 - fscache_stat(&fscache_n_op_enqueue);
51868 + fscache_stat_unchecked(&fscache_n_op_enqueue);
51869 switch (op->flags & FSCACHE_OP_TYPE) {
51870 case FSCACHE_OP_ASYNC:
51871 _debug("queue async");
51872 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
51873 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
51874 if (op->processor)
51875 fscache_enqueue_operation(op);
51876 - fscache_stat(&fscache_n_op_run);
51877 + fscache_stat_unchecked(&fscache_n_op_run);
51878 }
51879
51880 /*
51881 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51882 if (object->n_in_progress > 0) {
51883 atomic_inc(&op->usage);
51884 list_add_tail(&op->pend_link, &object->pending_ops);
51885 - fscache_stat(&fscache_n_op_pend);
51886 + fscache_stat_unchecked(&fscache_n_op_pend);
51887 } else if (!list_empty(&object->pending_ops)) {
51888 atomic_inc(&op->usage);
51889 list_add_tail(&op->pend_link, &object->pending_ops);
51890 - fscache_stat(&fscache_n_op_pend);
51891 + fscache_stat_unchecked(&fscache_n_op_pend);
51892 fscache_start_operations(object);
51893 } else {
51894 ASSERTCMP(object->n_in_progress, ==, 0);
51895 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51896 object->n_exclusive++; /* reads and writes must wait */
51897 atomic_inc(&op->usage);
51898 list_add_tail(&op->pend_link, &object->pending_ops);
51899 - fscache_stat(&fscache_n_op_pend);
51900 + fscache_stat_unchecked(&fscache_n_op_pend);
51901 ret = 0;
51902 } else {
51903 /* If we're in any other state, there must have been an I/O
51904 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
51905 if (object->n_exclusive > 0) {
51906 atomic_inc(&op->usage);
51907 list_add_tail(&op->pend_link, &object->pending_ops);
51908 - fscache_stat(&fscache_n_op_pend);
51909 + fscache_stat_unchecked(&fscache_n_op_pend);
51910 } else if (!list_empty(&object->pending_ops)) {
51911 atomic_inc(&op->usage);
51912 list_add_tail(&op->pend_link, &object->pending_ops);
51913 - fscache_stat(&fscache_n_op_pend);
51914 + fscache_stat_unchecked(&fscache_n_op_pend);
51915 fscache_start_operations(object);
51916 } else {
51917 ASSERTCMP(object->n_exclusive, ==, 0);
51918 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
51919 object->n_ops++;
51920 atomic_inc(&op->usage);
51921 list_add_tail(&op->pend_link, &object->pending_ops);
51922 - fscache_stat(&fscache_n_op_pend);
51923 + fscache_stat_unchecked(&fscache_n_op_pend);
51924 ret = 0;
51925 } else if (object->state == FSCACHE_OBJECT_DYING ||
51926 object->state == FSCACHE_OBJECT_LC_DYING ||
51927 object->state == FSCACHE_OBJECT_WITHDRAWING) {
51928 - fscache_stat(&fscache_n_op_rejected);
51929 + fscache_stat_unchecked(&fscache_n_op_rejected);
51930 op->state = FSCACHE_OP_ST_CANCELLED;
51931 ret = -ENOBUFS;
51932 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
51933 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
51934 ret = -EBUSY;
51935 if (op->state == FSCACHE_OP_ST_PENDING) {
51936 ASSERT(!list_empty(&op->pend_link));
51937 - fscache_stat(&fscache_n_op_cancelled);
51938 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51939 list_del_init(&op->pend_link);
51940 if (do_cancel)
51941 do_cancel(op);
51942 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
51943 while (!list_empty(&object->pending_ops)) {
51944 op = list_entry(object->pending_ops.next,
51945 struct fscache_operation, pend_link);
51946 - fscache_stat(&fscache_n_op_cancelled);
51947 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51948 list_del_init(&op->pend_link);
51949
51950 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
51951 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
51952 op->state, ==, FSCACHE_OP_ST_CANCELLED);
51953 op->state = FSCACHE_OP_ST_DEAD;
51954
51955 - fscache_stat(&fscache_n_op_release);
51956 + fscache_stat_unchecked(&fscache_n_op_release);
51957
51958 if (op->release) {
51959 op->release(op);
51960 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
51961 * lock, and defer it otherwise */
51962 if (!spin_trylock(&object->lock)) {
51963 _debug("defer put");
51964 - fscache_stat(&fscache_n_op_deferred_release);
51965 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
51966
51967 cache = object->cache;
51968 spin_lock(&cache->op_gc_list_lock);
51969 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
51970
51971 _debug("GC DEFERRED REL OBJ%x OP%x",
51972 object->debug_id, op->debug_id);
51973 - fscache_stat(&fscache_n_op_gc);
51974 + fscache_stat_unchecked(&fscache_n_op_gc);
51975
51976 ASSERTCMP(atomic_read(&op->usage), ==, 0);
51977 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
51978 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
51979 index ff000e5..c44ec6d 100644
51980 --- a/fs/fscache/page.c
51981 +++ b/fs/fscache/page.c
51982 @@ -61,7 +61,7 @@ try_again:
51983 val = radix_tree_lookup(&cookie->stores, page->index);
51984 if (!val) {
51985 rcu_read_unlock();
51986 - fscache_stat(&fscache_n_store_vmscan_not_storing);
51987 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
51988 __fscache_uncache_page(cookie, page);
51989 return true;
51990 }
51991 @@ -91,11 +91,11 @@ try_again:
51992 spin_unlock(&cookie->stores_lock);
51993
51994 if (xpage) {
51995 - fscache_stat(&fscache_n_store_vmscan_cancelled);
51996 - fscache_stat(&fscache_n_store_radix_deletes);
51997 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
51998 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
51999 ASSERTCMP(xpage, ==, page);
52000 } else {
52001 - fscache_stat(&fscache_n_store_vmscan_gone);
52002 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52003 }
52004
52005 wake_up_bit(&cookie->flags, 0);
52006 @@ -110,11 +110,11 @@ page_busy:
52007 * sleeping on memory allocation, so we may need to impose a timeout
52008 * too. */
52009 if (!(gfp & __GFP_WAIT)) {
52010 - fscache_stat(&fscache_n_store_vmscan_busy);
52011 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52012 return false;
52013 }
52014
52015 - fscache_stat(&fscache_n_store_vmscan_wait);
52016 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52017 __fscache_wait_on_page_write(cookie, page);
52018 gfp &= ~__GFP_WAIT;
52019 goto try_again;
52020 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52021 FSCACHE_COOKIE_STORING_TAG);
52022 if (!radix_tree_tag_get(&cookie->stores, page->index,
52023 FSCACHE_COOKIE_PENDING_TAG)) {
52024 - fscache_stat(&fscache_n_store_radix_deletes);
52025 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52026 xpage = radix_tree_delete(&cookie->stores, page->index);
52027 }
52028 spin_unlock(&cookie->stores_lock);
52029 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52030
52031 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52032
52033 - fscache_stat(&fscache_n_attr_changed_calls);
52034 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52035
52036 if (fscache_object_is_active(object)) {
52037 fscache_stat(&fscache_n_cop_attr_changed);
52038 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52039
52040 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52041
52042 - fscache_stat(&fscache_n_attr_changed);
52043 + fscache_stat_unchecked(&fscache_n_attr_changed);
52044
52045 op = kzalloc(sizeof(*op), GFP_KERNEL);
52046 if (!op) {
52047 - fscache_stat(&fscache_n_attr_changed_nomem);
52048 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52049 _leave(" = -ENOMEM");
52050 return -ENOMEM;
52051 }
52052 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52053 if (fscache_submit_exclusive_op(object, op) < 0)
52054 goto nobufs;
52055 spin_unlock(&cookie->lock);
52056 - fscache_stat(&fscache_n_attr_changed_ok);
52057 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52058 fscache_put_operation(op);
52059 _leave(" = 0");
52060 return 0;
52061 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52062 nobufs:
52063 spin_unlock(&cookie->lock);
52064 kfree(op);
52065 - fscache_stat(&fscache_n_attr_changed_nobufs);
52066 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52067 _leave(" = %d", -ENOBUFS);
52068 return -ENOBUFS;
52069 }
52070 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52071 /* allocate a retrieval operation and attempt to submit it */
52072 op = kzalloc(sizeof(*op), GFP_NOIO);
52073 if (!op) {
52074 - fscache_stat(&fscache_n_retrievals_nomem);
52075 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52076 return NULL;
52077 }
52078
52079 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52080 return 0;
52081 }
52082
52083 - fscache_stat(&fscache_n_retrievals_wait);
52084 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52085
52086 jif = jiffies;
52087 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52088 fscache_wait_bit_interruptible,
52089 TASK_INTERRUPTIBLE) != 0) {
52090 - fscache_stat(&fscache_n_retrievals_intr);
52091 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52092 _leave(" = -ERESTARTSYS");
52093 return -ERESTARTSYS;
52094 }
52095 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52096 */
52097 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52098 struct fscache_retrieval *op,
52099 - atomic_t *stat_op_waits,
52100 - atomic_t *stat_object_dead)
52101 + atomic_unchecked_t *stat_op_waits,
52102 + atomic_unchecked_t *stat_object_dead)
52103 {
52104 int ret;
52105
52106 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52107 goto check_if_dead;
52108
52109 _debug(">>> WT");
52110 - fscache_stat(stat_op_waits);
52111 + fscache_stat_unchecked(stat_op_waits);
52112 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52113 fscache_wait_bit_interruptible,
52114 TASK_INTERRUPTIBLE) != 0) {
52115 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52116
52117 check_if_dead:
52118 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52119 - fscache_stat(stat_object_dead);
52120 + fscache_stat_unchecked(stat_object_dead);
52121 _leave(" = -ENOBUFS [cancelled]");
52122 return -ENOBUFS;
52123 }
52124 if (unlikely(fscache_object_is_dead(object))) {
52125 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52126 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52127 - fscache_stat(stat_object_dead);
52128 + fscache_stat_unchecked(stat_object_dead);
52129 return -ENOBUFS;
52130 }
52131 return 0;
52132 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52133
52134 _enter("%p,%p,,,", cookie, page);
52135
52136 - fscache_stat(&fscache_n_retrievals);
52137 + fscache_stat_unchecked(&fscache_n_retrievals);
52138
52139 if (hlist_empty(&cookie->backing_objects))
52140 goto nobufs;
52141 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52142 goto nobufs_unlock_dec;
52143 spin_unlock(&cookie->lock);
52144
52145 - fscache_stat(&fscache_n_retrieval_ops);
52146 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52147
52148 /* pin the netfs read context in case we need to do the actual netfs
52149 * read because we've encountered a cache read failure */
52150 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52151
52152 error:
52153 if (ret == -ENOMEM)
52154 - fscache_stat(&fscache_n_retrievals_nomem);
52155 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52156 else if (ret == -ERESTARTSYS)
52157 - fscache_stat(&fscache_n_retrievals_intr);
52158 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52159 else if (ret == -ENODATA)
52160 - fscache_stat(&fscache_n_retrievals_nodata);
52161 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52162 else if (ret < 0)
52163 - fscache_stat(&fscache_n_retrievals_nobufs);
52164 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52165 else
52166 - fscache_stat(&fscache_n_retrievals_ok);
52167 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52168
52169 fscache_put_retrieval(op);
52170 _leave(" = %d", ret);
52171 @@ -467,7 +467,7 @@ nobufs_unlock:
52172 spin_unlock(&cookie->lock);
52173 kfree(op);
52174 nobufs:
52175 - fscache_stat(&fscache_n_retrievals_nobufs);
52176 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52177 _leave(" = -ENOBUFS");
52178 return -ENOBUFS;
52179 }
52180 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52181
52182 _enter("%p,,%d,,,", cookie, *nr_pages);
52183
52184 - fscache_stat(&fscache_n_retrievals);
52185 + fscache_stat_unchecked(&fscache_n_retrievals);
52186
52187 if (hlist_empty(&cookie->backing_objects))
52188 goto nobufs;
52189 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52190 goto nobufs_unlock_dec;
52191 spin_unlock(&cookie->lock);
52192
52193 - fscache_stat(&fscache_n_retrieval_ops);
52194 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52195
52196 /* pin the netfs read context in case we need to do the actual netfs
52197 * read because we've encountered a cache read failure */
52198 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52199
52200 error:
52201 if (ret == -ENOMEM)
52202 - fscache_stat(&fscache_n_retrievals_nomem);
52203 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52204 else if (ret == -ERESTARTSYS)
52205 - fscache_stat(&fscache_n_retrievals_intr);
52206 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52207 else if (ret == -ENODATA)
52208 - fscache_stat(&fscache_n_retrievals_nodata);
52209 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52210 else if (ret < 0)
52211 - fscache_stat(&fscache_n_retrievals_nobufs);
52212 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52213 else
52214 - fscache_stat(&fscache_n_retrievals_ok);
52215 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52216
52217 fscache_put_retrieval(op);
52218 _leave(" = %d", ret);
52219 @@ -591,7 +591,7 @@ nobufs_unlock:
52220 spin_unlock(&cookie->lock);
52221 kfree(op);
52222 nobufs:
52223 - fscache_stat(&fscache_n_retrievals_nobufs);
52224 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52225 _leave(" = -ENOBUFS");
52226 return -ENOBUFS;
52227 }
52228 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52229
52230 _enter("%p,%p,,,", cookie, page);
52231
52232 - fscache_stat(&fscache_n_allocs);
52233 + fscache_stat_unchecked(&fscache_n_allocs);
52234
52235 if (hlist_empty(&cookie->backing_objects))
52236 goto nobufs;
52237 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52238 goto nobufs_unlock;
52239 spin_unlock(&cookie->lock);
52240
52241 - fscache_stat(&fscache_n_alloc_ops);
52242 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52243
52244 ret = fscache_wait_for_retrieval_activation(
52245 object, op,
52246 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52247
52248 error:
52249 if (ret == -ERESTARTSYS)
52250 - fscache_stat(&fscache_n_allocs_intr);
52251 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52252 else if (ret < 0)
52253 - fscache_stat(&fscache_n_allocs_nobufs);
52254 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52255 else
52256 - fscache_stat(&fscache_n_allocs_ok);
52257 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52258
52259 fscache_put_retrieval(op);
52260 _leave(" = %d", ret);
52261 @@ -677,7 +677,7 @@ nobufs_unlock:
52262 spin_unlock(&cookie->lock);
52263 kfree(op);
52264 nobufs:
52265 - fscache_stat(&fscache_n_allocs_nobufs);
52266 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52267 _leave(" = -ENOBUFS");
52268 return -ENOBUFS;
52269 }
52270 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52271
52272 spin_lock(&cookie->stores_lock);
52273
52274 - fscache_stat(&fscache_n_store_calls);
52275 + fscache_stat_unchecked(&fscache_n_store_calls);
52276
52277 /* find a page to store */
52278 page = NULL;
52279 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52280 page = results[0];
52281 _debug("gang %d [%lx]", n, page->index);
52282 if (page->index > op->store_limit) {
52283 - fscache_stat(&fscache_n_store_pages_over_limit);
52284 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52285 goto superseded;
52286 }
52287
52288 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52289 spin_unlock(&cookie->stores_lock);
52290 spin_unlock(&object->lock);
52291
52292 - fscache_stat(&fscache_n_store_pages);
52293 + fscache_stat_unchecked(&fscache_n_store_pages);
52294 fscache_stat(&fscache_n_cop_write_page);
52295 ret = object->cache->ops->write_page(op, page);
52296 fscache_stat_d(&fscache_n_cop_write_page);
52297 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52298 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52299 ASSERT(PageFsCache(page));
52300
52301 - fscache_stat(&fscache_n_stores);
52302 + fscache_stat_unchecked(&fscache_n_stores);
52303
52304 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52305 _leave(" = -ENOBUFS [invalidating]");
52306 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52307 spin_unlock(&cookie->stores_lock);
52308 spin_unlock(&object->lock);
52309
52310 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52311 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52312 op->store_limit = object->store_limit;
52313
52314 if (fscache_submit_op(object, &op->op) < 0)
52315 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52316
52317 spin_unlock(&cookie->lock);
52318 radix_tree_preload_end();
52319 - fscache_stat(&fscache_n_store_ops);
52320 - fscache_stat(&fscache_n_stores_ok);
52321 + fscache_stat_unchecked(&fscache_n_store_ops);
52322 + fscache_stat_unchecked(&fscache_n_stores_ok);
52323
52324 /* the work queue now carries its own ref on the object */
52325 fscache_put_operation(&op->op);
52326 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52327 return 0;
52328
52329 already_queued:
52330 - fscache_stat(&fscache_n_stores_again);
52331 + fscache_stat_unchecked(&fscache_n_stores_again);
52332 already_pending:
52333 spin_unlock(&cookie->stores_lock);
52334 spin_unlock(&object->lock);
52335 spin_unlock(&cookie->lock);
52336 radix_tree_preload_end();
52337 kfree(op);
52338 - fscache_stat(&fscache_n_stores_ok);
52339 + fscache_stat_unchecked(&fscache_n_stores_ok);
52340 _leave(" = 0");
52341 return 0;
52342
52343 @@ -959,14 +959,14 @@ nobufs:
52344 spin_unlock(&cookie->lock);
52345 radix_tree_preload_end();
52346 kfree(op);
52347 - fscache_stat(&fscache_n_stores_nobufs);
52348 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52349 _leave(" = -ENOBUFS");
52350 return -ENOBUFS;
52351
52352 nomem_free:
52353 kfree(op);
52354 nomem:
52355 - fscache_stat(&fscache_n_stores_oom);
52356 + fscache_stat_unchecked(&fscache_n_stores_oom);
52357 _leave(" = -ENOMEM");
52358 return -ENOMEM;
52359 }
52360 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52361 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52362 ASSERTCMP(page, !=, NULL);
52363
52364 - fscache_stat(&fscache_n_uncaches);
52365 + fscache_stat_unchecked(&fscache_n_uncaches);
52366
52367 /* cache withdrawal may beat us to it */
52368 if (!PageFsCache(page))
52369 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52370 struct fscache_cookie *cookie = op->op.object->cookie;
52371
52372 #ifdef CONFIG_FSCACHE_STATS
52373 - atomic_inc(&fscache_n_marks);
52374 + atomic_inc_unchecked(&fscache_n_marks);
52375 #endif
52376
52377 _debug("- mark %p{%lx}", page, page->index);
52378 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52379 index 40d13c7..ddf52b9 100644
52380 --- a/fs/fscache/stats.c
52381 +++ b/fs/fscache/stats.c
52382 @@ -18,99 +18,99 @@
52383 /*
52384 * operation counters
52385 */
52386 -atomic_t fscache_n_op_pend;
52387 -atomic_t fscache_n_op_run;
52388 -atomic_t fscache_n_op_enqueue;
52389 -atomic_t fscache_n_op_requeue;
52390 -atomic_t fscache_n_op_deferred_release;
52391 -atomic_t fscache_n_op_release;
52392 -atomic_t fscache_n_op_gc;
52393 -atomic_t fscache_n_op_cancelled;
52394 -atomic_t fscache_n_op_rejected;
52395 +atomic_unchecked_t fscache_n_op_pend;
52396 +atomic_unchecked_t fscache_n_op_run;
52397 +atomic_unchecked_t fscache_n_op_enqueue;
52398 +atomic_unchecked_t fscache_n_op_requeue;
52399 +atomic_unchecked_t fscache_n_op_deferred_release;
52400 +atomic_unchecked_t fscache_n_op_release;
52401 +atomic_unchecked_t fscache_n_op_gc;
52402 +atomic_unchecked_t fscache_n_op_cancelled;
52403 +atomic_unchecked_t fscache_n_op_rejected;
52404
52405 -atomic_t fscache_n_attr_changed;
52406 -atomic_t fscache_n_attr_changed_ok;
52407 -atomic_t fscache_n_attr_changed_nobufs;
52408 -atomic_t fscache_n_attr_changed_nomem;
52409 -atomic_t fscache_n_attr_changed_calls;
52410 +atomic_unchecked_t fscache_n_attr_changed;
52411 +atomic_unchecked_t fscache_n_attr_changed_ok;
52412 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52413 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52414 +atomic_unchecked_t fscache_n_attr_changed_calls;
52415
52416 -atomic_t fscache_n_allocs;
52417 -atomic_t fscache_n_allocs_ok;
52418 -atomic_t fscache_n_allocs_wait;
52419 -atomic_t fscache_n_allocs_nobufs;
52420 -atomic_t fscache_n_allocs_intr;
52421 -atomic_t fscache_n_allocs_object_dead;
52422 -atomic_t fscache_n_alloc_ops;
52423 -atomic_t fscache_n_alloc_op_waits;
52424 +atomic_unchecked_t fscache_n_allocs;
52425 +atomic_unchecked_t fscache_n_allocs_ok;
52426 +atomic_unchecked_t fscache_n_allocs_wait;
52427 +atomic_unchecked_t fscache_n_allocs_nobufs;
52428 +atomic_unchecked_t fscache_n_allocs_intr;
52429 +atomic_unchecked_t fscache_n_allocs_object_dead;
52430 +atomic_unchecked_t fscache_n_alloc_ops;
52431 +atomic_unchecked_t fscache_n_alloc_op_waits;
52432
52433 -atomic_t fscache_n_retrievals;
52434 -atomic_t fscache_n_retrievals_ok;
52435 -atomic_t fscache_n_retrievals_wait;
52436 -atomic_t fscache_n_retrievals_nodata;
52437 -atomic_t fscache_n_retrievals_nobufs;
52438 -atomic_t fscache_n_retrievals_intr;
52439 -atomic_t fscache_n_retrievals_nomem;
52440 -atomic_t fscache_n_retrievals_object_dead;
52441 -atomic_t fscache_n_retrieval_ops;
52442 -atomic_t fscache_n_retrieval_op_waits;
52443 +atomic_unchecked_t fscache_n_retrievals;
52444 +atomic_unchecked_t fscache_n_retrievals_ok;
52445 +atomic_unchecked_t fscache_n_retrievals_wait;
52446 +atomic_unchecked_t fscache_n_retrievals_nodata;
52447 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52448 +atomic_unchecked_t fscache_n_retrievals_intr;
52449 +atomic_unchecked_t fscache_n_retrievals_nomem;
52450 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52451 +atomic_unchecked_t fscache_n_retrieval_ops;
52452 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52453
52454 -atomic_t fscache_n_stores;
52455 -atomic_t fscache_n_stores_ok;
52456 -atomic_t fscache_n_stores_again;
52457 -atomic_t fscache_n_stores_nobufs;
52458 -atomic_t fscache_n_stores_oom;
52459 -atomic_t fscache_n_store_ops;
52460 -atomic_t fscache_n_store_calls;
52461 -atomic_t fscache_n_store_pages;
52462 -atomic_t fscache_n_store_radix_deletes;
52463 -atomic_t fscache_n_store_pages_over_limit;
52464 +atomic_unchecked_t fscache_n_stores;
52465 +atomic_unchecked_t fscache_n_stores_ok;
52466 +atomic_unchecked_t fscache_n_stores_again;
52467 +atomic_unchecked_t fscache_n_stores_nobufs;
52468 +atomic_unchecked_t fscache_n_stores_oom;
52469 +atomic_unchecked_t fscache_n_store_ops;
52470 +atomic_unchecked_t fscache_n_store_calls;
52471 +atomic_unchecked_t fscache_n_store_pages;
52472 +atomic_unchecked_t fscache_n_store_radix_deletes;
52473 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52474
52475 -atomic_t fscache_n_store_vmscan_not_storing;
52476 -atomic_t fscache_n_store_vmscan_gone;
52477 -atomic_t fscache_n_store_vmscan_busy;
52478 -atomic_t fscache_n_store_vmscan_cancelled;
52479 -atomic_t fscache_n_store_vmscan_wait;
52480 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52481 +atomic_unchecked_t fscache_n_store_vmscan_gone;
52482 +atomic_unchecked_t fscache_n_store_vmscan_busy;
52483 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52484 +atomic_unchecked_t fscache_n_store_vmscan_wait;
52485
52486 -atomic_t fscache_n_marks;
52487 -atomic_t fscache_n_uncaches;
52488 +atomic_unchecked_t fscache_n_marks;
52489 +atomic_unchecked_t fscache_n_uncaches;
52490
52491 -atomic_t fscache_n_acquires;
52492 -atomic_t fscache_n_acquires_null;
52493 -atomic_t fscache_n_acquires_no_cache;
52494 -atomic_t fscache_n_acquires_ok;
52495 -atomic_t fscache_n_acquires_nobufs;
52496 -atomic_t fscache_n_acquires_oom;
52497 +atomic_unchecked_t fscache_n_acquires;
52498 +atomic_unchecked_t fscache_n_acquires_null;
52499 +atomic_unchecked_t fscache_n_acquires_no_cache;
52500 +atomic_unchecked_t fscache_n_acquires_ok;
52501 +atomic_unchecked_t fscache_n_acquires_nobufs;
52502 +atomic_unchecked_t fscache_n_acquires_oom;
52503
52504 -atomic_t fscache_n_invalidates;
52505 -atomic_t fscache_n_invalidates_run;
52506 +atomic_unchecked_t fscache_n_invalidates;
52507 +atomic_unchecked_t fscache_n_invalidates_run;
52508
52509 -atomic_t fscache_n_updates;
52510 -atomic_t fscache_n_updates_null;
52511 -atomic_t fscache_n_updates_run;
52512 +atomic_unchecked_t fscache_n_updates;
52513 +atomic_unchecked_t fscache_n_updates_null;
52514 +atomic_unchecked_t fscache_n_updates_run;
52515
52516 -atomic_t fscache_n_relinquishes;
52517 -atomic_t fscache_n_relinquishes_null;
52518 -atomic_t fscache_n_relinquishes_waitcrt;
52519 -atomic_t fscache_n_relinquishes_retire;
52520 +atomic_unchecked_t fscache_n_relinquishes;
52521 +atomic_unchecked_t fscache_n_relinquishes_null;
52522 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52523 +atomic_unchecked_t fscache_n_relinquishes_retire;
52524
52525 -atomic_t fscache_n_cookie_index;
52526 -atomic_t fscache_n_cookie_data;
52527 -atomic_t fscache_n_cookie_special;
52528 +atomic_unchecked_t fscache_n_cookie_index;
52529 +atomic_unchecked_t fscache_n_cookie_data;
52530 +atomic_unchecked_t fscache_n_cookie_special;
52531
52532 -atomic_t fscache_n_object_alloc;
52533 -atomic_t fscache_n_object_no_alloc;
52534 -atomic_t fscache_n_object_lookups;
52535 -atomic_t fscache_n_object_lookups_negative;
52536 -atomic_t fscache_n_object_lookups_positive;
52537 -atomic_t fscache_n_object_lookups_timed_out;
52538 -atomic_t fscache_n_object_created;
52539 -atomic_t fscache_n_object_avail;
52540 -atomic_t fscache_n_object_dead;
52541 +atomic_unchecked_t fscache_n_object_alloc;
52542 +atomic_unchecked_t fscache_n_object_no_alloc;
52543 +atomic_unchecked_t fscache_n_object_lookups;
52544 +atomic_unchecked_t fscache_n_object_lookups_negative;
52545 +atomic_unchecked_t fscache_n_object_lookups_positive;
52546 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
52547 +atomic_unchecked_t fscache_n_object_created;
52548 +atomic_unchecked_t fscache_n_object_avail;
52549 +atomic_unchecked_t fscache_n_object_dead;
52550
52551 -atomic_t fscache_n_checkaux_none;
52552 -atomic_t fscache_n_checkaux_okay;
52553 -atomic_t fscache_n_checkaux_update;
52554 -atomic_t fscache_n_checkaux_obsolete;
52555 +atomic_unchecked_t fscache_n_checkaux_none;
52556 +atomic_unchecked_t fscache_n_checkaux_okay;
52557 +atomic_unchecked_t fscache_n_checkaux_update;
52558 +atomic_unchecked_t fscache_n_checkaux_obsolete;
52559
52560 atomic_t fscache_n_cop_alloc_object;
52561 atomic_t fscache_n_cop_lookup_object;
52562 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
52563 seq_puts(m, "FS-Cache statistics\n");
52564
52565 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
52566 - atomic_read(&fscache_n_cookie_index),
52567 - atomic_read(&fscache_n_cookie_data),
52568 - atomic_read(&fscache_n_cookie_special));
52569 + atomic_read_unchecked(&fscache_n_cookie_index),
52570 + atomic_read_unchecked(&fscache_n_cookie_data),
52571 + atomic_read_unchecked(&fscache_n_cookie_special));
52572
52573 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
52574 - atomic_read(&fscache_n_object_alloc),
52575 - atomic_read(&fscache_n_object_no_alloc),
52576 - atomic_read(&fscache_n_object_avail),
52577 - atomic_read(&fscache_n_object_dead));
52578 + atomic_read_unchecked(&fscache_n_object_alloc),
52579 + atomic_read_unchecked(&fscache_n_object_no_alloc),
52580 + atomic_read_unchecked(&fscache_n_object_avail),
52581 + atomic_read_unchecked(&fscache_n_object_dead));
52582 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
52583 - atomic_read(&fscache_n_checkaux_none),
52584 - atomic_read(&fscache_n_checkaux_okay),
52585 - atomic_read(&fscache_n_checkaux_update),
52586 - atomic_read(&fscache_n_checkaux_obsolete));
52587 + atomic_read_unchecked(&fscache_n_checkaux_none),
52588 + atomic_read_unchecked(&fscache_n_checkaux_okay),
52589 + atomic_read_unchecked(&fscache_n_checkaux_update),
52590 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
52591
52592 seq_printf(m, "Pages : mrk=%u unc=%u\n",
52593 - atomic_read(&fscache_n_marks),
52594 - atomic_read(&fscache_n_uncaches));
52595 + atomic_read_unchecked(&fscache_n_marks),
52596 + atomic_read_unchecked(&fscache_n_uncaches));
52597
52598 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
52599 " oom=%u\n",
52600 - atomic_read(&fscache_n_acquires),
52601 - atomic_read(&fscache_n_acquires_null),
52602 - atomic_read(&fscache_n_acquires_no_cache),
52603 - atomic_read(&fscache_n_acquires_ok),
52604 - atomic_read(&fscache_n_acquires_nobufs),
52605 - atomic_read(&fscache_n_acquires_oom));
52606 + atomic_read_unchecked(&fscache_n_acquires),
52607 + atomic_read_unchecked(&fscache_n_acquires_null),
52608 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
52609 + atomic_read_unchecked(&fscache_n_acquires_ok),
52610 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
52611 + atomic_read_unchecked(&fscache_n_acquires_oom));
52612
52613 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
52614 - atomic_read(&fscache_n_object_lookups),
52615 - atomic_read(&fscache_n_object_lookups_negative),
52616 - atomic_read(&fscache_n_object_lookups_positive),
52617 - atomic_read(&fscache_n_object_created),
52618 - atomic_read(&fscache_n_object_lookups_timed_out));
52619 + atomic_read_unchecked(&fscache_n_object_lookups),
52620 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
52621 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
52622 + atomic_read_unchecked(&fscache_n_object_created),
52623 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
52624
52625 seq_printf(m, "Invals : n=%u run=%u\n",
52626 - atomic_read(&fscache_n_invalidates),
52627 - atomic_read(&fscache_n_invalidates_run));
52628 + atomic_read_unchecked(&fscache_n_invalidates),
52629 + atomic_read_unchecked(&fscache_n_invalidates_run));
52630
52631 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
52632 - atomic_read(&fscache_n_updates),
52633 - atomic_read(&fscache_n_updates_null),
52634 - atomic_read(&fscache_n_updates_run));
52635 + atomic_read_unchecked(&fscache_n_updates),
52636 + atomic_read_unchecked(&fscache_n_updates_null),
52637 + atomic_read_unchecked(&fscache_n_updates_run));
52638
52639 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
52640 - atomic_read(&fscache_n_relinquishes),
52641 - atomic_read(&fscache_n_relinquishes_null),
52642 - atomic_read(&fscache_n_relinquishes_waitcrt),
52643 - atomic_read(&fscache_n_relinquishes_retire));
52644 + atomic_read_unchecked(&fscache_n_relinquishes),
52645 + atomic_read_unchecked(&fscache_n_relinquishes_null),
52646 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
52647 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
52648
52649 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
52650 - atomic_read(&fscache_n_attr_changed),
52651 - atomic_read(&fscache_n_attr_changed_ok),
52652 - atomic_read(&fscache_n_attr_changed_nobufs),
52653 - atomic_read(&fscache_n_attr_changed_nomem),
52654 - atomic_read(&fscache_n_attr_changed_calls));
52655 + atomic_read_unchecked(&fscache_n_attr_changed),
52656 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
52657 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
52658 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
52659 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
52660
52661 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
52662 - atomic_read(&fscache_n_allocs),
52663 - atomic_read(&fscache_n_allocs_ok),
52664 - atomic_read(&fscache_n_allocs_wait),
52665 - atomic_read(&fscache_n_allocs_nobufs),
52666 - atomic_read(&fscache_n_allocs_intr));
52667 + atomic_read_unchecked(&fscache_n_allocs),
52668 + atomic_read_unchecked(&fscache_n_allocs_ok),
52669 + atomic_read_unchecked(&fscache_n_allocs_wait),
52670 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
52671 + atomic_read_unchecked(&fscache_n_allocs_intr));
52672 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
52673 - atomic_read(&fscache_n_alloc_ops),
52674 - atomic_read(&fscache_n_alloc_op_waits),
52675 - atomic_read(&fscache_n_allocs_object_dead));
52676 + atomic_read_unchecked(&fscache_n_alloc_ops),
52677 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
52678 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
52679
52680 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
52681 " int=%u oom=%u\n",
52682 - atomic_read(&fscache_n_retrievals),
52683 - atomic_read(&fscache_n_retrievals_ok),
52684 - atomic_read(&fscache_n_retrievals_wait),
52685 - atomic_read(&fscache_n_retrievals_nodata),
52686 - atomic_read(&fscache_n_retrievals_nobufs),
52687 - atomic_read(&fscache_n_retrievals_intr),
52688 - atomic_read(&fscache_n_retrievals_nomem));
52689 + atomic_read_unchecked(&fscache_n_retrievals),
52690 + atomic_read_unchecked(&fscache_n_retrievals_ok),
52691 + atomic_read_unchecked(&fscache_n_retrievals_wait),
52692 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
52693 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
52694 + atomic_read_unchecked(&fscache_n_retrievals_intr),
52695 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
52696 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
52697 - atomic_read(&fscache_n_retrieval_ops),
52698 - atomic_read(&fscache_n_retrieval_op_waits),
52699 - atomic_read(&fscache_n_retrievals_object_dead));
52700 + atomic_read_unchecked(&fscache_n_retrieval_ops),
52701 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
52702 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
52703
52704 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
52705 - atomic_read(&fscache_n_stores),
52706 - atomic_read(&fscache_n_stores_ok),
52707 - atomic_read(&fscache_n_stores_again),
52708 - atomic_read(&fscache_n_stores_nobufs),
52709 - atomic_read(&fscache_n_stores_oom));
52710 + atomic_read_unchecked(&fscache_n_stores),
52711 + atomic_read_unchecked(&fscache_n_stores_ok),
52712 + atomic_read_unchecked(&fscache_n_stores_again),
52713 + atomic_read_unchecked(&fscache_n_stores_nobufs),
52714 + atomic_read_unchecked(&fscache_n_stores_oom));
52715 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
52716 - atomic_read(&fscache_n_store_ops),
52717 - atomic_read(&fscache_n_store_calls),
52718 - atomic_read(&fscache_n_store_pages),
52719 - atomic_read(&fscache_n_store_radix_deletes),
52720 - atomic_read(&fscache_n_store_pages_over_limit));
52721 + atomic_read_unchecked(&fscache_n_store_ops),
52722 + atomic_read_unchecked(&fscache_n_store_calls),
52723 + atomic_read_unchecked(&fscache_n_store_pages),
52724 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
52725 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
52726
52727 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
52728 - atomic_read(&fscache_n_store_vmscan_not_storing),
52729 - atomic_read(&fscache_n_store_vmscan_gone),
52730 - atomic_read(&fscache_n_store_vmscan_busy),
52731 - atomic_read(&fscache_n_store_vmscan_cancelled),
52732 - atomic_read(&fscache_n_store_vmscan_wait));
52733 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
52734 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
52735 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
52736 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
52737 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
52738
52739 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
52740 - atomic_read(&fscache_n_op_pend),
52741 - atomic_read(&fscache_n_op_run),
52742 - atomic_read(&fscache_n_op_enqueue),
52743 - atomic_read(&fscache_n_op_cancelled),
52744 - atomic_read(&fscache_n_op_rejected));
52745 + atomic_read_unchecked(&fscache_n_op_pend),
52746 + atomic_read_unchecked(&fscache_n_op_run),
52747 + atomic_read_unchecked(&fscache_n_op_enqueue),
52748 + atomic_read_unchecked(&fscache_n_op_cancelled),
52749 + atomic_read_unchecked(&fscache_n_op_rejected));
52750 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
52751 - atomic_read(&fscache_n_op_deferred_release),
52752 - atomic_read(&fscache_n_op_release),
52753 - atomic_read(&fscache_n_op_gc));
52754 + atomic_read_unchecked(&fscache_n_op_deferred_release),
52755 + atomic_read_unchecked(&fscache_n_op_release),
52756 + atomic_read_unchecked(&fscache_n_op_gc));
52757
52758 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
52759 atomic_read(&fscache_n_cop_alloc_object),
52760 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
52761 index 6f96a8d..6019bb9 100644
52762 --- a/fs/fuse/cuse.c
52763 +++ b/fs/fuse/cuse.c
52764 @@ -597,10 +597,12 @@ static int __init cuse_init(void)
52765 INIT_LIST_HEAD(&cuse_conntbl[i]);
52766
52767 /* inherit and extend fuse_dev_operations */
52768 - cuse_channel_fops = fuse_dev_operations;
52769 - cuse_channel_fops.owner = THIS_MODULE;
52770 - cuse_channel_fops.open = cuse_channel_open;
52771 - cuse_channel_fops.release = cuse_channel_release;
52772 + pax_open_kernel();
52773 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
52774 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
52775 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
52776 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
52777 + pax_close_kernel();
52778
52779 cuse_class = class_create(THIS_MODULE, "cuse");
52780 if (IS_ERR(cuse_class))
52781 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
52782 index 11dfa0c..6f64416 100644
52783 --- a/fs/fuse/dev.c
52784 +++ b/fs/fuse/dev.c
52785 @@ -1294,7 +1294,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
52786 ret = 0;
52787 pipe_lock(pipe);
52788
52789 - if (!pipe->readers) {
52790 + if (!atomic_read(&pipe->readers)) {
52791 send_sig(SIGPIPE, current, 0);
52792 if (!ret)
52793 ret = -EPIPE;
52794 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
52795 index ff15522..092a0f6 100644
52796 --- a/fs/fuse/dir.c
52797 +++ b/fs/fuse/dir.c
52798 @@ -1409,7 +1409,7 @@ static char *read_link(struct dentry *dentry)
52799 return link;
52800 }
52801
52802 -static void free_link(char *link)
52803 +static void free_link(const char *link)
52804 {
52805 if (!IS_ERR(link))
52806 free_page((unsigned long) link);
52807 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
52808 index cc00bd1..3edb692 100644
52809 --- a/fs/gfs2/inode.c
52810 +++ b/fs/gfs2/inode.c
52811 @@ -1500,7 +1500,7 @@ out:
52812
52813 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52814 {
52815 - char *s = nd_get_link(nd);
52816 + const char *s = nd_get_link(nd);
52817 if (!IS_ERR(s))
52818 kfree(s);
52819 }
52820 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
52821 index a3f868a..bb308ae 100644
52822 --- a/fs/hugetlbfs/inode.c
52823 +++ b/fs/hugetlbfs/inode.c
52824 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52825 struct mm_struct *mm = current->mm;
52826 struct vm_area_struct *vma;
52827 struct hstate *h = hstate_file(file);
52828 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
52829 struct vm_unmapped_area_info info;
52830
52831 if (len & ~huge_page_mask(h))
52832 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52833 return addr;
52834 }
52835
52836 +#ifdef CONFIG_PAX_RANDMMAP
52837 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
52838 +#endif
52839 +
52840 if (addr) {
52841 addr = ALIGN(addr, huge_page_size(h));
52842 vma = find_vma(mm, addr);
52843 - if (TASK_SIZE - len >= addr &&
52844 - (!vma || addr + len <= vma->vm_start))
52845 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
52846 return addr;
52847 }
52848
52849 info.flags = 0;
52850 info.length = len;
52851 info.low_limit = TASK_UNMAPPED_BASE;
52852 +
52853 +#ifdef CONFIG_PAX_RANDMMAP
52854 + if (mm->pax_flags & MF_PAX_RANDMMAP)
52855 + info.low_limit += mm->delta_mmap;
52856 +#endif
52857 +
52858 info.high_limit = TASK_SIZE;
52859 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
52860 info.align_offset = 0;
52861 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
52862 };
52863 MODULE_ALIAS_FS("hugetlbfs");
52864
52865 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52866 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52867
52868 static int can_do_hugetlb_shm(void)
52869 {
52870 diff --git a/fs/inode.c b/fs/inode.c
52871 index a898b3d..9b5a214 100644
52872 --- a/fs/inode.c
52873 +++ b/fs/inode.c
52874 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
52875
52876 #ifdef CONFIG_SMP
52877 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
52878 - static atomic_t shared_last_ino;
52879 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
52880 + static atomic_unchecked_t shared_last_ino;
52881 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
52882
52883 res = next - LAST_INO_BATCH;
52884 }
52885 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
52886 index 4a6cf28..d3a29d3 100644
52887 --- a/fs/jffs2/erase.c
52888 +++ b/fs/jffs2/erase.c
52889 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
52890 struct jffs2_unknown_node marker = {
52891 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
52892 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52893 - .totlen = cpu_to_je32(c->cleanmarker_size)
52894 + .totlen = cpu_to_je32(c->cleanmarker_size),
52895 + .hdr_crc = cpu_to_je32(0)
52896 };
52897
52898 jffs2_prealloc_raw_node_refs(c, jeb, 1);
52899 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
52900 index a6597d6..41b30ec 100644
52901 --- a/fs/jffs2/wbuf.c
52902 +++ b/fs/jffs2/wbuf.c
52903 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
52904 {
52905 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
52906 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52907 - .totlen = constant_cpu_to_je32(8)
52908 + .totlen = constant_cpu_to_je32(8),
52909 + .hdr_crc = constant_cpu_to_je32(0)
52910 };
52911
52912 /*
52913 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
52914 index 2003e83..40db287 100644
52915 --- a/fs/jfs/super.c
52916 +++ b/fs/jfs/super.c
52917 @@ -856,7 +856,7 @@ static int __init init_jfs_fs(void)
52918
52919 jfs_inode_cachep =
52920 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
52921 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
52922 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
52923 init_once);
52924 if (jfs_inode_cachep == NULL)
52925 return -ENOMEM;
52926 diff --git a/fs/libfs.c b/fs/libfs.c
52927 index 916da8c..1588998 100644
52928 --- a/fs/libfs.c
52929 +++ b/fs/libfs.c
52930 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52931
52932 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
52933 struct dentry *next;
52934 + char d_name[sizeof(next->d_iname)];
52935 + const unsigned char *name;
52936 +
52937 next = list_entry(p, struct dentry, d_u.d_child);
52938 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
52939 if (!simple_positive(next)) {
52940 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52941
52942 spin_unlock(&next->d_lock);
52943 spin_unlock(&dentry->d_lock);
52944 - if (filldir(dirent, next->d_name.name,
52945 + name = next->d_name.name;
52946 + if (name == next->d_iname) {
52947 + memcpy(d_name, name, next->d_name.len);
52948 + name = d_name;
52949 + }
52950 + if (filldir(dirent, name,
52951 next->d_name.len, filp->f_pos,
52952 next->d_inode->i_ino,
52953 dt_type(next->d_inode)) < 0)
52954 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
52955 index 9760ecb..9b838ef 100644
52956 --- a/fs/lockd/clntproc.c
52957 +++ b/fs/lockd/clntproc.c
52958 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
52959 /*
52960 * Cookie counter for NLM requests
52961 */
52962 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
52963 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
52964
52965 void nlmclnt_next_cookie(struct nlm_cookie *c)
52966 {
52967 - u32 cookie = atomic_inc_return(&nlm_cookie);
52968 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
52969
52970 memcpy(c->data, &cookie, 4);
52971 c->len=4;
52972 diff --git a/fs/locks.c b/fs/locks.c
52973 index cb424a4..850e4dd 100644
52974 --- a/fs/locks.c
52975 +++ b/fs/locks.c
52976 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
52977 return;
52978
52979 if (filp->f_op && filp->f_op->flock) {
52980 - struct file_lock fl = {
52981 + struct file_lock flock = {
52982 .fl_pid = current->tgid,
52983 .fl_file = filp,
52984 .fl_flags = FL_FLOCK,
52985 .fl_type = F_UNLCK,
52986 .fl_end = OFFSET_MAX,
52987 };
52988 - filp->f_op->flock(filp, F_SETLKW, &fl);
52989 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
52990 - fl.fl_ops->fl_release_private(&fl);
52991 + filp->f_op->flock(filp, F_SETLKW, &flock);
52992 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
52993 + flock.fl_ops->fl_release_private(&flock);
52994 }
52995
52996 lock_flocks();
52997 diff --git a/fs/namei.c b/fs/namei.c
52998 index 85e40d1..b66744e 100644
52999 --- a/fs/namei.c
53000 +++ b/fs/namei.c
53001 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53002 if (ret != -EACCES)
53003 return ret;
53004
53005 +#ifdef CONFIG_GRKERNSEC
53006 + /* we'll block if we have to log due to a denied capability use */
53007 + if (mask & MAY_NOT_BLOCK)
53008 + return -ECHILD;
53009 +#endif
53010 +
53011 if (S_ISDIR(inode->i_mode)) {
53012 /* DACs are overridable for directories */
53013 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53014 - return 0;
53015 if (!(mask & MAY_WRITE))
53016 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53017 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53018 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53019 return 0;
53020 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53021 + return 0;
53022 return -EACCES;
53023 }
53024 /*
53025 + * Searching includes executable on directories, else just read.
53026 + */
53027 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53028 + if (mask == MAY_READ)
53029 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53030 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53031 + return 0;
53032 +
53033 + /*
53034 * Read/write DACs are always overridable.
53035 * Executable DACs are overridable when there is
53036 * at least one exec bit set.
53037 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53038 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53039 return 0;
53040
53041 - /*
53042 - * Searching includes executable on directories, else just read.
53043 - */
53044 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53045 - if (mask == MAY_READ)
53046 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53047 - return 0;
53048 -
53049 return -EACCES;
53050 }
53051
53052 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53053 {
53054 struct dentry *dentry = link->dentry;
53055 int error;
53056 - char *s;
53057 + const char *s;
53058
53059 BUG_ON(nd->flags & LOOKUP_RCU);
53060
53061 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53062 if (error)
53063 goto out_put_nd_path;
53064
53065 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53066 + dentry->d_inode, dentry, nd->path.mnt)) {
53067 + error = -EACCES;
53068 + goto out_put_nd_path;
53069 + }
53070 +
53071 nd->last_type = LAST_BIND;
53072 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53073 error = PTR_ERR(*p);
53074 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53075 if (res)
53076 break;
53077 res = walk_component(nd, path, LOOKUP_FOLLOW);
53078 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53079 + res = -EACCES;
53080 put_link(nd, &link, cookie);
53081 } while (res > 0);
53082
53083 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
53084 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53085 {
53086 unsigned long a, b, adata, bdata, mask, hash, len;
53087 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53088 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53089
53090 hash = a = 0;
53091 len = -sizeof(unsigned long);
53092 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
53093 if (err)
53094 break;
53095 err = lookup_last(nd, &path);
53096 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53097 + err = -EACCES;
53098 put_link(nd, &link, cookie);
53099 }
53100 }
53101 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
53102 if (!err)
53103 err = complete_walk(nd);
53104
53105 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53106 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53107 + path_put(&nd->path);
53108 + err = -ENOENT;
53109 + }
53110 + }
53111 +
53112 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53113 if (!nd->inode->i_op->lookup) {
53114 path_put(&nd->path);
53115 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
53116 retval = path_lookupat(dfd, name->name,
53117 flags | LOOKUP_REVAL, nd);
53118
53119 - if (likely(!retval))
53120 + if (likely(!retval)) {
53121 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53122 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53123 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53124 + path_put(&nd->path);
53125 + return -ENOENT;
53126 + }
53127 + }
53128 + }
53129 return retval;
53130 }
53131
53132 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53133 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53134 return -EPERM;
53135
53136 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53137 + return -EPERM;
53138 + if (gr_handle_rawio(inode))
53139 + return -EPERM;
53140 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53141 + return -EACCES;
53142 +
53143 return 0;
53144 }
53145
53146 @@ -2602,7 +2641,7 @@ looked_up:
53147 * cleared otherwise prior to returning.
53148 */
53149 static int lookup_open(struct nameidata *nd, struct path *path,
53150 - struct file *file,
53151 + struct path *link, struct file *file,
53152 const struct open_flags *op,
53153 bool got_write, int *opened)
53154 {
53155 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53156 /* Negative dentry, just create the file */
53157 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53158 umode_t mode = op->mode;
53159 +
53160 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53161 + error = -EACCES;
53162 + goto out_dput;
53163 + }
53164 +
53165 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53166 + error = -EACCES;
53167 + goto out_dput;
53168 + }
53169 +
53170 if (!IS_POSIXACL(dir->d_inode))
53171 mode &= ~current_umask();
53172 /*
53173 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53174 nd->flags & LOOKUP_EXCL);
53175 if (error)
53176 goto out_dput;
53177 + else
53178 + gr_handle_create(dentry, nd->path.mnt);
53179 }
53180 out_no_open:
53181 path->dentry = dentry;
53182 @@ -2672,7 +2724,7 @@ out_dput:
53183 /*
53184 * Handle the last step of open()
53185 */
53186 -static int do_last(struct nameidata *nd, struct path *path,
53187 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53188 struct file *file, const struct open_flags *op,
53189 int *opened, struct filename *name)
53190 {
53191 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53192 error = complete_walk(nd);
53193 if (error)
53194 return error;
53195 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53196 + error = -ENOENT;
53197 + goto out;
53198 + }
53199 audit_inode(name, nd->path.dentry, 0);
53200 if (open_flag & O_CREAT) {
53201 error = -EISDIR;
53202 goto out;
53203 }
53204 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53205 + error = -EACCES;
53206 + goto out;
53207 + }
53208 goto finish_open;
53209 case LAST_BIND:
53210 error = complete_walk(nd);
53211 if (error)
53212 return error;
53213 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53214 + error = -ENOENT;
53215 + goto out;
53216 + }
53217 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53218 + error = -EACCES;
53219 + goto out;
53220 + }
53221 audit_inode(name, dir, 0);
53222 goto finish_open;
53223 }
53224 @@ -2759,7 +2827,7 @@ retry_lookup:
53225 */
53226 }
53227 mutex_lock(&dir->d_inode->i_mutex);
53228 - error = lookup_open(nd, path, file, op, got_write, opened);
53229 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53230 mutex_unlock(&dir->d_inode->i_mutex);
53231
53232 if (error <= 0) {
53233 @@ -2783,11 +2851,28 @@ retry_lookup:
53234 goto finish_open_created;
53235 }
53236
53237 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53238 + error = -ENOENT;
53239 + goto exit_dput;
53240 + }
53241 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53242 + error = -EACCES;
53243 + goto exit_dput;
53244 + }
53245 +
53246 /*
53247 * create/update audit record if it already exists.
53248 */
53249 - if (path->dentry->d_inode)
53250 + if (path->dentry->d_inode) {
53251 + /* only check if O_CREAT is specified, all other checks need to go
53252 + into may_open */
53253 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53254 + error = -EACCES;
53255 + goto exit_dput;
53256 + }
53257 +
53258 audit_inode(name, path->dentry, 0);
53259 + }
53260
53261 /*
53262 * If atomic_open() acquired write access it is dropped now due to
53263 @@ -2828,6 +2913,11 @@ finish_lookup:
53264 }
53265 }
53266 BUG_ON(inode != path->dentry->d_inode);
53267 + /* if we're resolving a symlink to another symlink */
53268 + if (link && gr_handle_symlink_owner(link, inode)) {
53269 + error = -EACCES;
53270 + goto out;
53271 + }
53272 return 1;
53273 }
53274
53275 @@ -2837,7 +2927,6 @@ finish_lookup:
53276 save_parent.dentry = nd->path.dentry;
53277 save_parent.mnt = mntget(path->mnt);
53278 nd->path.dentry = path->dentry;
53279 -
53280 }
53281 nd->inode = inode;
53282 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53283 @@ -2846,6 +2935,16 @@ finish_lookup:
53284 path_put(&save_parent);
53285 return error;
53286 }
53287 +
53288 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53289 + error = -ENOENT;
53290 + goto out;
53291 + }
53292 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53293 + error = -EACCES;
53294 + goto out;
53295 + }
53296 +
53297 error = -EISDIR;
53298 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53299 goto out;
53300 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53301 if (unlikely(error))
53302 goto out;
53303
53304 - error = do_last(nd, &path, file, op, &opened, pathname);
53305 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53306 while (unlikely(error > 0)) { /* trailing symlink */
53307 struct path link = path;
53308 void *cookie;
53309 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53310 error = follow_link(&link, nd, &cookie);
53311 if (unlikely(error))
53312 break;
53313 - error = do_last(nd, &path, file, op, &opened, pathname);
53314 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53315 put_link(nd, &link, cookie);
53316 }
53317 out:
53318 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53319 goto unlock;
53320
53321 error = -EEXIST;
53322 - if (dentry->d_inode)
53323 + if (dentry->d_inode) {
53324 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53325 + error = -ENOENT;
53326 + }
53327 goto fail;
53328 + }
53329 /*
53330 * Special case - lookup gave negative, but... we had foo/bar/
53331 * From the vfs_mknod() POV we just have a negative dentry -
53332 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53333 }
53334 EXPORT_SYMBOL(user_path_create);
53335
53336 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53337 +{
53338 + struct filename *tmp = getname(pathname);
53339 + struct dentry *res;
53340 + if (IS_ERR(tmp))
53341 + return ERR_CAST(tmp);
53342 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53343 + if (IS_ERR(res))
53344 + putname(tmp);
53345 + else
53346 + *to = tmp;
53347 + return res;
53348 +}
53349 +
53350 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53351 {
53352 int error = may_create(dir, dentry);
53353 @@ -3177,6 +3294,17 @@ retry:
53354
53355 if (!IS_POSIXACL(path.dentry->d_inode))
53356 mode &= ~current_umask();
53357 +
53358 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53359 + error = -EPERM;
53360 + goto out;
53361 + }
53362 +
53363 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53364 + error = -EACCES;
53365 + goto out;
53366 + }
53367 +
53368 error = security_path_mknod(&path, dentry, mode, dev);
53369 if (error)
53370 goto out;
53371 @@ -3193,6 +3321,8 @@ retry:
53372 break;
53373 }
53374 out:
53375 + if (!error)
53376 + gr_handle_create(dentry, path.mnt);
53377 done_path_create(&path, dentry);
53378 if (retry_estale(error, lookup_flags)) {
53379 lookup_flags |= LOOKUP_REVAL;
53380 @@ -3245,9 +3375,16 @@ retry:
53381
53382 if (!IS_POSIXACL(path.dentry->d_inode))
53383 mode &= ~current_umask();
53384 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53385 + error = -EACCES;
53386 + goto out;
53387 + }
53388 error = security_path_mkdir(&path, dentry, mode);
53389 if (!error)
53390 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53391 + if (!error)
53392 + gr_handle_create(dentry, path.mnt);
53393 +out:
53394 done_path_create(&path, dentry);
53395 if (retry_estale(error, lookup_flags)) {
53396 lookup_flags |= LOOKUP_REVAL;
53397 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53398 struct filename *name;
53399 struct dentry *dentry;
53400 struct nameidata nd;
53401 + ino_t saved_ino = 0;
53402 + dev_t saved_dev = 0;
53403 unsigned int lookup_flags = 0;
53404 retry:
53405 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53406 @@ -3360,10 +3499,21 @@ retry:
53407 error = -ENOENT;
53408 goto exit3;
53409 }
53410 +
53411 + saved_ino = dentry->d_inode->i_ino;
53412 + saved_dev = gr_get_dev_from_dentry(dentry);
53413 +
53414 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53415 + error = -EACCES;
53416 + goto exit3;
53417 + }
53418 +
53419 error = security_path_rmdir(&nd.path, dentry);
53420 if (error)
53421 goto exit3;
53422 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53423 + if (!error && (saved_dev || saved_ino))
53424 + gr_handle_delete(saved_ino, saved_dev);
53425 exit3:
53426 dput(dentry);
53427 exit2:
53428 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53429 struct dentry *dentry;
53430 struct nameidata nd;
53431 struct inode *inode = NULL;
53432 + ino_t saved_ino = 0;
53433 + dev_t saved_dev = 0;
53434 unsigned int lookup_flags = 0;
53435 retry:
53436 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53437 @@ -3455,10 +3607,22 @@ retry:
53438 if (!inode)
53439 goto slashes;
53440 ihold(inode);
53441 +
53442 + if (inode->i_nlink <= 1) {
53443 + saved_ino = inode->i_ino;
53444 + saved_dev = gr_get_dev_from_dentry(dentry);
53445 + }
53446 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53447 + error = -EACCES;
53448 + goto exit2;
53449 + }
53450 +
53451 error = security_path_unlink(&nd.path, dentry);
53452 if (error)
53453 goto exit2;
53454 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
53455 + if (!error && (saved_ino || saved_dev))
53456 + gr_handle_delete(saved_ino, saved_dev);
53457 exit2:
53458 dput(dentry);
53459 }
53460 @@ -3536,9 +3700,17 @@ retry:
53461 if (IS_ERR(dentry))
53462 goto out_putname;
53463
53464 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
53465 + error = -EACCES;
53466 + goto out;
53467 + }
53468 +
53469 error = security_path_symlink(&path, dentry, from->name);
53470 if (!error)
53471 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
53472 + if (!error)
53473 + gr_handle_create(dentry, path.mnt);
53474 +out:
53475 done_path_create(&path, dentry);
53476 if (retry_estale(error, lookup_flags)) {
53477 lookup_flags |= LOOKUP_REVAL;
53478 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
53479 {
53480 struct dentry *new_dentry;
53481 struct path old_path, new_path;
53482 + struct filename *to = NULL;
53483 int how = 0;
53484 int error;
53485
53486 @@ -3635,7 +3808,7 @@ retry:
53487 if (error)
53488 return error;
53489
53490 - new_dentry = user_path_create(newdfd, newname, &new_path,
53491 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
53492 (how & LOOKUP_REVAL));
53493 error = PTR_ERR(new_dentry);
53494 if (IS_ERR(new_dentry))
53495 @@ -3647,11 +3820,28 @@ retry:
53496 error = may_linkat(&old_path);
53497 if (unlikely(error))
53498 goto out_dput;
53499 +
53500 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
53501 + old_path.dentry->d_inode,
53502 + old_path.dentry->d_inode->i_mode, to)) {
53503 + error = -EACCES;
53504 + goto out_dput;
53505 + }
53506 +
53507 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53508 + old_path.dentry, old_path.mnt, to)) {
53509 + error = -EACCES;
53510 + goto out_dput;
53511 + }
53512 +
53513 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53514 if (error)
53515 goto out_dput;
53516 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53517 + if (!error)
53518 + gr_handle_create(new_dentry, new_path.mnt);
53519 out_dput:
53520 + putname(to);
53521 done_path_create(&new_path, new_dentry);
53522 if (retry_estale(error, how)) {
53523 how |= LOOKUP_REVAL;
53524 @@ -3897,12 +4087,21 @@ retry:
53525 if (new_dentry == trap)
53526 goto exit5;
53527
53528 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53529 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53530 + to);
53531 + if (error)
53532 + goto exit5;
53533 +
53534 error = security_path_rename(&oldnd.path, old_dentry,
53535 &newnd.path, new_dentry);
53536 if (error)
53537 goto exit5;
53538 error = vfs_rename(old_dir->d_inode, old_dentry,
53539 new_dir->d_inode, new_dentry);
53540 + if (!error)
53541 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
53542 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
53543 exit5:
53544 dput(new_dentry);
53545 exit4:
53546 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
53547
53548 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
53549 {
53550 + char tmpbuf[64];
53551 + const char *newlink;
53552 int len;
53553
53554 len = PTR_ERR(link);
53555 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
53556 len = strlen(link);
53557 if (len > (unsigned) buflen)
53558 len = buflen;
53559 - if (copy_to_user(buffer, link, len))
53560 +
53561 + if (len < sizeof(tmpbuf)) {
53562 + memcpy(tmpbuf, link, len);
53563 + newlink = tmpbuf;
53564 + } else
53565 + newlink = link;
53566 +
53567 + if (copy_to_user(buffer, newlink, len))
53568 len = -EFAULT;
53569 out:
53570 return len;
53571 diff --git a/fs/namespace.c b/fs/namespace.c
53572 index e945b81..fc018e2 100644
53573 --- a/fs/namespace.c
53574 +++ b/fs/namespace.c
53575 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
53576 if (!(sb->s_flags & MS_RDONLY))
53577 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
53578 up_write(&sb->s_umount);
53579 +
53580 + gr_log_remount(mnt->mnt_devname, retval);
53581 +
53582 return retval;
53583 }
53584
53585 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
53586 br_write_unlock(&vfsmount_lock);
53587 up_write(&namespace_sem);
53588 release_mounts(&umount_list);
53589 +
53590 + gr_log_unmount(mnt->mnt_devname, retval);
53591 +
53592 return retval;
53593 }
53594
53595 @@ -1257,7 +1263,7 @@ static inline bool may_mount(void)
53596 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
53597 */
53598
53599 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
53600 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
53601 {
53602 struct path path;
53603 struct mount *mnt;
53604 @@ -1297,7 +1303,7 @@ out:
53605 /*
53606 * The 2.0 compatible umount. No flags.
53607 */
53608 -SYSCALL_DEFINE1(oldumount, char __user *, name)
53609 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
53610 {
53611 return sys_umount(name, 0);
53612 }
53613 @@ -2267,6 +2273,16 @@ long do_mount(const char *dev_name, const char *dir_name,
53614 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
53615 MS_STRICTATIME);
53616
53617 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
53618 + retval = -EPERM;
53619 + goto dput_out;
53620 + }
53621 +
53622 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
53623 + retval = -EPERM;
53624 + goto dput_out;
53625 + }
53626 +
53627 if (flags & MS_REMOUNT)
53628 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
53629 data_page);
53630 @@ -2281,6 +2297,9 @@ long do_mount(const char *dev_name, const char *dir_name,
53631 dev_name, data_page);
53632 dput_out:
53633 path_put(&path);
53634 +
53635 + gr_log_mount(dev_name, dir_name, retval);
53636 +
53637 return retval;
53638 }
53639
53640 @@ -2454,8 +2473,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
53641 }
53642 EXPORT_SYMBOL(mount_subtree);
53643
53644 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
53645 - char __user *, type, unsigned long, flags, void __user *, data)
53646 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
53647 + const char __user *, type, unsigned long, flags, void __user *, data)
53648 {
53649 int ret;
53650 char *kernel_type;
53651 @@ -2567,6 +2586,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
53652 if (error)
53653 goto out2;
53654
53655 + if (gr_handle_chroot_pivot()) {
53656 + error = -EPERM;
53657 + goto out2;
53658 + }
53659 +
53660 get_fs_root(current->fs, &root);
53661 error = lock_mount(&old);
53662 if (error)
53663 @@ -2815,7 +2839,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
53664 !nsown_capable(CAP_SYS_ADMIN))
53665 return -EPERM;
53666
53667 - if (fs->users != 1)
53668 + if (atomic_read(&fs->users) != 1)
53669 return -EINVAL;
53670
53671 get_mnt_ns(mnt_ns);
53672 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
53673 index 59461c9..b17c57e 100644
53674 --- a/fs/nfs/callback_xdr.c
53675 +++ b/fs/nfs/callback_xdr.c
53676 @@ -51,7 +51,7 @@ struct callback_op {
53677 callback_decode_arg_t decode_args;
53678 callback_encode_res_t encode_res;
53679 long res_maxsize;
53680 -};
53681 +} __do_const;
53682
53683 static struct callback_op callback_ops[];
53684
53685 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
53686 index 1f94167..79c4ce4 100644
53687 --- a/fs/nfs/inode.c
53688 +++ b/fs/nfs/inode.c
53689 @@ -1041,16 +1041,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
53690 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
53691 }
53692
53693 -static atomic_long_t nfs_attr_generation_counter;
53694 +static atomic_long_unchecked_t nfs_attr_generation_counter;
53695
53696 static unsigned long nfs_read_attr_generation_counter(void)
53697 {
53698 - return atomic_long_read(&nfs_attr_generation_counter);
53699 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
53700 }
53701
53702 unsigned long nfs_inc_attr_generation_counter(void)
53703 {
53704 - return atomic_long_inc_return(&nfs_attr_generation_counter);
53705 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
53706 }
53707
53708 void nfs_fattr_init(struct nfs_fattr *fattr)
53709 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
53710 index d401d01..10b3e62 100644
53711 --- a/fs/nfsd/nfs4proc.c
53712 +++ b/fs/nfsd/nfs4proc.c
53713 @@ -1109,7 +1109,7 @@ struct nfsd4_operation {
53714 nfsd4op_rsize op_rsize_bop;
53715 stateid_getter op_get_currentstateid;
53716 stateid_setter op_set_currentstateid;
53717 -};
53718 +} __do_const;
53719
53720 static struct nfsd4_operation nfsd4_ops[];
53721
53722 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
53723 index 6eb0dc5..29067a9 100644
53724 --- a/fs/nfsd/nfs4xdr.c
53725 +++ b/fs/nfsd/nfs4xdr.c
53726 @@ -1457,7 +1457,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
53727
53728 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
53729
53730 -static nfsd4_dec nfsd4_dec_ops[] = {
53731 +static const nfsd4_dec nfsd4_dec_ops[] = {
53732 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53733 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53734 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53735 @@ -1497,7 +1497,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
53736 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
53737 };
53738
53739 -static nfsd4_dec nfsd41_dec_ops[] = {
53740 +static const nfsd4_dec nfsd41_dec_ops[] = {
53741 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53742 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53743 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53744 @@ -1559,7 +1559,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
53745 };
53746
53747 struct nfsd4_minorversion_ops {
53748 - nfsd4_dec *decoders;
53749 + const nfsd4_dec *decoders;
53750 int nops;
53751 };
53752
53753 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
53754 index ca05f6d..411a576 100644
53755 --- a/fs/nfsd/nfscache.c
53756 +++ b/fs/nfsd/nfscache.c
53757 @@ -461,13 +461,15 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
53758 {
53759 struct svc_cacherep *rp = rqstp->rq_cacherep;
53760 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
53761 - int len;
53762 + long len;
53763
53764 if (!rp)
53765 return;
53766
53767 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
53768 - len >>= 2;
53769 + if (statp) {
53770 + len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
53771 + len >>= 2;
53772 + }
53773
53774 /* Don't cache excessive amounts of data and XDR failures */
53775 if (!statp || len > (256 >> 2)) {
53776 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
53777 index 2b2e239..c915b48 100644
53778 --- a/fs/nfsd/vfs.c
53779 +++ b/fs/nfsd/vfs.c
53780 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53781 } else {
53782 oldfs = get_fs();
53783 set_fs(KERNEL_DS);
53784 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
53785 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
53786 set_fs(oldfs);
53787 }
53788
53789 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53790
53791 /* Write the data. */
53792 oldfs = get_fs(); set_fs(KERNEL_DS);
53793 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
53794 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
53795 set_fs(oldfs);
53796 if (host_err < 0)
53797 goto out_nfserr;
53798 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
53799 */
53800
53801 oldfs = get_fs(); set_fs(KERNEL_DS);
53802 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
53803 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
53804 set_fs(oldfs);
53805
53806 if (host_err < 0)
53807 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
53808 index fea6bd5..8ee9d81 100644
53809 --- a/fs/nls/nls_base.c
53810 +++ b/fs/nls/nls_base.c
53811 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
53812
53813 int register_nls(struct nls_table * nls)
53814 {
53815 - struct nls_table ** tmp = &tables;
53816 + struct nls_table *tmp = tables;
53817
53818 if (nls->next)
53819 return -EBUSY;
53820
53821 spin_lock(&nls_lock);
53822 - while (*tmp) {
53823 - if (nls == *tmp) {
53824 + while (tmp) {
53825 + if (nls == tmp) {
53826 spin_unlock(&nls_lock);
53827 return -EBUSY;
53828 }
53829 - tmp = &(*tmp)->next;
53830 + tmp = tmp->next;
53831 }
53832 - nls->next = tables;
53833 + pax_open_kernel();
53834 + *(struct nls_table **)&nls->next = tables;
53835 + pax_close_kernel();
53836 tables = nls;
53837 spin_unlock(&nls_lock);
53838 return 0;
53839 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
53840
53841 int unregister_nls(struct nls_table * nls)
53842 {
53843 - struct nls_table ** tmp = &tables;
53844 + struct nls_table * const * tmp = &tables;
53845
53846 spin_lock(&nls_lock);
53847 while (*tmp) {
53848 if (nls == *tmp) {
53849 - *tmp = nls->next;
53850 + pax_open_kernel();
53851 + *(struct nls_table **)tmp = nls->next;
53852 + pax_close_kernel();
53853 spin_unlock(&nls_lock);
53854 return 0;
53855 }
53856 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
53857 index 7424929..35f6be5 100644
53858 --- a/fs/nls/nls_euc-jp.c
53859 +++ b/fs/nls/nls_euc-jp.c
53860 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
53861 p_nls = load_nls("cp932");
53862
53863 if (p_nls) {
53864 - table.charset2upper = p_nls->charset2upper;
53865 - table.charset2lower = p_nls->charset2lower;
53866 + pax_open_kernel();
53867 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53868 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53869 + pax_close_kernel();
53870 return register_nls(&table);
53871 }
53872
53873 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
53874 index e7bc1d7..06bd4bb 100644
53875 --- a/fs/nls/nls_koi8-ru.c
53876 +++ b/fs/nls/nls_koi8-ru.c
53877 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
53878 p_nls = load_nls("koi8-u");
53879
53880 if (p_nls) {
53881 - table.charset2upper = p_nls->charset2upper;
53882 - table.charset2lower = p_nls->charset2lower;
53883 + pax_open_kernel();
53884 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53885 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53886 + pax_close_kernel();
53887 return register_nls(&table);
53888 }
53889
53890 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
53891 index 5d84442..bf24453 100644
53892 --- a/fs/notify/fanotify/fanotify_user.c
53893 +++ b/fs/notify/fanotify/fanotify_user.c
53894 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
53895
53896 fd = fanotify_event_metadata.fd;
53897 ret = -EFAULT;
53898 - if (copy_to_user(buf, &fanotify_event_metadata,
53899 - fanotify_event_metadata.event_len))
53900 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
53901 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
53902 goto out_close_fd;
53903
53904 ret = prepare_for_access_response(group, event, fd);
53905 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
53906 index 7b51b05..5ea5ef6 100644
53907 --- a/fs/notify/notification.c
53908 +++ b/fs/notify/notification.c
53909 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
53910 * get set to 0 so it will never get 'freed'
53911 */
53912 static struct fsnotify_event *q_overflow_event;
53913 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53914 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53915
53916 /**
53917 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
53918 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53919 */
53920 u32 fsnotify_get_cookie(void)
53921 {
53922 - return atomic_inc_return(&fsnotify_sync_cookie);
53923 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
53924 }
53925 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
53926
53927 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
53928 index aa411c3..c260a84 100644
53929 --- a/fs/ntfs/dir.c
53930 +++ b/fs/ntfs/dir.c
53931 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
53932 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
53933 ~(s64)(ndir->itype.index.block_size - 1)));
53934 /* Bounds checks. */
53935 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53936 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53937 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
53938 "inode 0x%lx or driver bug.", vdir->i_ino);
53939 goto err_out;
53940 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
53941 index 5b2d4f0..c6de396 100644
53942 --- a/fs/ntfs/file.c
53943 +++ b/fs/ntfs/file.c
53944 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
53945 #endif /* NTFS_RW */
53946 };
53947
53948 -const struct file_operations ntfs_empty_file_ops = {};
53949 +const struct file_operations ntfs_empty_file_ops __read_only;
53950
53951 -const struct inode_operations ntfs_empty_inode_ops = {};
53952 +const struct inode_operations ntfs_empty_inode_ops __read_only;
53953 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
53954 index aebeacd..0dcdd26 100644
53955 --- a/fs/ocfs2/localalloc.c
53956 +++ b/fs/ocfs2/localalloc.c
53957 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
53958 goto bail;
53959 }
53960
53961 - atomic_inc(&osb->alloc_stats.moves);
53962 + atomic_inc_unchecked(&osb->alloc_stats.moves);
53963
53964 bail:
53965 if (handle)
53966 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
53967 index d355e6e..578d905 100644
53968 --- a/fs/ocfs2/ocfs2.h
53969 +++ b/fs/ocfs2/ocfs2.h
53970 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
53971
53972 struct ocfs2_alloc_stats
53973 {
53974 - atomic_t moves;
53975 - atomic_t local_data;
53976 - atomic_t bitmap_data;
53977 - atomic_t bg_allocs;
53978 - atomic_t bg_extends;
53979 + atomic_unchecked_t moves;
53980 + atomic_unchecked_t local_data;
53981 + atomic_unchecked_t bitmap_data;
53982 + atomic_unchecked_t bg_allocs;
53983 + atomic_unchecked_t bg_extends;
53984 };
53985
53986 enum ocfs2_local_alloc_state
53987 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
53988 index b7e74b5..19c6536 100644
53989 --- a/fs/ocfs2/suballoc.c
53990 +++ b/fs/ocfs2/suballoc.c
53991 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
53992 mlog_errno(status);
53993 goto bail;
53994 }
53995 - atomic_inc(&osb->alloc_stats.bg_extends);
53996 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
53997
53998 /* You should never ask for this much metadata */
53999 BUG_ON(bits_wanted >
54000 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54001 mlog_errno(status);
54002 goto bail;
54003 }
54004 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54005 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54006
54007 *suballoc_loc = res.sr_bg_blkno;
54008 *suballoc_bit_start = res.sr_bit_offset;
54009 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54010 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54011 res->sr_bits);
54012
54013 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54014 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54015
54016 BUG_ON(res->sr_bits != 1);
54017
54018 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54019 mlog_errno(status);
54020 goto bail;
54021 }
54022 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54023 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54024
54025 BUG_ON(res.sr_bits != 1);
54026
54027 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54028 cluster_start,
54029 num_clusters);
54030 if (!status)
54031 - atomic_inc(&osb->alloc_stats.local_data);
54032 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54033 } else {
54034 if (min_clusters > (osb->bitmap_cpg - 1)) {
54035 /* The only paths asking for contiguousness
54036 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54037 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54038 res.sr_bg_blkno,
54039 res.sr_bit_offset);
54040 - atomic_inc(&osb->alloc_stats.bitmap_data);
54041 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54042 *num_clusters = res.sr_bits;
54043 }
54044 }
54045 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54046 index 01b8516..579c4df 100644
54047 --- a/fs/ocfs2/super.c
54048 +++ b/fs/ocfs2/super.c
54049 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54050 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54051 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54052 "Stats",
54053 - atomic_read(&osb->alloc_stats.bitmap_data),
54054 - atomic_read(&osb->alloc_stats.local_data),
54055 - atomic_read(&osb->alloc_stats.bg_allocs),
54056 - atomic_read(&osb->alloc_stats.moves),
54057 - atomic_read(&osb->alloc_stats.bg_extends));
54058 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54059 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54060 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54061 + atomic_read_unchecked(&osb->alloc_stats.moves),
54062 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54063
54064 out += snprintf(buf + out, len - out,
54065 "%10s => State: %u Descriptor: %llu Size: %u bits "
54066 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54067 spin_lock_init(&osb->osb_xattr_lock);
54068 ocfs2_init_steal_slots(osb);
54069
54070 - atomic_set(&osb->alloc_stats.moves, 0);
54071 - atomic_set(&osb->alloc_stats.local_data, 0);
54072 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54073 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54074 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54075 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54076 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54077 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54078 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54079 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54080
54081 /* Copy the blockcheck stats from the superblock probe */
54082 osb->osb_ecc_stats = *stats;
54083 diff --git a/fs/open.c b/fs/open.c
54084 index 6835446..eadf09f 100644
54085 --- a/fs/open.c
54086 +++ b/fs/open.c
54087 @@ -32,6 +32,8 @@
54088 #include <linux/dnotify.h>
54089 #include <linux/compat.h>
54090
54091 +#define CREATE_TRACE_POINTS
54092 +#include <trace/events/fs.h>
54093 #include "internal.h"
54094
54095 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54096 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
54097 error = locks_verify_truncate(inode, NULL, length);
54098 if (!error)
54099 error = security_path_truncate(path);
54100 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54101 + error = -EACCES;
54102 if (!error)
54103 error = do_truncate(path->dentry, length, 0, NULL);
54104
54105 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54106 error = locks_verify_truncate(inode, f.file, length);
54107 if (!error)
54108 error = security_path_truncate(&f.file->f_path);
54109 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54110 + error = -EACCES;
54111 if (!error)
54112 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54113 sb_end_write(inode->i_sb);
54114 @@ -388,6 +394,9 @@ retry:
54115 if (__mnt_is_readonly(path.mnt))
54116 res = -EROFS;
54117
54118 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54119 + res = -EACCES;
54120 +
54121 out_path_release:
54122 path_put(&path);
54123 if (retry_estale(res, lookup_flags)) {
54124 @@ -419,6 +428,8 @@ retry:
54125 if (error)
54126 goto dput_and_out;
54127
54128 + gr_log_chdir(path.dentry, path.mnt);
54129 +
54130 set_fs_pwd(current->fs, &path);
54131
54132 dput_and_out:
54133 @@ -448,6 +459,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54134 goto out_putf;
54135
54136 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54137 +
54138 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54139 + error = -EPERM;
54140 +
54141 + if (!error)
54142 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54143 +
54144 if (!error)
54145 set_fs_pwd(current->fs, &f.file->f_path);
54146 out_putf:
54147 @@ -477,7 +495,13 @@ retry:
54148 if (error)
54149 goto dput_and_out;
54150
54151 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54152 + goto dput_and_out;
54153 +
54154 set_fs_root(current->fs, &path);
54155 +
54156 + gr_handle_chroot_chdir(&path);
54157 +
54158 error = 0;
54159 dput_and_out:
54160 path_put(&path);
54161 @@ -499,6 +523,16 @@ static int chmod_common(struct path *path, umode_t mode)
54162 if (error)
54163 return error;
54164 mutex_lock(&inode->i_mutex);
54165 +
54166 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54167 + error = -EACCES;
54168 + goto out_unlock;
54169 + }
54170 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54171 + error = -EACCES;
54172 + goto out_unlock;
54173 + }
54174 +
54175 error = security_path_chmod(path, mode);
54176 if (error)
54177 goto out_unlock;
54178 @@ -559,6 +593,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54179 uid = make_kuid(current_user_ns(), user);
54180 gid = make_kgid(current_user_ns(), group);
54181
54182 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54183 + return -EACCES;
54184 +
54185 newattrs.ia_valid = ATTR_CTIME;
54186 if (user != (uid_t) -1) {
54187 if (!uid_valid(uid))
54188 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54189 } else {
54190 fsnotify_open(f);
54191 fd_install(fd, f);
54192 + trace_do_sys_open(tmp->name, flags, mode);
54193 }
54194 }
54195 putname(tmp);
54196 diff --git a/fs/pipe.c b/fs/pipe.c
54197 index 2234f3f..f9083a1 100644
54198 --- a/fs/pipe.c
54199 +++ b/fs/pipe.c
54200 @@ -438,9 +438,9 @@ redo:
54201 }
54202 if (bufs) /* More to do? */
54203 continue;
54204 - if (!pipe->writers)
54205 + if (!atomic_read(&pipe->writers))
54206 break;
54207 - if (!pipe->waiting_writers) {
54208 + if (!atomic_read(&pipe->waiting_writers)) {
54209 /* syscall merging: Usually we must not sleep
54210 * if O_NONBLOCK is set, or if we got some data.
54211 * But if a writer sleeps in kernel space, then
54212 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54213 mutex_lock(&inode->i_mutex);
54214 pipe = inode->i_pipe;
54215
54216 - if (!pipe->readers) {
54217 + if (!atomic_read(&pipe->readers)) {
54218 send_sig(SIGPIPE, current, 0);
54219 ret = -EPIPE;
54220 goto out;
54221 @@ -553,7 +553,7 @@ redo1:
54222 for (;;) {
54223 int bufs;
54224
54225 - if (!pipe->readers) {
54226 + if (!atomic_read(&pipe->readers)) {
54227 send_sig(SIGPIPE, current, 0);
54228 if (!ret)
54229 ret = -EPIPE;
54230 @@ -644,9 +644,9 @@ redo2:
54231 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54232 do_wakeup = 0;
54233 }
54234 - pipe->waiting_writers++;
54235 + atomic_inc(&pipe->waiting_writers);
54236 pipe_wait(pipe);
54237 - pipe->waiting_writers--;
54238 + atomic_dec(&pipe->waiting_writers);
54239 }
54240 out:
54241 mutex_unlock(&inode->i_mutex);
54242 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54243 mask = 0;
54244 if (filp->f_mode & FMODE_READ) {
54245 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54246 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54247 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54248 mask |= POLLHUP;
54249 }
54250
54251 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54252 * Most Unices do not set POLLERR for FIFOs but on Linux they
54253 * behave exactly like pipes for poll().
54254 */
54255 - if (!pipe->readers)
54256 + if (!atomic_read(&pipe->readers))
54257 mask |= POLLERR;
54258 }
54259
54260 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54261
54262 mutex_lock(&inode->i_mutex);
54263 pipe = inode->i_pipe;
54264 - pipe->readers -= decr;
54265 - pipe->writers -= decw;
54266 + atomic_sub(decr, &pipe->readers);
54267 + atomic_sub(decw, &pipe->writers);
54268
54269 - if (!pipe->readers && !pipe->writers) {
54270 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54271 free_pipe_info(inode);
54272 } else {
54273 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54274 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54275
54276 if (inode->i_pipe) {
54277 ret = 0;
54278 - inode->i_pipe->readers++;
54279 + atomic_inc(&inode->i_pipe->readers);
54280 }
54281
54282 mutex_unlock(&inode->i_mutex);
54283 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54284
54285 if (inode->i_pipe) {
54286 ret = 0;
54287 - inode->i_pipe->writers++;
54288 + atomic_inc(&inode->i_pipe->writers);
54289 }
54290
54291 mutex_unlock(&inode->i_mutex);
54292 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54293 if (inode->i_pipe) {
54294 ret = 0;
54295 if (filp->f_mode & FMODE_READ)
54296 - inode->i_pipe->readers++;
54297 + atomic_inc(&inode->i_pipe->readers);
54298 if (filp->f_mode & FMODE_WRITE)
54299 - inode->i_pipe->writers++;
54300 + atomic_inc(&inode->i_pipe->writers);
54301 }
54302
54303 mutex_unlock(&inode->i_mutex);
54304 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54305 inode->i_pipe = NULL;
54306 }
54307
54308 -static struct vfsmount *pipe_mnt __read_mostly;
54309 +struct vfsmount *pipe_mnt __read_mostly;
54310
54311 /*
54312 * pipefs_dname() is called from d_path().
54313 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54314 goto fail_iput;
54315 inode->i_pipe = pipe;
54316
54317 - pipe->readers = pipe->writers = 1;
54318 + atomic_set(&pipe->readers, 1);
54319 + atomic_set(&pipe->writers, 1);
54320 inode->i_fop = &rdwr_pipefifo_fops;
54321
54322 /*
54323 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54324 index 15af622..0e9f4467 100644
54325 --- a/fs/proc/Kconfig
54326 +++ b/fs/proc/Kconfig
54327 @@ -30,12 +30,12 @@ config PROC_FS
54328
54329 config PROC_KCORE
54330 bool "/proc/kcore support" if !ARM
54331 - depends on PROC_FS && MMU
54332 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54333
54334 config PROC_VMCORE
54335 bool "/proc/vmcore support"
54336 - depends on PROC_FS && CRASH_DUMP
54337 - default y
54338 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54339 + default n
54340 help
54341 Exports the dump image of crashed kernel in ELF format.
54342
54343 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54344 limited in memory.
54345
54346 config PROC_PAGE_MONITOR
54347 - default y
54348 - depends on PROC_FS && MMU
54349 + default n
54350 + depends on PROC_FS && MMU && !GRKERNSEC
54351 bool "Enable /proc page monitoring" if EXPERT
54352 help
54353 Various /proc files exist to monitor process memory utilization:
54354 diff --git a/fs/proc/array.c b/fs/proc/array.c
54355 index cbd0f1b..adec3f0 100644
54356 --- a/fs/proc/array.c
54357 +++ b/fs/proc/array.c
54358 @@ -60,6 +60,7 @@
54359 #include <linux/tty.h>
54360 #include <linux/string.h>
54361 #include <linux/mman.h>
54362 +#include <linux/grsecurity.h>
54363 #include <linux/proc_fs.h>
54364 #include <linux/ioport.h>
54365 #include <linux/uaccess.h>
54366 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54367 seq_putc(m, '\n');
54368 }
54369
54370 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54371 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54372 +{
54373 + if (p->mm)
54374 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54375 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54376 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54377 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54378 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54379 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54380 + else
54381 + seq_printf(m, "PaX:\t-----\n");
54382 +}
54383 +#endif
54384 +
54385 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54386 struct pid *pid, struct task_struct *task)
54387 {
54388 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54389 task_cpus_allowed(m, task);
54390 cpuset_task_status_allowed(m, task);
54391 task_context_switch_counts(m, task);
54392 +
54393 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54394 + task_pax(m, task);
54395 +#endif
54396 +
54397 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54398 + task_grsec_rbac(m, task);
54399 +#endif
54400 +
54401 return 0;
54402 }
54403
54404 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54405 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54406 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54407 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54408 +#endif
54409 +
54410 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54411 struct pid *pid, struct task_struct *task, int whole)
54412 {
54413 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54414 char tcomm[sizeof(task->comm)];
54415 unsigned long flags;
54416
54417 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54418 + if (current->exec_id != m->exec_id) {
54419 + gr_log_badprocpid("stat");
54420 + return 0;
54421 + }
54422 +#endif
54423 +
54424 state = *get_task_state(task);
54425 vsize = eip = esp = 0;
54426 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54427 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54428 gtime = task_gtime(task);
54429 }
54430
54431 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54432 + if (PAX_RAND_FLAGS(mm)) {
54433 + eip = 0;
54434 + esp = 0;
54435 + wchan = 0;
54436 + }
54437 +#endif
54438 +#ifdef CONFIG_GRKERNSEC_HIDESYM
54439 + wchan = 0;
54440 + eip =0;
54441 + esp =0;
54442 +#endif
54443 +
54444 /* scale priority and nice values from timeslices to -20..20 */
54445 /* to make it look like a "normal" Unix priority/nice value */
54446 priority = task_prio(task);
54447 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54448 seq_put_decimal_ull(m, ' ', vsize);
54449 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
54450 seq_put_decimal_ull(m, ' ', rsslim);
54451 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54452 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
54453 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
54454 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
54455 +#else
54456 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
54457 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
54458 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
54459 +#endif
54460 seq_put_decimal_ull(m, ' ', esp);
54461 seq_put_decimal_ull(m, ' ', eip);
54462 /* The signal information here is obsolete.
54463 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54464 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
54465 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
54466
54467 - if (mm && permitted) {
54468 + if (mm && permitted
54469 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54470 + && !PAX_RAND_FLAGS(mm)
54471 +#endif
54472 + ) {
54473 seq_put_decimal_ull(m, ' ', mm->start_data);
54474 seq_put_decimal_ull(m, ' ', mm->end_data);
54475 seq_put_decimal_ull(m, ' ', mm->start_brk);
54476 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54477 struct pid *pid, struct task_struct *task)
54478 {
54479 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
54480 - struct mm_struct *mm = get_task_mm(task);
54481 + struct mm_struct *mm;
54482
54483 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54484 + if (current->exec_id != m->exec_id) {
54485 + gr_log_badprocpid("statm");
54486 + return 0;
54487 + }
54488 +#endif
54489 + mm = get_task_mm(task);
54490 if (mm) {
54491 size = task_statm(mm, &shared, &text, &data, &resident);
54492 mmput(mm);
54493 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54494 return 0;
54495 }
54496
54497 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54498 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
54499 +{
54500 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
54501 +}
54502 +#endif
54503 +
54504 #ifdef CONFIG_CHECKPOINT_RESTORE
54505 static struct pid *
54506 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
54507 diff --git a/fs/proc/base.c b/fs/proc/base.c
54508 index 69078c7..3e12a75 100644
54509 --- a/fs/proc/base.c
54510 +++ b/fs/proc/base.c
54511 @@ -112,6 +112,14 @@ struct pid_entry {
54512 union proc_op op;
54513 };
54514
54515 +struct getdents_callback {
54516 + struct linux_dirent __user * current_dir;
54517 + struct linux_dirent __user * previous;
54518 + struct file * file;
54519 + int count;
54520 + int error;
54521 +};
54522 +
54523 #define NOD(NAME, MODE, IOP, FOP, OP) { \
54524 .name = (NAME), \
54525 .len = sizeof(NAME) - 1, \
54526 @@ -209,6 +217,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
54527 if (!mm->arg_end)
54528 goto out_mm; /* Shh! No looking before we're done */
54529
54530 + if (gr_acl_handle_procpidmem(task))
54531 + goto out_mm;
54532 +
54533 len = mm->arg_end - mm->arg_start;
54534
54535 if (len > PAGE_SIZE)
54536 @@ -236,12 +247,28 @@ out:
54537 return res;
54538 }
54539
54540 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54541 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54542 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54543 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54544 +#endif
54545 +
54546 static int proc_pid_auxv(struct task_struct *task, char *buffer)
54547 {
54548 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
54549 int res = PTR_ERR(mm);
54550 if (mm && !IS_ERR(mm)) {
54551 unsigned int nwords = 0;
54552 +
54553 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54554 + /* allow if we're currently ptracing this task */
54555 + if (PAX_RAND_FLAGS(mm) &&
54556 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
54557 + mmput(mm);
54558 + return 0;
54559 + }
54560 +#endif
54561 +
54562 do {
54563 nwords += 2;
54564 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
54565 @@ -255,7 +282,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
54566 }
54567
54568
54569 -#ifdef CONFIG_KALLSYMS
54570 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54571 /*
54572 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
54573 * Returns the resolved symbol. If that fails, simply return the address.
54574 @@ -294,7 +321,7 @@ static void unlock_trace(struct task_struct *task)
54575 mutex_unlock(&task->signal->cred_guard_mutex);
54576 }
54577
54578 -#ifdef CONFIG_STACKTRACE
54579 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54580
54581 #define MAX_STACK_TRACE_DEPTH 64
54582
54583 @@ -486,7 +513,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
54584 return count;
54585 }
54586
54587 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54588 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54589 static int proc_pid_syscall(struct task_struct *task, char *buffer)
54590 {
54591 long nr;
54592 @@ -515,7 +542,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
54593 /************************************************************************/
54594
54595 /* permission checks */
54596 -static int proc_fd_access_allowed(struct inode *inode)
54597 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
54598 {
54599 struct task_struct *task;
54600 int allowed = 0;
54601 @@ -525,7 +552,10 @@ static int proc_fd_access_allowed(struct inode *inode)
54602 */
54603 task = get_proc_task(inode);
54604 if (task) {
54605 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54606 + if (log)
54607 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54608 + else
54609 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54610 put_task_struct(task);
54611 }
54612 return allowed;
54613 @@ -556,10 +586,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
54614 struct task_struct *task,
54615 int hide_pid_min)
54616 {
54617 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54618 + return false;
54619 +
54620 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54621 + rcu_read_lock();
54622 + {
54623 + const struct cred *tmpcred = current_cred();
54624 + const struct cred *cred = __task_cred(task);
54625 +
54626 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
54627 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54628 + || in_group_p(grsec_proc_gid)
54629 +#endif
54630 + ) {
54631 + rcu_read_unlock();
54632 + return true;
54633 + }
54634 + }
54635 + rcu_read_unlock();
54636 +
54637 + if (!pid->hide_pid)
54638 + return false;
54639 +#endif
54640 +
54641 if (pid->hide_pid < hide_pid_min)
54642 return true;
54643 if (in_group_p(pid->pid_gid))
54644 return true;
54645 +
54646 return ptrace_may_access(task, PTRACE_MODE_READ);
54647 }
54648
54649 @@ -577,7 +632,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
54650 put_task_struct(task);
54651
54652 if (!has_perms) {
54653 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54654 + {
54655 +#else
54656 if (pid->hide_pid == 2) {
54657 +#endif
54658 /*
54659 * Let's make getdents(), stat(), and open()
54660 * consistent with each other. If a process
54661 @@ -675,6 +734,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54662 if (!task)
54663 return -ESRCH;
54664
54665 + if (gr_acl_handle_procpidmem(task)) {
54666 + put_task_struct(task);
54667 + return -EPERM;
54668 + }
54669 +
54670 mm = mm_access(task, mode);
54671 put_task_struct(task);
54672
54673 @@ -690,6 +754,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54674
54675 file->private_data = mm;
54676
54677 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54678 + file->f_version = current->exec_id;
54679 +#endif
54680 +
54681 return 0;
54682 }
54683
54684 @@ -711,6 +779,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54685 ssize_t copied;
54686 char *page;
54687
54688 +#ifdef CONFIG_GRKERNSEC
54689 + if (write)
54690 + return -EPERM;
54691 +#endif
54692 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54693 + if (file->f_version != current->exec_id) {
54694 + gr_log_badprocpid("mem");
54695 + return 0;
54696 + }
54697 +#endif
54698 +
54699 if (!mm)
54700 return 0;
54701
54702 @@ -723,7 +802,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54703 goto free;
54704
54705 while (count > 0) {
54706 - int this_len = min_t(int, count, PAGE_SIZE);
54707 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
54708
54709 if (write && copy_from_user(page, buf, this_len)) {
54710 copied = -EFAULT;
54711 @@ -815,6 +894,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54712 if (!mm)
54713 return 0;
54714
54715 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54716 + if (file->f_version != current->exec_id) {
54717 + gr_log_badprocpid("environ");
54718 + return 0;
54719 + }
54720 +#endif
54721 +
54722 page = (char *)__get_free_page(GFP_TEMPORARY);
54723 if (!page)
54724 return -ENOMEM;
54725 @@ -824,7 +910,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54726 goto free;
54727 while (count > 0) {
54728 size_t this_len, max_len;
54729 - int retval;
54730 + ssize_t retval;
54731
54732 if (src >= (mm->env_end - mm->env_start))
54733 break;
54734 @@ -1430,7 +1516,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
54735 int error = -EACCES;
54736
54737 /* Are we allowed to snoop on the tasks file descriptors? */
54738 - if (!proc_fd_access_allowed(inode))
54739 + if (!proc_fd_access_allowed(inode, 0))
54740 goto out;
54741
54742 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54743 @@ -1474,8 +1560,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
54744 struct path path;
54745
54746 /* Are we allowed to snoop on the tasks file descriptors? */
54747 - if (!proc_fd_access_allowed(inode))
54748 - goto out;
54749 + /* logging this is needed for learning on chromium to work properly,
54750 + but we don't want to flood the logs from 'ps' which does a readlink
54751 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
54752 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
54753 + */
54754 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
54755 + if (!proc_fd_access_allowed(inode,0))
54756 + goto out;
54757 + } else {
54758 + if (!proc_fd_access_allowed(inode,1))
54759 + goto out;
54760 + }
54761
54762 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54763 if (error)
54764 @@ -1525,7 +1621,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
54765 rcu_read_lock();
54766 cred = __task_cred(task);
54767 inode->i_uid = cred->euid;
54768 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54769 + inode->i_gid = grsec_proc_gid;
54770 +#else
54771 inode->i_gid = cred->egid;
54772 +#endif
54773 rcu_read_unlock();
54774 }
54775 security_task_to_inode(task, inode);
54776 @@ -1561,10 +1661,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
54777 return -ENOENT;
54778 }
54779 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54780 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54781 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54782 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54783 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54784 +#endif
54785 task_dumpable(task)) {
54786 cred = __task_cred(task);
54787 stat->uid = cred->euid;
54788 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54789 + stat->gid = grsec_proc_gid;
54790 +#else
54791 stat->gid = cred->egid;
54792 +#endif
54793 }
54794 }
54795 rcu_read_unlock();
54796 @@ -1602,11 +1711,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
54797
54798 if (task) {
54799 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54800 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54801 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54802 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54803 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54804 +#endif
54805 task_dumpable(task)) {
54806 rcu_read_lock();
54807 cred = __task_cred(task);
54808 inode->i_uid = cred->euid;
54809 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54810 + inode->i_gid = grsec_proc_gid;
54811 +#else
54812 inode->i_gid = cred->egid;
54813 +#endif
54814 rcu_read_unlock();
54815 } else {
54816 inode->i_uid = GLOBAL_ROOT_UID;
54817 @@ -2059,6 +2177,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
54818 if (!task)
54819 goto out_no_task;
54820
54821 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54822 + goto out;
54823 +
54824 /*
54825 * Yes, it does not scale. And it should not. Don't add
54826 * new entries into /proc/<tgid>/ without very good reasons.
54827 @@ -2103,6 +2224,9 @@ static int proc_pident_readdir(struct file *filp,
54828 if (!task)
54829 goto out_no_task;
54830
54831 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54832 + goto out;
54833 +
54834 ret = 0;
54835 i = filp->f_pos;
54836 switch (i) {
54837 @@ -2516,7 +2640,7 @@ static const struct pid_entry tgid_base_stuff[] = {
54838 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
54839 #endif
54840 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54841 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54842 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54843 INF("syscall", S_IRUGO, proc_pid_syscall),
54844 #endif
54845 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54846 @@ -2541,10 +2665,10 @@ static const struct pid_entry tgid_base_stuff[] = {
54847 #ifdef CONFIG_SECURITY
54848 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54849 #endif
54850 -#ifdef CONFIG_KALLSYMS
54851 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54852 INF("wchan", S_IRUGO, proc_pid_wchan),
54853 #endif
54854 -#ifdef CONFIG_STACKTRACE
54855 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54856 ONE("stack", S_IRUGO, proc_pid_stack),
54857 #endif
54858 #ifdef CONFIG_SCHEDSTATS
54859 @@ -2578,6 +2702,9 @@ static const struct pid_entry tgid_base_stuff[] = {
54860 #ifdef CONFIG_HARDWALL
54861 INF("hardwall", S_IRUGO, proc_pid_hardwall),
54862 #endif
54863 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54864 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
54865 +#endif
54866 #ifdef CONFIG_USER_NS
54867 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
54868 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
54869 @@ -2707,7 +2834,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
54870 if (!inode)
54871 goto out;
54872
54873 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54874 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
54875 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54876 + inode->i_gid = grsec_proc_gid;
54877 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
54878 +#else
54879 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
54880 +#endif
54881 inode->i_op = &proc_tgid_base_inode_operations;
54882 inode->i_fop = &proc_tgid_base_operations;
54883 inode->i_flags|=S_IMMUTABLE;
54884 @@ -2745,7 +2879,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
54885 if (!task)
54886 goto out;
54887
54888 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54889 + goto out_put_task;
54890 +
54891 result = proc_pid_instantiate(dir, dentry, task, NULL);
54892 +out_put_task:
54893 put_task_struct(task);
54894 out:
54895 return result;
54896 @@ -2808,6 +2946,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
54897 static int fake_filldir(void *buf, const char *name, int namelen,
54898 loff_t offset, u64 ino, unsigned d_type)
54899 {
54900 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
54901 + __buf->error = -EINVAL;
54902 return 0;
54903 }
54904
54905 @@ -2859,7 +2999,7 @@ static const struct pid_entry tid_base_stuff[] = {
54906 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
54907 #endif
54908 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54909 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54910 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54911 INF("syscall", S_IRUGO, proc_pid_syscall),
54912 #endif
54913 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54914 @@ -2886,10 +3026,10 @@ static const struct pid_entry tid_base_stuff[] = {
54915 #ifdef CONFIG_SECURITY
54916 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54917 #endif
54918 -#ifdef CONFIG_KALLSYMS
54919 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54920 INF("wchan", S_IRUGO, proc_pid_wchan),
54921 #endif
54922 -#ifdef CONFIG_STACKTRACE
54923 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54924 ONE("stack", S_IRUGO, proc_pid_stack),
54925 #endif
54926 #ifdef CONFIG_SCHEDSTATS
54927 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
54928 index 82676e3..5f8518a 100644
54929 --- a/fs/proc/cmdline.c
54930 +++ b/fs/proc/cmdline.c
54931 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
54932
54933 static int __init proc_cmdline_init(void)
54934 {
54935 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54936 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
54937 +#else
54938 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
54939 +#endif
54940 return 0;
54941 }
54942 module_init(proc_cmdline_init);
54943 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
54944 index b143471..bb105e5 100644
54945 --- a/fs/proc/devices.c
54946 +++ b/fs/proc/devices.c
54947 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
54948
54949 static int __init proc_devices_init(void)
54950 {
54951 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54952 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
54953 +#else
54954 proc_create("devices", 0, NULL, &proc_devinfo_operations);
54955 +#endif
54956 return 0;
54957 }
54958 module_init(proc_devices_init);
54959 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
54960 index d7a4a28..0201742 100644
54961 --- a/fs/proc/fd.c
54962 +++ b/fs/proc/fd.c
54963 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
54964 if (!task)
54965 return -ENOENT;
54966
54967 - files = get_files_struct(task);
54968 + if (!gr_acl_handle_procpidmem(task))
54969 + files = get_files_struct(task);
54970 put_task_struct(task);
54971
54972 if (files) {
54973 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
54974 */
54975 int proc_fd_permission(struct inode *inode, int mask)
54976 {
54977 + struct task_struct *task;
54978 int rv = generic_permission(inode, mask);
54979 - if (rv == 0)
54980 - return 0;
54981 +
54982 if (task_pid(current) == proc_pid(inode))
54983 rv = 0;
54984 +
54985 + task = get_proc_task(inode);
54986 + if (task == NULL)
54987 + return rv;
54988 +
54989 + if (gr_acl_handle_procpidmem(task))
54990 + rv = -EACCES;
54991 +
54992 + put_task_struct(task);
54993 +
54994 return rv;
54995 }
54996
54997 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
54998 index 869116c..820cb27 100644
54999 --- a/fs/proc/inode.c
55000 +++ b/fs/proc/inode.c
55001 @@ -22,11 +22,17 @@
55002 #include <linux/seq_file.h>
55003 #include <linux/slab.h>
55004 #include <linux/mount.h>
55005 +#include <linux/grsecurity.h>
55006
55007 #include <asm/uaccess.h>
55008
55009 #include "internal.h"
55010
55011 +#ifdef CONFIG_PROC_SYSCTL
55012 +extern const struct inode_operations proc_sys_inode_operations;
55013 +extern const struct inode_operations proc_sys_dir_operations;
55014 +#endif
55015 +
55016 static void proc_evict_inode(struct inode *inode)
55017 {
55018 struct proc_dir_entry *de;
55019 @@ -54,6 +60,13 @@ static void proc_evict_inode(struct inode *inode)
55020 ns = PROC_I(inode)->ns;
55021 if (ns_ops && ns)
55022 ns_ops->put(ns);
55023 +
55024 +#ifdef CONFIG_PROC_SYSCTL
55025 + if (inode->i_op == &proc_sys_inode_operations ||
55026 + inode->i_op == &proc_sys_dir_operations)
55027 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55028 +#endif
55029 +
55030 }
55031
55032 static struct kmem_cache * proc_inode_cachep;
55033 @@ -456,7 +469,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55034 if (de->mode) {
55035 inode->i_mode = de->mode;
55036 inode->i_uid = de->uid;
55037 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55038 + inode->i_gid = grsec_proc_gid;
55039 +#else
55040 inode->i_gid = de->gid;
55041 +#endif
55042 }
55043 if (de->size)
55044 inode->i_size = de->size;
55045 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55046 index 85ff3a4..a512bd8 100644
55047 --- a/fs/proc/internal.h
55048 +++ b/fs/proc/internal.h
55049 @@ -56,6 +56,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55050 struct pid *pid, struct task_struct *task);
55051 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55052 struct pid *pid, struct task_struct *task);
55053 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55054 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55055 +#endif
55056 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55057
55058 extern const struct file_operations proc_tid_children_operations;
55059 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55060 index eda6f01..006ae24 100644
55061 --- a/fs/proc/kcore.c
55062 +++ b/fs/proc/kcore.c
55063 @@ -481,9 +481,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55064 * the addresses in the elf_phdr on our list.
55065 */
55066 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55067 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55068 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55069 + if (tsz > buflen)
55070 tsz = buflen;
55071 -
55072 +
55073 while (buflen) {
55074 struct kcore_list *m;
55075
55076 @@ -512,20 +513,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55077 kfree(elf_buf);
55078 } else {
55079 if (kern_addr_valid(start)) {
55080 - unsigned long n;
55081 + char *elf_buf;
55082 + mm_segment_t oldfs;
55083
55084 - n = copy_to_user(buffer, (char *)start, tsz);
55085 - /*
55086 - * We cannot distinguish between fault on source
55087 - * and fault on destination. When this happens
55088 - * we clear too and hope it will trigger the
55089 - * EFAULT again.
55090 - */
55091 - if (n) {
55092 - if (clear_user(buffer + tsz - n,
55093 - n))
55094 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55095 + if (!elf_buf)
55096 + return -ENOMEM;
55097 + oldfs = get_fs();
55098 + set_fs(KERNEL_DS);
55099 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55100 + set_fs(oldfs);
55101 + if (copy_to_user(buffer, elf_buf, tsz)) {
55102 + kfree(elf_buf);
55103 return -EFAULT;
55104 + }
55105 }
55106 + set_fs(oldfs);
55107 + kfree(elf_buf);
55108 } else {
55109 if (clear_user(buffer, tsz))
55110 return -EFAULT;
55111 @@ -545,6 +549,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55112
55113 static int open_kcore(struct inode *inode, struct file *filp)
55114 {
55115 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55116 + return -EPERM;
55117 +#endif
55118 if (!capable(CAP_SYS_RAWIO))
55119 return -EPERM;
55120 if (kcore_need_update)
55121 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55122 index 1efaaa1..834e49a 100644
55123 --- a/fs/proc/meminfo.c
55124 +++ b/fs/proc/meminfo.c
55125 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55126 vmi.used >> 10,
55127 vmi.largest_chunk >> 10
55128 #ifdef CONFIG_MEMORY_FAILURE
55129 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55130 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55131 #endif
55132 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55133 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55134 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55135 index ccfd99b..1b7e255 100644
55136 --- a/fs/proc/nommu.c
55137 +++ b/fs/proc/nommu.c
55138 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55139 if (len < 1)
55140 len = 1;
55141 seq_printf(m, "%*c", len, ' ');
55142 - seq_path(m, &file->f_path, "");
55143 + seq_path(m, &file->f_path, "\n\\");
55144 }
55145
55146 seq_putc(m, '\n');
55147 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55148 index b4ac657..0842bd2 100644
55149 --- a/fs/proc/proc_net.c
55150 +++ b/fs/proc/proc_net.c
55151 @@ -23,6 +23,7 @@
55152 #include <linux/nsproxy.h>
55153 #include <net/net_namespace.h>
55154 #include <linux/seq_file.h>
55155 +#include <linux/grsecurity.h>
55156
55157 #include "internal.h"
55158
55159 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55160 struct task_struct *task;
55161 struct nsproxy *ns;
55162 struct net *net = NULL;
55163 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55164 + const struct cred *cred = current_cred();
55165 +#endif
55166 +
55167 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55168 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55169 + return net;
55170 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55171 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55172 + return net;
55173 +#endif
55174
55175 rcu_read_lock();
55176 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55177 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55178 index ac05f33..1e6dc7e 100644
55179 --- a/fs/proc/proc_sysctl.c
55180 +++ b/fs/proc/proc_sysctl.c
55181 @@ -13,11 +13,15 @@
55182 #include <linux/module.h>
55183 #include "internal.h"
55184
55185 +extern int gr_handle_chroot_sysctl(const int op);
55186 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55187 + const int op);
55188 +
55189 static const struct dentry_operations proc_sys_dentry_operations;
55190 static const struct file_operations proc_sys_file_operations;
55191 -static const struct inode_operations proc_sys_inode_operations;
55192 +const struct inode_operations proc_sys_inode_operations;
55193 static const struct file_operations proc_sys_dir_file_operations;
55194 -static const struct inode_operations proc_sys_dir_operations;
55195 +const struct inode_operations proc_sys_dir_operations;
55196
55197 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55198 {
55199 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55200
55201 err = NULL;
55202 d_set_d_op(dentry, &proc_sys_dentry_operations);
55203 +
55204 + gr_handle_proc_create(dentry, inode);
55205 +
55206 d_add(dentry, inode);
55207
55208 out:
55209 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55210 struct inode *inode = file_inode(filp);
55211 struct ctl_table_header *head = grab_header(inode);
55212 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55213 + int op = write ? MAY_WRITE : MAY_READ;
55214 ssize_t error;
55215 size_t res;
55216
55217 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55218 * and won't be until we finish.
55219 */
55220 error = -EPERM;
55221 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55222 + if (sysctl_perm(head, table, op))
55223 goto out;
55224
55225 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55226 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55227 if (!table->proc_handler)
55228 goto out;
55229
55230 +#ifdef CONFIG_GRKERNSEC
55231 + error = -EPERM;
55232 + if (gr_handle_chroot_sysctl(op))
55233 + goto out;
55234 + dget(filp->f_path.dentry);
55235 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55236 + dput(filp->f_path.dentry);
55237 + goto out;
55238 + }
55239 + dput(filp->f_path.dentry);
55240 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55241 + goto out;
55242 + if (write && !capable(CAP_SYS_ADMIN))
55243 + goto out;
55244 +#endif
55245 +
55246 /* careful: calling conventions are nasty here */
55247 res = count;
55248 error = table->proc_handler(table, write, buf, &res, ppos);
55249 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55250 return -ENOMEM;
55251 } else {
55252 d_set_d_op(child, &proc_sys_dentry_operations);
55253 +
55254 + gr_handle_proc_create(child, inode);
55255 +
55256 d_add(child, inode);
55257 }
55258 } else {
55259 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55260 if ((*pos)++ < file->f_pos)
55261 return 0;
55262
55263 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55264 + return 0;
55265 +
55266 if (unlikely(S_ISLNK(table->mode)))
55267 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55268 else
55269 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55270 if (IS_ERR(head))
55271 return PTR_ERR(head);
55272
55273 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55274 + return -ENOENT;
55275 +
55276 generic_fillattr(inode, stat);
55277 if (table)
55278 stat->mode = (stat->mode & S_IFMT) | table->mode;
55279 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55280 .llseek = generic_file_llseek,
55281 };
55282
55283 -static const struct inode_operations proc_sys_inode_operations = {
55284 +const struct inode_operations proc_sys_inode_operations = {
55285 .permission = proc_sys_permission,
55286 .setattr = proc_sys_setattr,
55287 .getattr = proc_sys_getattr,
55288 };
55289
55290 -static const struct inode_operations proc_sys_dir_operations = {
55291 +const struct inode_operations proc_sys_dir_operations = {
55292 .lookup = proc_sys_lookup,
55293 .permission = proc_sys_permission,
55294 .setattr = proc_sys_setattr,
55295 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55296 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55297 const char *name, int namelen)
55298 {
55299 - struct ctl_table *table;
55300 + ctl_table_no_const *table;
55301 struct ctl_dir *new;
55302 struct ctl_node *node;
55303 char *new_name;
55304 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55305 return NULL;
55306
55307 node = (struct ctl_node *)(new + 1);
55308 - table = (struct ctl_table *)(node + 1);
55309 + table = (ctl_table_no_const *)(node + 1);
55310 new_name = (char *)(table + 2);
55311 memcpy(new_name, name, namelen);
55312 new_name[namelen] = '\0';
55313 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55314 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55315 struct ctl_table_root *link_root)
55316 {
55317 - struct ctl_table *link_table, *entry, *link;
55318 + ctl_table_no_const *link_table, *link;
55319 + struct ctl_table *entry;
55320 struct ctl_table_header *links;
55321 struct ctl_node *node;
55322 char *link_name;
55323 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55324 return NULL;
55325
55326 node = (struct ctl_node *)(links + 1);
55327 - link_table = (struct ctl_table *)(node + nr_entries);
55328 + link_table = (ctl_table_no_const *)(node + nr_entries);
55329 link_name = (char *)&link_table[nr_entries + 1];
55330
55331 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55332 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55333 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55334 struct ctl_table *table)
55335 {
55336 - struct ctl_table *ctl_table_arg = NULL;
55337 - struct ctl_table *entry, *files;
55338 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55339 + struct ctl_table *entry;
55340 int nr_files = 0;
55341 int nr_dirs = 0;
55342 int err = -ENOMEM;
55343 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55344 nr_files++;
55345 }
55346
55347 - files = table;
55348 /* If there are mixed files and directories we need a new table */
55349 if (nr_dirs && nr_files) {
55350 - struct ctl_table *new;
55351 + ctl_table_no_const *new;
55352 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55353 GFP_KERNEL);
55354 if (!files)
55355 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55356 /* Register everything except a directory full of subdirectories */
55357 if (nr_files || !nr_dirs) {
55358 struct ctl_table_header *header;
55359 - header = __register_sysctl_table(set, path, files);
55360 + header = __register_sysctl_table(set, path, files ? files : table);
55361 if (!header) {
55362 kfree(ctl_table_arg);
55363 goto out;
55364 diff --git a/fs/proc/root.c b/fs/proc/root.c
55365 index 9c7fab1..ed1c8e0 100644
55366 --- a/fs/proc/root.c
55367 +++ b/fs/proc/root.c
55368 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
55369 #ifdef CONFIG_PROC_DEVICETREE
55370 proc_device_tree_init();
55371 #endif
55372 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55373 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55374 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55375 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55376 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55377 +#endif
55378 +#else
55379 proc_mkdir("bus", NULL);
55380 +#endif
55381 proc_sys_init();
55382 }
55383
55384 diff --git a/fs/proc/self.c b/fs/proc/self.c
55385 index aa5cc3b..c91a5d0 100644
55386 --- a/fs/proc/self.c
55387 +++ b/fs/proc/self.c
55388 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55389 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55390 void *cookie)
55391 {
55392 - char *s = nd_get_link(nd);
55393 + const char *s = nd_get_link(nd);
55394 if (!IS_ERR(s))
55395 kfree(s);
55396 }
55397 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55398 index 3e636d8..83e3b71 100644
55399 --- a/fs/proc/task_mmu.c
55400 +++ b/fs/proc/task_mmu.c
55401 @@ -11,12 +11,19 @@
55402 #include <linux/rmap.h>
55403 #include <linux/swap.h>
55404 #include <linux/swapops.h>
55405 +#include <linux/grsecurity.h>
55406
55407 #include <asm/elf.h>
55408 #include <asm/uaccess.h>
55409 #include <asm/tlbflush.h>
55410 #include "internal.h"
55411
55412 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55413 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55414 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55415 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55416 +#endif
55417 +
55418 void task_mem(struct seq_file *m, struct mm_struct *mm)
55419 {
55420 unsigned long data, text, lib, swap;
55421 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55422 "VmExe:\t%8lu kB\n"
55423 "VmLib:\t%8lu kB\n"
55424 "VmPTE:\t%8lu kB\n"
55425 - "VmSwap:\t%8lu kB\n",
55426 - hiwater_vm << (PAGE_SHIFT-10),
55427 + "VmSwap:\t%8lu kB\n"
55428 +
55429 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55430 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
55431 +#endif
55432 +
55433 + ,hiwater_vm << (PAGE_SHIFT-10),
55434 total_vm << (PAGE_SHIFT-10),
55435 mm->locked_vm << (PAGE_SHIFT-10),
55436 mm->pinned_vm << (PAGE_SHIFT-10),
55437 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55438 data << (PAGE_SHIFT-10),
55439 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
55440 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
55441 - swap << (PAGE_SHIFT-10));
55442 + swap << (PAGE_SHIFT-10)
55443 +
55444 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55445 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55446 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
55447 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
55448 +#else
55449 + , mm->context.user_cs_base
55450 + , mm->context.user_cs_limit
55451 +#endif
55452 +#endif
55453 +
55454 + );
55455 }
55456
55457 unsigned long task_vsize(struct mm_struct *mm)
55458 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55459 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
55460 }
55461
55462 - /* We don't show the stack guard page in /proc/maps */
55463 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55464 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
55465 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
55466 +#else
55467 start = vma->vm_start;
55468 - if (stack_guard_page_start(vma, start))
55469 - start += PAGE_SIZE;
55470 end = vma->vm_end;
55471 - if (stack_guard_page_end(vma, end))
55472 - end -= PAGE_SIZE;
55473 +#endif
55474
55475 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
55476 start,
55477 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55478 flags & VM_WRITE ? 'w' : '-',
55479 flags & VM_EXEC ? 'x' : '-',
55480 flags & VM_MAYSHARE ? 's' : 'p',
55481 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55482 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
55483 +#else
55484 pgoff,
55485 +#endif
55486 MAJOR(dev), MINOR(dev), ino, &len);
55487
55488 /*
55489 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55490 */
55491 if (file) {
55492 pad_len_spaces(m, len);
55493 - seq_path(m, &file->f_path, "\n");
55494 + seq_path(m, &file->f_path, "\n\\");
55495 goto done;
55496 }
55497
55498 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55499 * Thread stack in /proc/PID/task/TID/maps or
55500 * the main process stack.
55501 */
55502 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
55503 - vma->vm_end >= mm->start_stack)) {
55504 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
55505 + (vma->vm_start <= mm->start_stack &&
55506 + vma->vm_end >= mm->start_stack)) {
55507 name = "[stack]";
55508 } else {
55509 /* Thread stack in /proc/PID/maps */
55510 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
55511 struct proc_maps_private *priv = m->private;
55512 struct task_struct *task = priv->task;
55513
55514 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55515 + if (current->exec_id != m->exec_id) {
55516 + gr_log_badprocpid("maps");
55517 + return 0;
55518 + }
55519 +#endif
55520 +
55521 show_map_vma(m, vma, is_pid);
55522
55523 if (m->count < m->size) /* vma is copied successfully */
55524 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55525 .private = &mss,
55526 };
55527
55528 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55529 + if (current->exec_id != m->exec_id) {
55530 + gr_log_badprocpid("smaps");
55531 + return 0;
55532 + }
55533 +#endif
55534 memset(&mss, 0, sizeof mss);
55535 - mss.vma = vma;
55536 - /* mmap_sem is held in m_start */
55537 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55538 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55539 -
55540 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55541 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
55542 +#endif
55543 + mss.vma = vma;
55544 + /* mmap_sem is held in m_start */
55545 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55546 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55547 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55548 + }
55549 +#endif
55550 show_map_vma(m, vma, is_pid);
55551
55552 seq_printf(m,
55553 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55554 "KernelPageSize: %8lu kB\n"
55555 "MMUPageSize: %8lu kB\n"
55556 "Locked: %8lu kB\n",
55557 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55558 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
55559 +#else
55560 (vma->vm_end - vma->vm_start) >> 10,
55561 +#endif
55562 mss.resident >> 10,
55563 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
55564 mss.shared_clean >> 10,
55565 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55566 int n;
55567 char buffer[50];
55568
55569 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55570 + if (current->exec_id != m->exec_id) {
55571 + gr_log_badprocpid("numa_maps");
55572 + return 0;
55573 + }
55574 +#endif
55575 +
55576 if (!mm)
55577 return 0;
55578
55579 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55580 mpol_to_str(buffer, sizeof(buffer), pol);
55581 mpol_cond_put(pol);
55582
55583 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55584 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
55585 +#else
55586 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
55587 +#endif
55588
55589 if (file) {
55590 seq_printf(m, " file=");
55591 - seq_path(m, &file->f_path, "\n\t= ");
55592 + seq_path(m, &file->f_path, "\n\t\\= ");
55593 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
55594 seq_printf(m, " heap");
55595 } else {
55596 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
55597 index 56123a6..5a2f6ec 100644
55598 --- a/fs/proc/task_nommu.c
55599 +++ b/fs/proc/task_nommu.c
55600 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55601 else
55602 bytes += kobjsize(mm);
55603
55604 - if (current->fs && current->fs->users > 1)
55605 + if (current->fs && atomic_read(&current->fs->users) > 1)
55606 sbytes += kobjsize(current->fs);
55607 else
55608 bytes += kobjsize(current->fs);
55609 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
55610
55611 if (file) {
55612 pad_len_spaces(m, len);
55613 - seq_path(m, &file->f_path, "");
55614 + seq_path(m, &file->f_path, "\n\\");
55615 } else if (mm) {
55616 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
55617
55618 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
55619 index b870f74..e9048df 100644
55620 --- a/fs/proc/vmcore.c
55621 +++ b/fs/proc/vmcore.c
55622 @@ -98,9 +98,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
55623 nr_bytes = count;
55624
55625 /* If pfn is not ram, return zeros for sparse dump files */
55626 - if (pfn_is_ram(pfn) == 0)
55627 - memset(buf, 0, nr_bytes);
55628 - else {
55629 + if (pfn_is_ram(pfn) == 0) {
55630 + if (userbuf) {
55631 + if (clear_user((char __force_user *)buf, nr_bytes))
55632 + return -EFAULT;
55633 + } else
55634 + memset(buf, 0, nr_bytes);
55635 + } else {
55636 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
55637 offset, userbuf);
55638 if (tmp < 0)
55639 @@ -185,7 +189,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
55640 if (tsz > nr_bytes)
55641 tsz = nr_bytes;
55642
55643 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
55644 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
55645 if (tmp < 0)
55646 return tmp;
55647 buflen -= tsz;
55648 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
55649 index b00fcc9..e0c6381 100644
55650 --- a/fs/qnx6/qnx6.h
55651 +++ b/fs/qnx6/qnx6.h
55652 @@ -74,7 +74,7 @@ enum {
55653 BYTESEX_BE,
55654 };
55655
55656 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55657 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55658 {
55659 if (sbi->s_bytesex == BYTESEX_LE)
55660 return le64_to_cpu((__force __le64)n);
55661 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
55662 return (__force __fs64)cpu_to_be64(n);
55663 }
55664
55665 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55666 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55667 {
55668 if (sbi->s_bytesex == BYTESEX_LE)
55669 return le32_to_cpu((__force __le32)n);
55670 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
55671 index 16e8abb..2dcf914 100644
55672 --- a/fs/quota/netlink.c
55673 +++ b/fs/quota/netlink.c
55674 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
55675 void quota_send_warning(struct kqid qid, dev_t dev,
55676 const char warntype)
55677 {
55678 - static atomic_t seq;
55679 + static atomic_unchecked_t seq;
55680 struct sk_buff *skb;
55681 void *msg_head;
55682 int ret;
55683 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
55684 "VFS: Not enough memory to send quota warning.\n");
55685 return;
55686 }
55687 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
55688 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
55689 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
55690 if (!msg_head) {
55691 printk(KERN_ERR
55692 diff --git a/fs/read_write.c b/fs/read_write.c
55693 index e6ddc8d..9155227 100644
55694 --- a/fs/read_write.c
55695 +++ b/fs/read_write.c
55696 @@ -429,7 +429,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
55697
55698 old_fs = get_fs();
55699 set_fs(get_ds());
55700 - p = (__force const char __user *)buf;
55701 + p = (const char __force_user *)buf;
55702 if (count > MAX_RW_COUNT)
55703 count = MAX_RW_COUNT;
55704 if (file->f_op->write)
55705 diff --git a/fs/readdir.c b/fs/readdir.c
55706 index fee38e0..12fdf47 100644
55707 --- a/fs/readdir.c
55708 +++ b/fs/readdir.c
55709 @@ -17,6 +17,7 @@
55710 #include <linux/security.h>
55711 #include <linux/syscalls.h>
55712 #include <linux/unistd.h>
55713 +#include <linux/namei.h>
55714
55715 #include <asm/uaccess.h>
55716
55717 @@ -67,6 +68,7 @@ struct old_linux_dirent {
55718
55719 struct readdir_callback {
55720 struct old_linux_dirent __user * dirent;
55721 + struct file * file;
55722 int result;
55723 };
55724
55725 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
55726 buf->result = -EOVERFLOW;
55727 return -EOVERFLOW;
55728 }
55729 +
55730 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55731 + return 0;
55732 +
55733 buf->result++;
55734 dirent = buf->dirent;
55735 if (!access_ok(VERIFY_WRITE, dirent,
55736 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
55737
55738 buf.result = 0;
55739 buf.dirent = dirent;
55740 + buf.file = f.file;
55741
55742 error = vfs_readdir(f.file, fillonedir, &buf);
55743 if (buf.result)
55744 @@ -139,6 +146,7 @@ struct linux_dirent {
55745 struct getdents_callback {
55746 struct linux_dirent __user * current_dir;
55747 struct linux_dirent __user * previous;
55748 + struct file * file;
55749 int count;
55750 int error;
55751 };
55752 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
55753 buf->error = -EOVERFLOW;
55754 return -EOVERFLOW;
55755 }
55756 +
55757 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55758 + return 0;
55759 +
55760 dirent = buf->previous;
55761 if (dirent) {
55762 if (__put_user(offset, &dirent->d_off))
55763 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55764 buf.previous = NULL;
55765 buf.count = count;
55766 buf.error = 0;
55767 + buf.file = f.file;
55768
55769 error = vfs_readdir(f.file, filldir, &buf);
55770 if (error >= 0)
55771 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55772 struct getdents_callback64 {
55773 struct linux_dirent64 __user * current_dir;
55774 struct linux_dirent64 __user * previous;
55775 + struct file *file;
55776 int count;
55777 int error;
55778 };
55779 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
55780 buf->error = -EINVAL; /* only used if we fail.. */
55781 if (reclen > buf->count)
55782 return -EINVAL;
55783 +
55784 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55785 + return 0;
55786 +
55787 dirent = buf->previous;
55788 if (dirent) {
55789 if (__put_user(offset, &dirent->d_off))
55790 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55791
55792 buf.current_dir = dirent;
55793 buf.previous = NULL;
55794 + buf.file = f.file;
55795 buf.count = count;
55796 buf.error = 0;
55797
55798 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55799 error = buf.error;
55800 lastdirent = buf.previous;
55801 if (lastdirent) {
55802 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
55803 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
55804 if (__put_user(d_off, &lastdirent->d_off))
55805 error = -EFAULT;
55806 else
55807 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
55808 index 2b7882b..1c5ef48 100644
55809 --- a/fs/reiserfs/do_balan.c
55810 +++ b/fs/reiserfs/do_balan.c
55811 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
55812 return;
55813 }
55814
55815 - atomic_inc(&(fs_generation(tb->tb_sb)));
55816 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
55817 do_balance_starts(tb);
55818
55819 /* balance leaf returns 0 except if combining L R and S into
55820 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
55821 index 9cc0740a..46bf953 100644
55822 --- a/fs/reiserfs/procfs.c
55823 +++ b/fs/reiserfs/procfs.c
55824 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
55825 "SMALL_TAILS " : "NO_TAILS ",
55826 replay_only(sb) ? "REPLAY_ONLY " : "",
55827 convert_reiserfs(sb) ? "CONV " : "",
55828 - atomic_read(&r->s_generation_counter),
55829 + atomic_read_unchecked(&r->s_generation_counter),
55830 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
55831 SF(s_do_balance), SF(s_unneeded_left_neighbor),
55832 SF(s_good_search_by_key_reada), SF(s_bmaps),
55833 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
55834 index 157e474..65a6114 100644
55835 --- a/fs/reiserfs/reiserfs.h
55836 +++ b/fs/reiserfs/reiserfs.h
55837 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
55838 /* Comment? -Hans */
55839 wait_queue_head_t s_wait;
55840 /* To be obsoleted soon by per buffer seals.. -Hans */
55841 - atomic_t s_generation_counter; // increased by one every time the
55842 + atomic_unchecked_t s_generation_counter; // increased by one every time the
55843 // tree gets re-balanced
55844 unsigned long s_properties; /* File system properties. Currently holds
55845 on-disk FS format */
55846 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
55847 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
55848
55849 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
55850 -#define get_generation(s) atomic_read (&fs_generation(s))
55851 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
55852 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
55853 #define __fs_changed(gen,s) (gen != get_generation (s))
55854 #define fs_changed(gen,s) \
55855 diff --git a/fs/select.c b/fs/select.c
55856 index 8c1c96c..a0f9b6d 100644
55857 --- a/fs/select.c
55858 +++ b/fs/select.c
55859 @@ -20,6 +20,7 @@
55860 #include <linux/export.h>
55861 #include <linux/slab.h>
55862 #include <linux/poll.h>
55863 +#include <linux/security.h>
55864 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
55865 #include <linux/file.h>
55866 #include <linux/fdtable.h>
55867 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
55868 struct poll_list *walk = head;
55869 unsigned long todo = nfds;
55870
55871 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
55872 if (nfds > rlimit(RLIMIT_NOFILE))
55873 return -EINVAL;
55874
55875 diff --git a/fs/seq_file.c b/fs/seq_file.c
55876 index 38bb59f..a304f9d 100644
55877 --- a/fs/seq_file.c
55878 +++ b/fs/seq_file.c
55879 @@ -10,6 +10,7 @@
55880 #include <linux/seq_file.h>
55881 #include <linux/slab.h>
55882 #include <linux/cred.h>
55883 +#include <linux/sched.h>
55884
55885 #include <asm/uaccess.h>
55886 #include <asm/page.h>
55887 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
55888 #ifdef CONFIG_USER_NS
55889 p->user_ns = file->f_cred->user_ns;
55890 #endif
55891 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55892 + p->exec_id = current->exec_id;
55893 +#endif
55894
55895 /*
55896 * Wrappers around seq_open(e.g. swaps_open) need to be
55897 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55898 return 0;
55899 }
55900 if (!m->buf) {
55901 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55902 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55903 if (!m->buf)
55904 return -ENOMEM;
55905 }
55906 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55907 Eoverflow:
55908 m->op->stop(m, p);
55909 kfree(m->buf);
55910 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55911 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55912 return !m->buf ? -ENOMEM : -EAGAIN;
55913 }
55914
55915 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55916
55917 /* grab buffer if we didn't have one */
55918 if (!m->buf) {
55919 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55920 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55921 if (!m->buf)
55922 goto Enomem;
55923 }
55924 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55925 goto Fill;
55926 m->op->stop(m, p);
55927 kfree(m->buf);
55928 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55929 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55930 if (!m->buf)
55931 goto Enomem;
55932 m->count = 0;
55933 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
55934 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
55935 void *data)
55936 {
55937 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
55938 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
55939 int res = -ENOMEM;
55940
55941 if (op) {
55942 diff --git a/fs/splice.c b/fs/splice.c
55943 index 29e394e..b13c247 100644
55944 --- a/fs/splice.c
55945 +++ b/fs/splice.c
55946 @@ -195,7 +195,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55947 pipe_lock(pipe);
55948
55949 for (;;) {
55950 - if (!pipe->readers) {
55951 + if (!atomic_read(&pipe->readers)) {
55952 send_sig(SIGPIPE, current, 0);
55953 if (!ret)
55954 ret = -EPIPE;
55955 @@ -249,9 +249,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55956 do_wakeup = 0;
55957 }
55958
55959 - pipe->waiting_writers++;
55960 + atomic_inc(&pipe->waiting_writers);
55961 pipe_wait(pipe);
55962 - pipe->waiting_writers--;
55963 + atomic_dec(&pipe->waiting_writers);
55964 }
55965
55966 pipe_unlock(pipe);
55967 @@ -564,7 +564,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
55968 old_fs = get_fs();
55969 set_fs(get_ds());
55970 /* The cast to a user pointer is valid due to the set_fs() */
55971 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
55972 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
55973 set_fs(old_fs);
55974
55975 return res;
55976 @@ -579,7 +579,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
55977 old_fs = get_fs();
55978 set_fs(get_ds());
55979 /* The cast to a user pointer is valid due to the set_fs() */
55980 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
55981 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
55982 set_fs(old_fs);
55983
55984 return res;
55985 @@ -632,7 +632,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
55986 goto err;
55987
55988 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
55989 - vec[i].iov_base = (void __user *) page_address(page);
55990 + vec[i].iov_base = (void __force_user *) page_address(page);
55991 vec[i].iov_len = this_len;
55992 spd.pages[i] = page;
55993 spd.nr_pages++;
55994 @@ -853,10 +853,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
55995 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
55996 {
55997 while (!pipe->nrbufs) {
55998 - if (!pipe->writers)
55999 + if (!atomic_read(&pipe->writers))
56000 return 0;
56001
56002 - if (!pipe->waiting_writers && sd->num_spliced)
56003 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56004 return 0;
56005
56006 if (sd->flags & SPLICE_F_NONBLOCK)
56007 @@ -1192,7 +1192,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56008 * out of the pipe right after the splice_to_pipe(). So set
56009 * PIPE_READERS appropriately.
56010 */
56011 - pipe->readers = 1;
56012 + atomic_set(&pipe->readers, 1);
56013
56014 current->splice_pipe = pipe;
56015 }
56016 @@ -1741,9 +1741,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56017 ret = -ERESTARTSYS;
56018 break;
56019 }
56020 - if (!pipe->writers)
56021 + if (!atomic_read(&pipe->writers))
56022 break;
56023 - if (!pipe->waiting_writers) {
56024 + if (!atomic_read(&pipe->waiting_writers)) {
56025 if (flags & SPLICE_F_NONBLOCK) {
56026 ret = -EAGAIN;
56027 break;
56028 @@ -1775,7 +1775,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56029 pipe_lock(pipe);
56030
56031 while (pipe->nrbufs >= pipe->buffers) {
56032 - if (!pipe->readers) {
56033 + if (!atomic_read(&pipe->readers)) {
56034 send_sig(SIGPIPE, current, 0);
56035 ret = -EPIPE;
56036 break;
56037 @@ -1788,9 +1788,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56038 ret = -ERESTARTSYS;
56039 break;
56040 }
56041 - pipe->waiting_writers++;
56042 + atomic_inc(&pipe->waiting_writers);
56043 pipe_wait(pipe);
56044 - pipe->waiting_writers--;
56045 + atomic_dec(&pipe->waiting_writers);
56046 }
56047
56048 pipe_unlock(pipe);
56049 @@ -1826,14 +1826,14 @@ retry:
56050 pipe_double_lock(ipipe, opipe);
56051
56052 do {
56053 - if (!opipe->readers) {
56054 + if (!atomic_read(&opipe->readers)) {
56055 send_sig(SIGPIPE, current, 0);
56056 if (!ret)
56057 ret = -EPIPE;
56058 break;
56059 }
56060
56061 - if (!ipipe->nrbufs && !ipipe->writers)
56062 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56063 break;
56064
56065 /*
56066 @@ -1930,7 +1930,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56067 pipe_double_lock(ipipe, opipe);
56068
56069 do {
56070 - if (!opipe->readers) {
56071 + if (!atomic_read(&opipe->readers)) {
56072 send_sig(SIGPIPE, current, 0);
56073 if (!ret)
56074 ret = -EPIPE;
56075 @@ -1975,7 +1975,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56076 * return EAGAIN if we have the potential of some data in the
56077 * future, otherwise just return 0
56078 */
56079 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56080 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56081 ret = -EAGAIN;
56082
56083 pipe_unlock(ipipe);
56084 diff --git a/fs/stat.c b/fs/stat.c
56085 index 04ce1ac..a13dd1e 100644
56086 --- a/fs/stat.c
56087 +++ b/fs/stat.c
56088 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56089 stat->gid = inode->i_gid;
56090 stat->rdev = inode->i_rdev;
56091 stat->size = i_size_read(inode);
56092 - stat->atime = inode->i_atime;
56093 - stat->mtime = inode->i_mtime;
56094 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56095 + stat->atime = inode->i_ctime;
56096 + stat->mtime = inode->i_ctime;
56097 + } else {
56098 + stat->atime = inode->i_atime;
56099 + stat->mtime = inode->i_mtime;
56100 + }
56101 stat->ctime = inode->i_ctime;
56102 stat->blksize = (1 << inode->i_blkbits);
56103 stat->blocks = inode->i_blocks;
56104 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
56105 if (retval)
56106 return retval;
56107
56108 - if (inode->i_op->getattr)
56109 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
56110 + if (inode->i_op->getattr) {
56111 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
56112 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56113 + stat->atime = stat->ctime;
56114 + stat->mtime = stat->ctime;
56115 + }
56116 + return retval;
56117 + }
56118
56119 generic_fillattr(inode, stat);
56120 return 0;
56121 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56122 index 15c68f9..36a8b3e 100644
56123 --- a/fs/sysfs/bin.c
56124 +++ b/fs/sysfs/bin.c
56125 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56126 return ret;
56127 }
56128
56129 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56130 - void *buf, int len, int write)
56131 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56132 + void *buf, size_t len, int write)
56133 {
56134 struct file *file = vma->vm_file;
56135 struct bin_buffer *bb = file->private_data;
56136 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56137 - int ret;
56138 + ssize_t ret;
56139
56140 if (!bb->vm_ops)
56141 return -EINVAL;
56142 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56143 index 6f31590..3c87c8a 100644
56144 --- a/fs/sysfs/dir.c
56145 +++ b/fs/sysfs/dir.c
56146 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56147 *
56148 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56149 */
56150 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56151 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56152 {
56153 unsigned long hash = init_name_hash();
56154 unsigned int len = strlen(name);
56155 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56156 struct sysfs_dirent *sd;
56157 int rc;
56158
56159 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56160 + const char *parent_name = parent_sd->s_name;
56161 +
56162 + mode = S_IFDIR | S_IRWXU;
56163 +
56164 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56165 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56166 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56167 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56168 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56169 +#endif
56170 +
56171 /* allocate */
56172 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56173 if (!sd)
56174 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56175 index 602f56d..6853db8 100644
56176 --- a/fs/sysfs/file.c
56177 +++ b/fs/sysfs/file.c
56178 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56179
56180 struct sysfs_open_dirent {
56181 atomic_t refcnt;
56182 - atomic_t event;
56183 + atomic_unchecked_t event;
56184 wait_queue_head_t poll;
56185 struct list_head buffers; /* goes through sysfs_buffer.list */
56186 };
56187 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56188 if (!sysfs_get_active(attr_sd))
56189 return -ENODEV;
56190
56191 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56192 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56193 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56194
56195 sysfs_put_active(attr_sd);
56196 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56197 return -ENOMEM;
56198
56199 atomic_set(&new_od->refcnt, 0);
56200 - atomic_set(&new_od->event, 1);
56201 + atomic_set_unchecked(&new_od->event, 1);
56202 init_waitqueue_head(&new_od->poll);
56203 INIT_LIST_HEAD(&new_od->buffers);
56204 goto retry;
56205 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56206
56207 sysfs_put_active(attr_sd);
56208
56209 - if (buffer->event != atomic_read(&od->event))
56210 + if (buffer->event != atomic_read_unchecked(&od->event))
56211 goto trigger;
56212
56213 return DEFAULT_POLLMASK;
56214 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56215
56216 od = sd->s_attr.open;
56217 if (od) {
56218 - atomic_inc(&od->event);
56219 + atomic_inc_unchecked(&od->event);
56220 wake_up_interruptible(&od->poll);
56221 }
56222
56223 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56224 index 8c940df..25b733e 100644
56225 --- a/fs/sysfs/symlink.c
56226 +++ b/fs/sysfs/symlink.c
56227 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56228
56229 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56230 {
56231 - char *page = nd_get_link(nd);
56232 + const char *page = nd_get_link(nd);
56233 if (!IS_ERR(page))
56234 free_page((unsigned long)page);
56235 }
56236 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56237 index 69d4889..a810bd4 100644
56238 --- a/fs/sysv/sysv.h
56239 +++ b/fs/sysv/sysv.h
56240 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56241 #endif
56242 }
56243
56244 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56245 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56246 {
56247 if (sbi->s_bytesex == BYTESEX_PDP)
56248 return PDP_swab((__force __u32)n);
56249 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56250 index e18b988..f1d4ad0f 100644
56251 --- a/fs/ubifs/io.c
56252 +++ b/fs/ubifs/io.c
56253 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56254 return err;
56255 }
56256
56257 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56258 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56259 {
56260 int err;
56261
56262 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56263 index c175b4d..8f36a16 100644
56264 --- a/fs/udf/misc.c
56265 +++ b/fs/udf/misc.c
56266 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56267
56268 u8 udf_tag_checksum(const struct tag *t)
56269 {
56270 - u8 *data = (u8 *)t;
56271 + const u8 *data = (const u8 *)t;
56272 u8 checksum = 0;
56273 int i;
56274 for (i = 0; i < sizeof(struct tag); ++i)
56275 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56276 index 8d974c4..b82f6ec 100644
56277 --- a/fs/ufs/swab.h
56278 +++ b/fs/ufs/swab.h
56279 @@ -22,7 +22,7 @@ enum {
56280 BYTESEX_BE
56281 };
56282
56283 -static inline u64
56284 +static inline u64 __intentional_overflow(-1)
56285 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56286 {
56287 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56288 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56289 return (__force __fs64)cpu_to_be64(n);
56290 }
56291
56292 -static inline u32
56293 +static inline u32 __intentional_overflow(-1)
56294 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56295 {
56296 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56297 diff --git a/fs/utimes.c b/fs/utimes.c
56298 index f4fb7ec..3fe03c0 100644
56299 --- a/fs/utimes.c
56300 +++ b/fs/utimes.c
56301 @@ -1,6 +1,7 @@
56302 #include <linux/compiler.h>
56303 #include <linux/file.h>
56304 #include <linux/fs.h>
56305 +#include <linux/security.h>
56306 #include <linux/linkage.h>
56307 #include <linux/mount.h>
56308 #include <linux/namei.h>
56309 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56310 goto mnt_drop_write_and_out;
56311 }
56312 }
56313 +
56314 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56315 + error = -EACCES;
56316 + goto mnt_drop_write_and_out;
56317 + }
56318 +
56319 mutex_lock(&inode->i_mutex);
56320 error = notify_change(path->dentry, &newattrs);
56321 mutex_unlock(&inode->i_mutex);
56322 diff --git a/fs/xattr.c b/fs/xattr.c
56323 index 3377dff..4d074d9 100644
56324 --- a/fs/xattr.c
56325 +++ b/fs/xattr.c
56326 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
56327 return rc;
56328 }
56329
56330 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
56331 +ssize_t
56332 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
56333 +{
56334 + struct inode *inode = dentry->d_inode;
56335 + ssize_t error;
56336 +
56337 + error = inode_permission(inode, MAY_EXEC);
56338 + if (error)
56339 + return error;
56340 +
56341 + if (inode->i_op->getxattr)
56342 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
56343 + else
56344 + error = -EOPNOTSUPP;
56345 +
56346 + return error;
56347 +}
56348 +EXPORT_SYMBOL(pax_getxattr);
56349 +#endif
56350 +
56351 ssize_t
56352 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
56353 {
56354 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56355 * Extended attribute SET operations
56356 */
56357 static long
56358 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56359 +setxattr(struct path *path, const char __user *name, const void __user *value,
56360 size_t size, int flags)
56361 {
56362 int error;
56363 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56364 posix_acl_fix_xattr_from_user(kvalue, size);
56365 }
56366
56367 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56368 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56369 + error = -EACCES;
56370 + goto out;
56371 + }
56372 +
56373 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56374 out:
56375 if (vvalue)
56376 vfree(vvalue);
56377 @@ -377,7 +403,7 @@ retry:
56378 return error;
56379 error = mnt_want_write(path.mnt);
56380 if (!error) {
56381 - error = setxattr(path.dentry, name, value, size, flags);
56382 + error = setxattr(&path, name, value, size, flags);
56383 mnt_drop_write(path.mnt);
56384 }
56385 path_put(&path);
56386 @@ -401,7 +427,7 @@ retry:
56387 return error;
56388 error = mnt_want_write(path.mnt);
56389 if (!error) {
56390 - error = setxattr(path.dentry, name, value, size, flags);
56391 + error = setxattr(&path, name, value, size, flags);
56392 mnt_drop_write(path.mnt);
56393 }
56394 path_put(&path);
56395 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56396 const void __user *,value, size_t, size, int, flags)
56397 {
56398 struct fd f = fdget(fd);
56399 - struct dentry *dentry;
56400 int error = -EBADF;
56401
56402 if (!f.file)
56403 return error;
56404 - dentry = f.file->f_path.dentry;
56405 - audit_inode(NULL, dentry, 0);
56406 + audit_inode(NULL, f.file->f_path.dentry, 0);
56407 error = mnt_want_write_file(f.file);
56408 if (!error) {
56409 - error = setxattr(dentry, name, value, size, flags);
56410 + error = setxattr(&f.file->f_path, name, value, size, flags);
56411 mnt_drop_write_file(f.file);
56412 }
56413 fdput(f);
56414 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56415 index 9fbea87..6b19972 100644
56416 --- a/fs/xattr_acl.c
56417 +++ b/fs/xattr_acl.c
56418 @@ -76,8 +76,8 @@ struct posix_acl *
56419 posix_acl_from_xattr(struct user_namespace *user_ns,
56420 const void *value, size_t size)
56421 {
56422 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56423 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56424 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56425 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56426 int count;
56427 struct posix_acl *acl;
56428 struct posix_acl_entry *acl_e;
56429 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56430 index b44af92..06073da 100644
56431 --- a/fs/xfs/xfs_bmap.c
56432 +++ b/fs/xfs/xfs_bmap.c
56433 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56434 int nmap,
56435 int ret_nmap);
56436 #else
56437 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56438 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56439 #endif /* DEBUG */
56440
56441 STATIC int
56442 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56443 index 1b9fc3e..e1bdde0 100644
56444 --- a/fs/xfs/xfs_dir2_sf.c
56445 +++ b/fs/xfs/xfs_dir2_sf.c
56446 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56447 }
56448
56449 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56450 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56451 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56452 + char name[sfep->namelen];
56453 + memcpy(name, sfep->name, sfep->namelen);
56454 + if (filldir(dirent, name, sfep->namelen,
56455 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56456 + *offset = off & 0x7fffffff;
56457 + return 0;
56458 + }
56459 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56460 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56461 *offset = off & 0x7fffffff;
56462 return 0;
56463 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56464 index d681e34..2a3f5ab 100644
56465 --- a/fs/xfs/xfs_ioctl.c
56466 +++ b/fs/xfs/xfs_ioctl.c
56467 @@ -127,7 +127,7 @@ xfs_find_handle(
56468 }
56469
56470 error = -EFAULT;
56471 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56472 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56473 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56474 goto out_put;
56475
56476 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56477 index d82efaa..0904a8e 100644
56478 --- a/fs/xfs/xfs_iops.c
56479 +++ b/fs/xfs/xfs_iops.c
56480 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56481 struct nameidata *nd,
56482 void *p)
56483 {
56484 - char *s = nd_get_link(nd);
56485 + const char *s = nd_get_link(nd);
56486
56487 if (!IS_ERR(s))
56488 kfree(s);
56489 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
56490 new file mode 100644
56491 index 0000000..7174794
56492 --- /dev/null
56493 +++ b/grsecurity/Kconfig
56494 @@ -0,0 +1,1031 @@
56495 +#
56496 +# grecurity configuration
56497 +#
56498 +menu "Memory Protections"
56499 +depends on GRKERNSEC
56500 +
56501 +config GRKERNSEC_KMEM
56502 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
56503 + default y if GRKERNSEC_CONFIG_AUTO
56504 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
56505 + help
56506 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
56507 + be written to or read from to modify or leak the contents of the running
56508 + kernel. /dev/port will also not be allowed to be opened and support
56509 + for /dev/cpu/*/msr will be removed. If you have module
56510 + support disabled, enabling this will close up five ways that are
56511 + currently used to insert malicious code into the running kernel.
56512 +
56513 + Even with all these features enabled, we still highly recommend that
56514 + you use the RBAC system, as it is still possible for an attacker to
56515 + modify the running kernel through privileged I/O granted by ioperm/iopl.
56516 +
56517 + If you are not using XFree86, you may be able to stop this additional
56518 + case by enabling the 'Disable privileged I/O' option. Though nothing
56519 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
56520 + but only to video memory, which is the only writing we allow in this
56521 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
56522 + not be allowed to mprotect it with PROT_WRITE later.
56523 + Enabling this feature will prevent the "cpupower" and "powertop" tools
56524 + from working.
56525 +
56526 + It is highly recommended that you say Y here if you meet all the
56527 + conditions above.
56528 +
56529 +config GRKERNSEC_VM86
56530 + bool "Restrict VM86 mode"
56531 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56532 + depends on X86_32
56533 +
56534 + help
56535 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
56536 + make use of a special execution mode on 32bit x86 processors called
56537 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
56538 + video cards and will still work with this option enabled. The purpose
56539 + of the option is to prevent exploitation of emulation errors in
56540 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
56541 + Nearly all users should be able to enable this option.
56542 +
56543 +config GRKERNSEC_IO
56544 + bool "Disable privileged I/O"
56545 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56546 + depends on X86
56547 + select RTC_CLASS
56548 + select RTC_INTF_DEV
56549 + select RTC_DRV_CMOS
56550 +
56551 + help
56552 + If you say Y here, all ioperm and iopl calls will return an error.
56553 + Ioperm and iopl can be used to modify the running kernel.
56554 + Unfortunately, some programs need this access to operate properly,
56555 + the most notable of which are XFree86 and hwclock. hwclock can be
56556 + remedied by having RTC support in the kernel, so real-time
56557 + clock support is enabled if this option is enabled, to ensure
56558 + that hwclock operates correctly. XFree86 still will not
56559 + operate correctly with this option enabled, so DO NOT CHOOSE Y
56560 + IF YOU USE XFree86. If you use XFree86 and you still want to
56561 + protect your kernel against modification, use the RBAC system.
56562 +
56563 +config GRKERNSEC_JIT_HARDEN
56564 + bool "Harden BPF JIT against spray attacks"
56565 + default y if GRKERNSEC_CONFIG_AUTO
56566 + depends on BPF_JIT
56567 + help
56568 + If you say Y here, the native code generated by the kernel's Berkeley
56569 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
56570 + attacks that attempt to fit attacker-beneficial instructions in
56571 + 32bit immediate fields of JIT-generated native instructions. The
56572 + attacker will generally aim to cause an unintended instruction sequence
56573 + of JIT-generated native code to execute by jumping into the middle of
56574 + a generated instruction. This feature effectively randomizes the 32bit
56575 + immediate constants present in the generated code to thwart such attacks.
56576 +
56577 + If you're using KERNEXEC, it's recommended that you enable this option
56578 + to supplement the hardening of the kernel.
56579 +
56580 +config GRKERNSEC_RAND_THREADSTACK
56581 + bool "Insert random gaps between thread stacks"
56582 + default y if GRKERNSEC_CONFIG_AUTO
56583 + depends on PAX_RANDMMAP && !PPC && BROKEN
56584 + help
56585 + If you say Y here, a random-sized gap will be enforced between allocated
56586 + thread stacks. Glibc's NPTL and other threading libraries that
56587 + pass MAP_STACK to the kernel for thread stack allocation are supported.
56588 + The implementation currently provides 8 bits of entropy for the gap.
56589 +
56590 + Many distributions do not compile threaded remote services with the
56591 + -fstack-check argument to GCC, causing the variable-sized stack-based
56592 + allocator, alloca(), to not probe the stack on allocation. This
56593 + permits an unbounded alloca() to skip over any guard page and potentially
56594 + modify another thread's stack reliably. An enforced random gap
56595 + reduces the reliability of such an attack and increases the chance
56596 + that such a read/write to another thread's stack instead lands in
56597 + an unmapped area, causing a crash and triggering grsecurity's
56598 + anti-bruteforcing logic.
56599 +
56600 +config GRKERNSEC_PROC_MEMMAP
56601 + bool "Harden ASLR against information leaks and entropy reduction"
56602 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
56603 + depends on PAX_NOEXEC || PAX_ASLR
56604 + help
56605 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
56606 + give no information about the addresses of its mappings if
56607 + PaX features that rely on random addresses are enabled on the task.
56608 + In addition to sanitizing this information and disabling other
56609 + dangerous sources of information, this option causes reads of sensitive
56610 + /proc/<pid> entries where the file descriptor was opened in a different
56611 + task than the one performing the read. Such attempts are logged.
56612 + This option also limits argv/env strings for suid/sgid binaries
56613 + to 512KB to prevent a complete exhaustion of the stack entropy provided
56614 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
56615 + binaries to prevent alternative mmap layouts from being abused.
56616 +
56617 + If you use PaX it is essential that you say Y here as it closes up
56618 + several holes that make full ASLR useless locally.
56619 +
56620 +config GRKERNSEC_BRUTE
56621 + bool "Deter exploit bruteforcing"
56622 + default y if GRKERNSEC_CONFIG_AUTO
56623 + help
56624 + If you say Y here, attempts to bruteforce exploits against forking
56625 + daemons such as apache or sshd, as well as against suid/sgid binaries
56626 + will be deterred. When a child of a forking daemon is killed by PaX
56627 + or crashes due to an illegal instruction or other suspicious signal,
56628 + the parent process will be delayed 30 seconds upon every subsequent
56629 + fork until the administrator is able to assess the situation and
56630 + restart the daemon.
56631 + In the suid/sgid case, the attempt is logged, the user has all their
56632 + processes terminated, and they are prevented from executing any further
56633 + processes for 15 minutes.
56634 + It is recommended that you also enable signal logging in the auditing
56635 + section so that logs are generated when a process triggers a suspicious
56636 + signal.
56637 + If the sysctl option is enabled, a sysctl option with name
56638 + "deter_bruteforce" is created.
56639 +
56640 +
56641 +config GRKERNSEC_MODHARDEN
56642 + bool "Harden module auto-loading"
56643 + default y if GRKERNSEC_CONFIG_AUTO
56644 + depends on MODULES
56645 + help
56646 + If you say Y here, module auto-loading in response to use of some
56647 + feature implemented by an unloaded module will be restricted to
56648 + root users. Enabling this option helps defend against attacks
56649 + by unprivileged users who abuse the auto-loading behavior to
56650 + cause a vulnerable module to load that is then exploited.
56651 +
56652 + If this option prevents a legitimate use of auto-loading for a
56653 + non-root user, the administrator can execute modprobe manually
56654 + with the exact name of the module mentioned in the alert log.
56655 + Alternatively, the administrator can add the module to the list
56656 + of modules loaded at boot by modifying init scripts.
56657 +
56658 + Modification of init scripts will most likely be needed on
56659 + Ubuntu servers with encrypted home directory support enabled,
56660 + as the first non-root user logging in will cause the ecb(aes),
56661 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
56662 +
56663 +config GRKERNSEC_HIDESYM
56664 + bool "Hide kernel symbols"
56665 + default y if GRKERNSEC_CONFIG_AUTO
56666 + select PAX_USERCOPY_SLABS
56667 + help
56668 + If you say Y here, getting information on loaded modules, and
56669 + displaying all kernel symbols through a syscall will be restricted
56670 + to users with CAP_SYS_MODULE. For software compatibility reasons,
56671 + /proc/kallsyms will be restricted to the root user. The RBAC
56672 + system can hide that entry even from root.
56673 +
56674 + This option also prevents leaking of kernel addresses through
56675 + several /proc entries.
56676 +
56677 + Note that this option is only effective provided the following
56678 + conditions are met:
56679 + 1) The kernel using grsecurity is not precompiled by some distribution
56680 + 2) You have also enabled GRKERNSEC_DMESG
56681 + 3) You are using the RBAC system and hiding other files such as your
56682 + kernel image and System.map. Alternatively, enabling this option
56683 + causes the permissions on /boot, /lib/modules, and the kernel
56684 + source directory to change at compile time to prevent
56685 + reading by non-root users.
56686 + If the above conditions are met, this option will aid in providing a
56687 + useful protection against local kernel exploitation of overflows
56688 + and arbitrary read/write vulnerabilities.
56689 +
56690 +config GRKERNSEC_KERN_LOCKOUT
56691 + bool "Active kernel exploit response"
56692 + default y if GRKERNSEC_CONFIG_AUTO
56693 + depends on X86 || ARM || PPC || SPARC
56694 + help
56695 + If you say Y here, when a PaX alert is triggered due to suspicious
56696 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
56697 + or an OOPS occurs due to bad memory accesses, instead of just
56698 + terminating the offending process (and potentially allowing
56699 + a subsequent exploit from the same user), we will take one of two
56700 + actions:
56701 + If the user was root, we will panic the system
56702 + If the user was non-root, we will log the attempt, terminate
56703 + all processes owned by the user, then prevent them from creating
56704 + any new processes until the system is restarted
56705 + This deters repeated kernel exploitation/bruteforcing attempts
56706 + and is useful for later forensics.
56707 +
56708 +endmenu
56709 +menu "Role Based Access Control Options"
56710 +depends on GRKERNSEC
56711 +
56712 +config GRKERNSEC_RBAC_DEBUG
56713 + bool
56714 +
56715 +config GRKERNSEC_NO_RBAC
56716 + bool "Disable RBAC system"
56717 + help
56718 + If you say Y here, the /dev/grsec device will be removed from the kernel,
56719 + preventing the RBAC system from being enabled. You should only say Y
56720 + here if you have no intention of using the RBAC system, so as to prevent
56721 + an attacker with root access from misusing the RBAC system to hide files
56722 + and processes when loadable module support and /dev/[k]mem have been
56723 + locked down.
56724 +
56725 +config GRKERNSEC_ACL_HIDEKERN
56726 + bool "Hide kernel processes"
56727 + help
56728 + If you say Y here, all kernel threads will be hidden to all
56729 + processes but those whose subject has the "view hidden processes"
56730 + flag.
56731 +
56732 +config GRKERNSEC_ACL_MAXTRIES
56733 + int "Maximum tries before password lockout"
56734 + default 3
56735 + help
56736 + This option enforces the maximum number of times a user can attempt
56737 + to authorize themselves with the grsecurity RBAC system before being
56738 + denied the ability to attempt authorization again for a specified time.
56739 + The lower the number, the harder it will be to brute-force a password.
56740 +
56741 +config GRKERNSEC_ACL_TIMEOUT
56742 + int "Time to wait after max password tries, in seconds"
56743 + default 30
56744 + help
56745 + This option specifies the time the user must wait after attempting to
56746 + authorize to the RBAC system with the maximum number of invalid
56747 + passwords. The higher the number, the harder it will be to brute-force
56748 + a password.
56749 +
56750 +endmenu
56751 +menu "Filesystem Protections"
56752 +depends on GRKERNSEC
56753 +
56754 +config GRKERNSEC_PROC
56755 + bool "Proc restrictions"
56756 + default y if GRKERNSEC_CONFIG_AUTO
56757 + help
56758 + If you say Y here, the permissions of the /proc filesystem
56759 + will be altered to enhance system security and privacy. You MUST
56760 + choose either a user only restriction or a user and group restriction.
56761 + Depending upon the option you choose, you can either restrict users to
56762 + see only the processes they themselves run, or choose a group that can
56763 + view all processes and files normally restricted to root if you choose
56764 + the "restrict to user only" option. NOTE: If you're running identd or
56765 + ntpd as a non-root user, you will have to run it as the group you
56766 + specify here.
56767 +
56768 +config GRKERNSEC_PROC_USER
56769 + bool "Restrict /proc to user only"
56770 + depends on GRKERNSEC_PROC
56771 + help
56772 + If you say Y here, non-root users will only be able to view their own
56773 + processes, and restricts them from viewing network-related information,
56774 + and viewing kernel symbol and module information.
56775 +
56776 +config GRKERNSEC_PROC_USERGROUP
56777 + bool "Allow special group"
56778 + default y if GRKERNSEC_CONFIG_AUTO
56779 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
56780 + help
56781 + If you say Y here, you will be able to select a group that will be
56782 + able to view all processes and network-related information. If you've
56783 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
56784 + remain hidden. This option is useful if you want to run identd as
56785 + a non-root user. The group you select may also be chosen at boot time
56786 + via "grsec_proc_gid=" on the kernel commandline.
56787 +
56788 +config GRKERNSEC_PROC_GID
56789 + int "GID for special group"
56790 + depends on GRKERNSEC_PROC_USERGROUP
56791 + default 1001
56792 +
56793 +config GRKERNSEC_PROC_ADD
56794 + bool "Additional restrictions"
56795 + default y if GRKERNSEC_CONFIG_AUTO
56796 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
56797 + help
56798 + If you say Y here, additional restrictions will be placed on
56799 + /proc that keep normal users from viewing device information and
56800 + slabinfo information that could be useful for exploits.
56801 +
56802 +config GRKERNSEC_LINK
56803 + bool "Linking restrictions"
56804 + default y if GRKERNSEC_CONFIG_AUTO
56805 + help
56806 + If you say Y here, /tmp race exploits will be prevented, since users
56807 + will no longer be able to follow symlinks owned by other users in
56808 + world-writable +t directories (e.g. /tmp), unless the owner of the
56809 + symlink is the owner of the directory. users will also not be
56810 + able to hardlink to files they do not own. If the sysctl option is
56811 + enabled, a sysctl option with name "linking_restrictions" is created.
56812 +
56813 +config GRKERNSEC_SYMLINKOWN
56814 + bool "Kernel-enforced SymlinksIfOwnerMatch"
56815 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56816 + help
56817 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
56818 + that prevents it from being used as a security feature. As Apache
56819 + verifies the symlink by performing a stat() against the target of
56820 + the symlink before it is followed, an attacker can setup a symlink
56821 + to point to a same-owned file, then replace the symlink with one
56822 + that targets another user's file just after Apache "validates" the
56823 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
56824 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
56825 + will be in place for the group you specify. If the sysctl option
56826 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
56827 + created.
56828 +
56829 +config GRKERNSEC_SYMLINKOWN_GID
56830 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
56831 + depends on GRKERNSEC_SYMLINKOWN
56832 + default 1006
56833 + help
56834 + Setting this GID determines what group kernel-enforced
56835 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
56836 + is enabled, a sysctl option with name "symlinkown_gid" is created.
56837 +
56838 +config GRKERNSEC_FIFO
56839 + bool "FIFO restrictions"
56840 + default y if GRKERNSEC_CONFIG_AUTO
56841 + help
56842 + If you say Y here, users will not be able to write to FIFOs they don't
56843 + own in world-writable +t directories (e.g. /tmp), unless the owner of
56844 + the FIFO is the same owner of the directory it's held in. If the sysctl
56845 + option is enabled, a sysctl option with name "fifo_restrictions" is
56846 + created.
56847 +
56848 +config GRKERNSEC_SYSFS_RESTRICT
56849 + bool "Sysfs/debugfs restriction"
56850 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56851 + depends on SYSFS
56852 + help
56853 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
56854 + any filesystem normally mounted under it (e.g. debugfs) will be
56855 + mostly accessible only by root. These filesystems generally provide access
56856 + to hardware and debug information that isn't appropriate for unprivileged
56857 + users of the system. Sysfs and debugfs have also become a large source
56858 + of new vulnerabilities, ranging from infoleaks to local compromise.
56859 + There has been very little oversight with an eye toward security involved
56860 + in adding new exporters of information to these filesystems, so their
56861 + use is discouraged.
56862 + For reasons of compatibility, a few directories have been whitelisted
56863 + for access by non-root users:
56864 + /sys/fs/selinux
56865 + /sys/fs/fuse
56866 + /sys/devices/system/cpu
56867 +
56868 +config GRKERNSEC_ROFS
56869 + bool "Runtime read-only mount protection"
56870 + help
56871 + If you say Y here, a sysctl option with name "romount_protect" will
56872 + be created. By setting this option to 1 at runtime, filesystems
56873 + will be protected in the following ways:
56874 + * No new writable mounts will be allowed
56875 + * Existing read-only mounts won't be able to be remounted read/write
56876 + * Write operations will be denied on all block devices
56877 + This option acts independently of grsec_lock: once it is set to 1,
56878 + it cannot be turned off. Therefore, please be mindful of the resulting
56879 + behavior if this option is enabled in an init script on a read-only
56880 + filesystem. This feature is mainly intended for secure embedded systems.
56881 +
56882 +config GRKERNSEC_DEVICE_SIDECHANNEL
56883 + bool "Eliminate stat/notify-based device sidechannels"
56884 + default y if GRKERNSEC_CONFIG_AUTO
56885 + help
56886 + If you say Y here, timing analyses on block or character
56887 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
56888 + will be thwarted for unprivileged users. If a process without
56889 + CAP_MKNOD stats such a device, the last access and last modify times
56890 + will match the device's create time. No access or modify events
56891 + will be triggered through inotify/dnotify/fanotify for such devices.
56892 + This feature will prevent attacks that may at a minimum
56893 + allow an attacker to determine the administrator's password length.
56894 +
56895 +config GRKERNSEC_CHROOT
56896 + bool "Chroot jail restrictions"
56897 + default y if GRKERNSEC_CONFIG_AUTO
56898 + help
56899 + If you say Y here, you will be able to choose several options that will
56900 + make breaking out of a chrooted jail much more difficult. If you
56901 + encounter no software incompatibilities with the following options, it
56902 + is recommended that you enable each one.
56903 +
56904 +config GRKERNSEC_CHROOT_MOUNT
56905 + bool "Deny mounts"
56906 + default y if GRKERNSEC_CONFIG_AUTO
56907 + depends on GRKERNSEC_CHROOT
56908 + help
56909 + If you say Y here, processes inside a chroot will not be able to
56910 + mount or remount filesystems. If the sysctl option is enabled, a
56911 + sysctl option with name "chroot_deny_mount" is created.
56912 +
56913 +config GRKERNSEC_CHROOT_DOUBLE
56914 + bool "Deny double-chroots"
56915 + default y if GRKERNSEC_CONFIG_AUTO
56916 + depends on GRKERNSEC_CHROOT
56917 + help
56918 + If you say Y here, processes inside a chroot will not be able to chroot
56919 + again outside the chroot. This is a widely used method of breaking
56920 + out of a chroot jail and should not be allowed. If the sysctl
56921 + option is enabled, a sysctl option with name
56922 + "chroot_deny_chroot" is created.
56923 +
56924 +config GRKERNSEC_CHROOT_PIVOT
56925 + bool "Deny pivot_root in chroot"
56926 + default y if GRKERNSEC_CONFIG_AUTO
56927 + depends on GRKERNSEC_CHROOT
56928 + help
56929 + If you say Y here, processes inside a chroot will not be able to use
56930 + a function called pivot_root() that was introduced in Linux 2.3.41. It
56931 + works similar to chroot in that it changes the root filesystem. This
56932 + function could be misused in a chrooted process to attempt to break out
56933 + of the chroot, and therefore should not be allowed. If the sysctl
56934 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
56935 + created.
56936 +
56937 +config GRKERNSEC_CHROOT_CHDIR
56938 + bool "Enforce chdir(\"/\") on all chroots"
56939 + default y if GRKERNSEC_CONFIG_AUTO
56940 + depends on GRKERNSEC_CHROOT
56941 + help
56942 + If you say Y here, the current working directory of all newly-chrooted
56943 + applications will be set to the the root directory of the chroot.
56944 + The man page on chroot(2) states:
56945 + Note that this call does not change the current working
56946 + directory, so that `.' can be outside the tree rooted at
56947 + `/'. In particular, the super-user can escape from a
56948 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
56949 +
56950 + It is recommended that you say Y here, since it's not known to break
56951 + any software. If the sysctl option is enabled, a sysctl option with
56952 + name "chroot_enforce_chdir" is created.
56953 +
56954 +config GRKERNSEC_CHROOT_CHMOD
56955 + bool "Deny (f)chmod +s"
56956 + default y if GRKERNSEC_CONFIG_AUTO
56957 + depends on GRKERNSEC_CHROOT
56958 + help
56959 + If you say Y here, processes inside a chroot will not be able to chmod
56960 + or fchmod files to make them have suid or sgid bits. This protects
56961 + against another published method of breaking a chroot. If the sysctl
56962 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
56963 + created.
56964 +
56965 +config GRKERNSEC_CHROOT_FCHDIR
56966 + bool "Deny fchdir out of chroot"
56967 + default y if GRKERNSEC_CONFIG_AUTO
56968 + depends on GRKERNSEC_CHROOT
56969 + help
56970 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
56971 + to a file descriptor of the chrooting process that points to a directory
56972 + outside the filesystem will be stopped. If the sysctl option
56973 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
56974 +
56975 +config GRKERNSEC_CHROOT_MKNOD
56976 + bool "Deny mknod"
56977 + default y if GRKERNSEC_CONFIG_AUTO
56978 + depends on GRKERNSEC_CHROOT
56979 + help
56980 + If you say Y here, processes inside a chroot will not be allowed to
56981 + mknod. The problem with using mknod inside a chroot is that it
56982 + would allow an attacker to create a device entry that is the same
56983 + as one on the physical root of your system, which could range from
56984 + anything from the console device to a device for your harddrive (which
56985 + they could then use to wipe the drive or steal data). It is recommended
56986 + that you say Y here, unless you run into software incompatibilities.
56987 + If the sysctl option is enabled, a sysctl option with name
56988 + "chroot_deny_mknod" is created.
56989 +
56990 +config GRKERNSEC_CHROOT_SHMAT
56991 + bool "Deny shmat() out of chroot"
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 able to attach
56996 + to shared memory segments that were created outside of the chroot jail.
56997 + It is recommended that you say Y here. If the sysctl option is enabled,
56998 + a sysctl option with name "chroot_deny_shmat" is created.
56999 +
57000 +config GRKERNSEC_CHROOT_UNIX
57001 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57002 + default y if GRKERNSEC_CONFIG_AUTO
57003 + depends on GRKERNSEC_CHROOT
57004 + help
57005 + If you say Y here, processes inside a chroot will not be able to
57006 + connect to abstract (meaning not belonging to a filesystem) Unix
57007 + domain sockets that were bound outside of a chroot. It is recommended
57008 + that you say Y here. If the sysctl option is enabled, a sysctl option
57009 + with name "chroot_deny_unix" is created.
57010 +
57011 +config GRKERNSEC_CHROOT_FINDTASK
57012 + bool "Protect outside processes"
57013 + default y if GRKERNSEC_CONFIG_AUTO
57014 + depends on GRKERNSEC_CHROOT
57015 + help
57016 + If you say Y here, processes inside a chroot will not be able to
57017 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57018 + getsid, or view any process outside of the chroot. If the sysctl
57019 + option is enabled, a sysctl option with name "chroot_findtask" is
57020 + created.
57021 +
57022 +config GRKERNSEC_CHROOT_NICE
57023 + bool "Restrict priority changes"
57024 + default y if GRKERNSEC_CONFIG_AUTO
57025 + depends on GRKERNSEC_CHROOT
57026 + help
57027 + If you say Y here, processes inside a chroot will not be able to raise
57028 + the priority of processes in the chroot, or alter the priority of
57029 + processes outside the chroot. This provides more security than simply
57030 + removing CAP_SYS_NICE from the process' capability set. If the
57031 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57032 + is created.
57033 +
57034 +config GRKERNSEC_CHROOT_SYSCTL
57035 + bool "Deny sysctl writes"
57036 + default y if GRKERNSEC_CONFIG_AUTO
57037 + depends on GRKERNSEC_CHROOT
57038 + help
57039 + If you say Y here, an attacker in a chroot will not be able to
57040 + write to sysctl entries, either by sysctl(2) or through a /proc
57041 + interface. It is strongly recommended that you say Y here. If the
57042 + sysctl option is enabled, a sysctl option with name
57043 + "chroot_deny_sysctl" is created.
57044 +
57045 +config GRKERNSEC_CHROOT_CAPS
57046 + bool "Capability restrictions"
57047 + default y if GRKERNSEC_CONFIG_AUTO
57048 + depends on GRKERNSEC_CHROOT
57049 + help
57050 + If you say Y here, the capabilities on all processes within a
57051 + chroot jail will be lowered to stop module insertion, raw i/o,
57052 + system and net admin tasks, rebooting the system, modifying immutable
57053 + files, modifying IPC owned by another, and changing the system time.
57054 + This is left an option because it can break some apps. Disable this
57055 + if your chrooted apps are having problems performing those kinds of
57056 + tasks. If the sysctl option is enabled, a sysctl option with
57057 + name "chroot_caps" is created.
57058 +
57059 +config GRKERNSEC_CHROOT_INITRD
57060 + bool "Exempt initrd tasks from restrictions"
57061 + default y if GRKERNSEC_CONFIG_AUTO
57062 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
57063 + help
57064 + If you say Y here, tasks started prior to init will be exempted from
57065 + grsecurity's chroot restrictions. This option is mainly meant to
57066 + resolve Plymouth's performing privileged operations unnecessarily
57067 + in a chroot.
57068 +
57069 +endmenu
57070 +menu "Kernel Auditing"
57071 +depends on GRKERNSEC
57072 +
57073 +config GRKERNSEC_AUDIT_GROUP
57074 + bool "Single group for auditing"
57075 + help
57076 + If you say Y here, the exec and chdir logging features will only operate
57077 + on a group you specify. This option is recommended if you only want to
57078 + watch certain users instead of having a large amount of logs from the
57079 + entire system. If the sysctl option is enabled, a sysctl option with
57080 + name "audit_group" is created.
57081 +
57082 +config GRKERNSEC_AUDIT_GID
57083 + int "GID for auditing"
57084 + depends on GRKERNSEC_AUDIT_GROUP
57085 + default 1007
57086 +
57087 +config GRKERNSEC_EXECLOG
57088 + bool "Exec logging"
57089 + help
57090 + If you say Y here, all execve() calls will be logged (since the
57091 + other exec*() calls are frontends to execve(), all execution
57092 + will be logged). Useful for shell-servers that like to keep track
57093 + of their users. If the sysctl option is enabled, a sysctl option with
57094 + name "exec_logging" is created.
57095 + WARNING: This option when enabled will produce a LOT of logs, especially
57096 + on an active system.
57097 +
57098 +config GRKERNSEC_RESLOG
57099 + bool "Resource logging"
57100 + default y if GRKERNSEC_CONFIG_AUTO
57101 + help
57102 + If you say Y here, all attempts to overstep resource limits will
57103 + be logged with the resource name, the requested size, and the current
57104 + limit. It is highly recommended that you say Y here. If the sysctl
57105 + option is enabled, a sysctl option with name "resource_logging" is
57106 + created. If the RBAC system is enabled, the sysctl value is ignored.
57107 +
57108 +config GRKERNSEC_CHROOT_EXECLOG
57109 + bool "Log execs within chroot"
57110 + help
57111 + If you say Y here, all executions inside a chroot jail will be logged
57112 + to syslog. This can cause a large amount of logs if certain
57113 + applications (eg. djb's daemontools) are installed on the system, and
57114 + is therefore left as an option. If the sysctl option is enabled, a
57115 + sysctl option with name "chroot_execlog" is created.
57116 +
57117 +config GRKERNSEC_AUDIT_PTRACE
57118 + bool "Ptrace logging"
57119 + help
57120 + If you say Y here, all attempts to attach to a process via ptrace
57121 + will be logged. If the sysctl option is enabled, a sysctl option
57122 + with name "audit_ptrace" is created.
57123 +
57124 +config GRKERNSEC_AUDIT_CHDIR
57125 + bool "Chdir logging"
57126 + help
57127 + If you say Y here, all chdir() calls will be logged. If the sysctl
57128 + option is enabled, a sysctl option with name "audit_chdir" is created.
57129 +
57130 +config GRKERNSEC_AUDIT_MOUNT
57131 + bool "(Un)Mount logging"
57132 + help
57133 + If you say Y here, all mounts and unmounts will be logged. If the
57134 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57135 + created.
57136 +
57137 +config GRKERNSEC_SIGNAL
57138 + bool "Signal logging"
57139 + default y if GRKERNSEC_CONFIG_AUTO
57140 + help
57141 + If you say Y here, certain important signals will be logged, such as
57142 + SIGSEGV, which will as a result inform you of when a error in a program
57143 + occurred, which in some cases could mean a possible exploit attempt.
57144 + If the sysctl option is enabled, a sysctl option with name
57145 + "signal_logging" is created.
57146 +
57147 +config GRKERNSEC_FORKFAIL
57148 + bool "Fork failure logging"
57149 + help
57150 + If you say Y here, all failed fork() attempts will be logged.
57151 + This could suggest a fork bomb, or someone attempting to overstep
57152 + their process limit. If the sysctl option is enabled, a sysctl option
57153 + with name "forkfail_logging" is created.
57154 +
57155 +config GRKERNSEC_TIME
57156 + bool "Time change logging"
57157 + default y if GRKERNSEC_CONFIG_AUTO
57158 + help
57159 + If you say Y here, any changes of the system clock will be logged.
57160 + If the sysctl option is enabled, a sysctl option with name
57161 + "timechange_logging" is created.
57162 +
57163 +config GRKERNSEC_PROC_IPADDR
57164 + bool "/proc/<pid>/ipaddr support"
57165 + default y if GRKERNSEC_CONFIG_AUTO
57166 + help
57167 + If you say Y here, a new entry will be added to each /proc/<pid>
57168 + directory that contains the IP address of the person using the task.
57169 + The IP is carried across local TCP and AF_UNIX stream sockets.
57170 + This information can be useful for IDS/IPSes to perform remote response
57171 + to a local attack. The entry is readable by only the owner of the
57172 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57173 + the RBAC system), and thus does not create privacy concerns.
57174 +
57175 +config GRKERNSEC_RWXMAP_LOG
57176 + bool 'Denied RWX mmap/mprotect logging'
57177 + default y if GRKERNSEC_CONFIG_AUTO
57178 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57179 + help
57180 + If you say Y here, calls to mmap() and mprotect() with explicit
57181 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57182 + denied by the PAX_MPROTECT feature. If the sysctl option is
57183 + enabled, a sysctl option with name "rwxmap_logging" is created.
57184 +
57185 +config GRKERNSEC_AUDIT_TEXTREL
57186 + bool 'ELF text relocations logging (READ HELP)'
57187 + depends on PAX_MPROTECT
57188 + help
57189 + If you say Y here, text relocations will be logged with the filename
57190 + of the offending library or binary. The purpose of the feature is
57191 + to help Linux distribution developers get rid of libraries and
57192 + binaries that need text relocations which hinder the future progress
57193 + of PaX. Only Linux distribution developers should say Y here, and
57194 + never on a production machine, as this option creates an information
57195 + leak that could aid an attacker in defeating the randomization of
57196 + a single memory region. If the sysctl option is enabled, a sysctl
57197 + option with name "audit_textrel" is created.
57198 +
57199 +endmenu
57200 +
57201 +menu "Executable Protections"
57202 +depends on GRKERNSEC
57203 +
57204 +config GRKERNSEC_DMESG
57205 + bool "Dmesg(8) restriction"
57206 + default y if GRKERNSEC_CONFIG_AUTO
57207 + help
57208 + If you say Y here, non-root users will not be able to use dmesg(8)
57209 + to view the contents of the kernel's circular log buffer.
57210 + The kernel's log buffer often contains kernel addresses and other
57211 + identifying information useful to an attacker in fingerprinting a
57212 + system for a targeted exploit.
57213 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57214 + created.
57215 +
57216 +config GRKERNSEC_HARDEN_PTRACE
57217 + bool "Deter ptrace-based process snooping"
57218 + default y if GRKERNSEC_CONFIG_AUTO
57219 + help
57220 + If you say Y here, TTY sniffers and other malicious monitoring
57221 + programs implemented through ptrace will be defeated. If you
57222 + have been using the RBAC system, this option has already been
57223 + enabled for several years for all users, with the ability to make
57224 + fine-grained exceptions.
57225 +
57226 + This option only affects the ability of non-root users to ptrace
57227 + processes that are not a descendent of the ptracing process.
57228 + This means that strace ./binary and gdb ./binary will still work,
57229 + but attaching to arbitrary processes will not. If the sysctl
57230 + option is enabled, a sysctl option with name "harden_ptrace" is
57231 + created.
57232 +
57233 +config GRKERNSEC_PTRACE_READEXEC
57234 + bool "Require read access to ptrace sensitive binaries"
57235 + default y if GRKERNSEC_CONFIG_AUTO
57236 + help
57237 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57238 + binaries. This option is useful in environments that
57239 + remove the read bits (e.g. file mode 4711) from suid binaries to
57240 + prevent infoleaking of their contents. This option adds
57241 + consistency to the use of that file mode, as the binary could normally
57242 + be read out when run without privileges while ptracing.
57243 +
57244 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57245 + is created.
57246 +
57247 +config GRKERNSEC_SETXID
57248 + bool "Enforce consistent multithreaded privileges"
57249 + default y if GRKERNSEC_CONFIG_AUTO
57250 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57251 + help
57252 + If you say Y here, a change from a root uid to a non-root uid
57253 + in a multithreaded application will cause the resulting uids,
57254 + gids, supplementary groups, and capabilities in that thread
57255 + to be propagated to the other threads of the process. In most
57256 + cases this is unnecessary, as glibc will emulate this behavior
57257 + on behalf of the application. Other libcs do not act in the
57258 + same way, allowing the other threads of the process to continue
57259 + running with root privileges. If the sysctl option is enabled,
57260 + a sysctl option with name "consistent_setxid" is created.
57261 +
57262 +config GRKERNSEC_TPE
57263 + bool "Trusted Path Execution (TPE)"
57264 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57265 + help
57266 + If you say Y here, you will be able to choose a gid to add to the
57267 + supplementary groups of users you want to mark as "untrusted."
57268 + These users will not be able to execute any files that are not in
57269 + root-owned directories writable only by root. If the sysctl option
57270 + is enabled, a sysctl option with name "tpe" is created.
57271 +
57272 +config GRKERNSEC_TPE_ALL
57273 + bool "Partially restrict all non-root users"
57274 + depends on GRKERNSEC_TPE
57275 + help
57276 + If you say Y here, all non-root users will be covered under
57277 + a weaker TPE restriction. This is separate from, and in addition to,
57278 + the main TPE options that you have selected elsewhere. Thus, if a
57279 + "trusted" GID is chosen, this restriction applies to even that GID.
57280 + Under this restriction, all non-root users will only be allowed to
57281 + execute files in directories they own that are not group or
57282 + world-writable, or in directories owned by root and writable only by
57283 + root. If the sysctl option is enabled, a sysctl option with name
57284 + "tpe_restrict_all" is created.
57285 +
57286 +config GRKERNSEC_TPE_INVERT
57287 + bool "Invert GID option"
57288 + depends on GRKERNSEC_TPE
57289 + help
57290 + If you say Y here, the group you specify in the TPE configuration will
57291 + decide what group TPE restrictions will be *disabled* for. This
57292 + option is useful if you want TPE restrictions to be applied to most
57293 + users on the system. If the sysctl option is enabled, a sysctl option
57294 + with name "tpe_invert" is created. Unlike other sysctl options, this
57295 + entry will default to on for backward-compatibility.
57296 +
57297 +config GRKERNSEC_TPE_GID
57298 + int
57299 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57300 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57301 +
57302 +config GRKERNSEC_TPE_UNTRUSTED_GID
57303 + int "GID for TPE-untrusted users"
57304 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57305 + default 1005
57306 + help
57307 + Setting this GID determines what group TPE restrictions will be
57308 + *enabled* for. If the sysctl option is enabled, a sysctl option
57309 + with name "tpe_gid" is created.
57310 +
57311 +config GRKERNSEC_TPE_TRUSTED_GID
57312 + int "GID for TPE-trusted users"
57313 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57314 + default 1005
57315 + help
57316 + Setting this GID determines what group TPE restrictions will be
57317 + *disabled* for. If the sysctl option is enabled, a sysctl option
57318 + with name "tpe_gid" is created.
57319 +
57320 +endmenu
57321 +menu "Network Protections"
57322 +depends on GRKERNSEC
57323 +
57324 +config GRKERNSEC_RANDNET
57325 + bool "Larger entropy pools"
57326 + default y if GRKERNSEC_CONFIG_AUTO
57327 + help
57328 + If you say Y here, the entropy pools used for many features of Linux
57329 + and grsecurity will be doubled in size. Since several grsecurity
57330 + features use additional randomness, it is recommended that you say Y
57331 + here. Saying Y here has a similar effect as modifying
57332 + /proc/sys/kernel/random/poolsize.
57333 +
57334 +config GRKERNSEC_BLACKHOLE
57335 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57336 + default y if GRKERNSEC_CONFIG_AUTO
57337 + depends on NET
57338 + help
57339 + If you say Y here, neither TCP resets nor ICMP
57340 + destination-unreachable packets will be sent in response to packets
57341 + sent to ports for which no associated listening process exists.
57342 + This feature supports both IPV4 and IPV6 and exempts the
57343 + loopback interface from blackholing. Enabling this feature
57344 + makes a host more resilient to DoS attacks and reduces network
57345 + visibility against scanners.
57346 +
57347 + The blackhole feature as-implemented is equivalent to the FreeBSD
57348 + blackhole feature, as it prevents RST responses to all packets, not
57349 + just SYNs. Under most application behavior this causes no
57350 + problems, but applications (like haproxy) may not close certain
57351 + connections in a way that cleanly terminates them on the remote
57352 + end, leaving the remote host in LAST_ACK state. Because of this
57353 + side-effect and to prevent intentional LAST_ACK DoSes, this
57354 + feature also adds automatic mitigation against such attacks.
57355 + The mitigation drastically reduces the amount of time a socket
57356 + can spend in LAST_ACK state. If you're using haproxy and not
57357 + all servers it connects to have this option enabled, consider
57358 + disabling this feature on the haproxy host.
57359 +
57360 + If the sysctl option is enabled, two sysctl options with names
57361 + "ip_blackhole" and "lastack_retries" will be created.
57362 + While "ip_blackhole" takes the standard zero/non-zero on/off
57363 + toggle, "lastack_retries" uses the same kinds of values as
57364 + "tcp_retries1" and "tcp_retries2". The default value of 4
57365 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57366 + state.
57367 +
57368 +config GRKERNSEC_NO_SIMULT_CONNECT
57369 + bool "Disable TCP Simultaneous Connect"
57370 + default y if GRKERNSEC_CONFIG_AUTO
57371 + depends on NET
57372 + help
57373 + If you say Y here, a feature by Willy Tarreau will be enabled that
57374 + removes a weakness in Linux's strict implementation of TCP that
57375 + allows two clients to connect to each other without either entering
57376 + a listening state. The weakness allows an attacker to easily prevent
57377 + a client from connecting to a known server provided the source port
57378 + for the connection is guessed correctly.
57379 +
57380 + As the weakness could be used to prevent an antivirus or IPS from
57381 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57382 + it should be eliminated by enabling this option. Though Linux is
57383 + one of few operating systems supporting simultaneous connect, it
57384 + has no legitimate use in practice and is rarely supported by firewalls.
57385 +
57386 +config GRKERNSEC_SOCKET
57387 + bool "Socket restrictions"
57388 + depends on NET
57389 + help
57390 + If you say Y here, you will be able to choose from several options.
57391 + If you assign a GID on your system and add it to the supplementary
57392 + groups of users you want to restrict socket access to, this patch
57393 + will perform up to three things, based on the option(s) you choose.
57394 +
57395 +config GRKERNSEC_SOCKET_ALL
57396 + bool "Deny any sockets to group"
57397 + depends on GRKERNSEC_SOCKET
57398 + help
57399 + If you say Y here, you will be able to choose a GID of whose users will
57400 + be unable to connect to other hosts from your machine or run server
57401 + applications from your machine. If the sysctl option is enabled, a
57402 + sysctl option with name "socket_all" is created.
57403 +
57404 +config GRKERNSEC_SOCKET_ALL_GID
57405 + int "GID to deny all sockets for"
57406 + depends on GRKERNSEC_SOCKET_ALL
57407 + default 1004
57408 + help
57409 + Here you can choose the GID to disable socket access for. Remember to
57410 + add the users you want socket access disabled for to the GID
57411 + specified here. If the sysctl option is enabled, a sysctl option
57412 + with name "socket_all_gid" is created.
57413 +
57414 +config GRKERNSEC_SOCKET_CLIENT
57415 + bool "Deny client sockets to group"
57416 + depends on GRKERNSEC_SOCKET
57417 + help
57418 + If you say Y here, you will be able to choose a GID of whose users will
57419 + be unable to connect to other hosts from your machine, but will be
57420 + able to run servers. If this option is enabled, all users in the group
57421 + you specify will have to use passive mode when initiating ftp transfers
57422 + from the shell on your machine. If the sysctl option is enabled, a
57423 + sysctl option with name "socket_client" is created.
57424 +
57425 +config GRKERNSEC_SOCKET_CLIENT_GID
57426 + int "GID to deny client sockets for"
57427 + depends on GRKERNSEC_SOCKET_CLIENT
57428 + default 1003
57429 + help
57430 + Here you can choose the GID to disable client socket access for.
57431 + Remember to add the users you want client socket access disabled for to
57432 + the GID specified here. If the sysctl option is enabled, a sysctl
57433 + option with name "socket_client_gid" is created.
57434 +
57435 +config GRKERNSEC_SOCKET_SERVER
57436 + bool "Deny server sockets to group"
57437 + depends on GRKERNSEC_SOCKET
57438 + help
57439 + If you say Y here, you will be able to choose a GID of whose users will
57440 + be unable to run server applications from your machine. If the sysctl
57441 + option is enabled, a sysctl option with name "socket_server" is created.
57442 +
57443 +config GRKERNSEC_SOCKET_SERVER_GID
57444 + int "GID to deny server sockets for"
57445 + depends on GRKERNSEC_SOCKET_SERVER
57446 + default 1002
57447 + help
57448 + Here you can choose the GID to disable server socket access for.
57449 + Remember to add the users you want server socket access disabled for to
57450 + the GID specified here. If the sysctl option is enabled, a sysctl
57451 + option with name "socket_server_gid" is created.
57452 +
57453 +endmenu
57454 +menu "Sysctl Support"
57455 +depends on GRKERNSEC && SYSCTL
57456 +
57457 +config GRKERNSEC_SYSCTL
57458 + bool "Sysctl support"
57459 + default y if GRKERNSEC_CONFIG_AUTO
57460 + help
57461 + If you say Y here, you will be able to change the options that
57462 + grsecurity runs with at bootup, without having to recompile your
57463 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57464 + to enable (1) or disable (0) various features. All the sysctl entries
57465 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57466 + All features enabled in the kernel configuration are disabled at boot
57467 + if you do not say Y to the "Turn on features by default" option.
57468 + All options should be set at startup, and the grsec_lock entry should
57469 + be set to a non-zero value after all the options are set.
57470 + *THIS IS EXTREMELY IMPORTANT*
57471 +
57472 +config GRKERNSEC_SYSCTL_DISTRO
57473 + bool "Extra sysctl support for distro makers (READ HELP)"
57474 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57475 + help
57476 + If you say Y here, additional sysctl options will be created
57477 + for features that affect processes running as root. Therefore,
57478 + it is critical when using this option that the grsec_lock entry be
57479 + enabled after boot. Only distros with prebuilt kernel packages
57480 + with this option enabled that can ensure grsec_lock is enabled
57481 + after boot should use this option.
57482 + *Failure to set grsec_lock after boot makes all grsec features
57483 + this option covers useless*
57484 +
57485 + Currently this option creates the following sysctl entries:
57486 + "Disable Privileged I/O": "disable_priv_io"
57487 +
57488 +config GRKERNSEC_SYSCTL_ON
57489 + bool "Turn on features by default"
57490 + default y if GRKERNSEC_CONFIG_AUTO
57491 + depends on GRKERNSEC_SYSCTL
57492 + help
57493 + If you say Y here, instead of having all features enabled in the
57494 + kernel configuration disabled at boot time, the features will be
57495 + enabled at boot time. It is recommended you say Y here unless
57496 + there is some reason you would want all sysctl-tunable features to
57497 + be disabled by default. As mentioned elsewhere, it is important
57498 + to enable the grsec_lock entry once you have finished modifying
57499 + the sysctl entries.
57500 +
57501 +endmenu
57502 +menu "Logging Options"
57503 +depends on GRKERNSEC
57504 +
57505 +config GRKERNSEC_FLOODTIME
57506 + int "Seconds in between log messages (minimum)"
57507 + default 10
57508 + help
57509 + This option allows you to enforce the number of seconds between
57510 + grsecurity log messages. The default should be suitable for most
57511 + people, however, if you choose to change it, choose a value small enough
57512 + to allow informative logs to be produced, but large enough to
57513 + prevent flooding.
57514 +
57515 +config GRKERNSEC_FLOODBURST
57516 + int "Number of messages in a burst (maximum)"
57517 + default 6
57518 + help
57519 + This option allows you to choose the maximum number of messages allowed
57520 + within the flood time interval you chose in a separate option. The
57521 + default should be suitable for most people, however if you find that
57522 + many of your logs are being interpreted as flooding, you may want to
57523 + raise this value.
57524 +
57525 +endmenu
57526 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
57527 new file mode 100644
57528 index 0000000..1b9afa9
57529 --- /dev/null
57530 +++ b/grsecurity/Makefile
57531 @@ -0,0 +1,38 @@
57532 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
57533 +# during 2001-2009 it has been completely redesigned by Brad Spengler
57534 +# into an RBAC system
57535 +#
57536 +# All code in this directory and various hooks inserted throughout the kernel
57537 +# are copyright Brad Spengler - Open Source Security, Inc., and released
57538 +# under the GPL v2 or higher
57539 +
57540 +KBUILD_CFLAGS += -Werror
57541 +
57542 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
57543 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
57544 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
57545 +
57546 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
57547 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
57548 + gracl_learn.o grsec_log.o
57549 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
57550 +
57551 +ifdef CONFIG_NET
57552 +obj-y += grsec_sock.o
57553 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
57554 +endif
57555 +
57556 +ifndef CONFIG_GRKERNSEC
57557 +obj-y += grsec_disabled.o
57558 +endif
57559 +
57560 +ifdef CONFIG_GRKERNSEC_HIDESYM
57561 +extra-y := grsec_hidesym.o
57562 +$(obj)/grsec_hidesym.o:
57563 + @-chmod -f 500 /boot
57564 + @-chmod -f 500 /lib/modules
57565 + @-chmod -f 500 /lib64/modules
57566 + @-chmod -f 500 /lib32/modules
57567 + @-chmod -f 700 .
57568 + @echo ' grsec: protected kernel image paths'
57569 +endif
57570 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
57571 new file mode 100644
57572 index 0000000..1248ee0
57573 --- /dev/null
57574 +++ b/grsecurity/gracl.c
57575 @@ -0,0 +1,4073 @@
57576 +#include <linux/kernel.h>
57577 +#include <linux/module.h>
57578 +#include <linux/sched.h>
57579 +#include <linux/mm.h>
57580 +#include <linux/file.h>
57581 +#include <linux/fs.h>
57582 +#include <linux/namei.h>
57583 +#include <linux/mount.h>
57584 +#include <linux/tty.h>
57585 +#include <linux/proc_fs.h>
57586 +#include <linux/lglock.h>
57587 +#include <linux/slab.h>
57588 +#include <linux/vmalloc.h>
57589 +#include <linux/types.h>
57590 +#include <linux/sysctl.h>
57591 +#include <linux/netdevice.h>
57592 +#include <linux/ptrace.h>
57593 +#include <linux/gracl.h>
57594 +#include <linux/gralloc.h>
57595 +#include <linux/security.h>
57596 +#include <linux/grinternal.h>
57597 +#include <linux/pid_namespace.h>
57598 +#include <linux/stop_machine.h>
57599 +#include <linux/fdtable.h>
57600 +#include <linux/percpu.h>
57601 +#include <linux/lglock.h>
57602 +#include <linux/hugetlb.h>
57603 +#include <linux/posix-timers.h>
57604 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
57605 +#include <linux/magic.h>
57606 +#include <linux/pagemap.h>
57607 +#include "../fs/btrfs/async-thread.h"
57608 +#include "../fs/btrfs/ctree.h"
57609 +#include "../fs/btrfs/btrfs_inode.h"
57610 +#endif
57611 +#include "../fs/mount.h"
57612 +
57613 +#include <asm/uaccess.h>
57614 +#include <asm/errno.h>
57615 +#include <asm/mman.h>
57616 +
57617 +extern struct lglock vfsmount_lock;
57618 +
57619 +static struct acl_role_db acl_role_set;
57620 +static struct name_db name_set;
57621 +static struct inodev_db inodev_set;
57622 +
57623 +/* for keeping track of userspace pointers used for subjects, so we
57624 + can share references in the kernel as well
57625 +*/
57626 +
57627 +static struct path real_root;
57628 +
57629 +static struct acl_subj_map_db subj_map_set;
57630 +
57631 +static struct acl_role_label *default_role;
57632 +
57633 +static struct acl_role_label *role_list;
57634 +
57635 +static u16 acl_sp_role_value;
57636 +
57637 +extern char *gr_shared_page[4];
57638 +static DEFINE_MUTEX(gr_dev_mutex);
57639 +DEFINE_RWLOCK(gr_inode_lock);
57640 +
57641 +struct gr_arg *gr_usermode;
57642 +
57643 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
57644 +
57645 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
57646 +extern void gr_clear_learn_entries(void);
57647 +
57648 +unsigned char *gr_system_salt;
57649 +unsigned char *gr_system_sum;
57650 +
57651 +static struct sprole_pw **acl_special_roles = NULL;
57652 +static __u16 num_sprole_pws = 0;
57653 +
57654 +static struct acl_role_label *kernel_role = NULL;
57655 +
57656 +static unsigned int gr_auth_attempts = 0;
57657 +static unsigned long gr_auth_expires = 0UL;
57658 +
57659 +#ifdef CONFIG_NET
57660 +extern struct vfsmount *sock_mnt;
57661 +#endif
57662 +
57663 +extern struct vfsmount *pipe_mnt;
57664 +extern struct vfsmount *shm_mnt;
57665 +
57666 +#ifdef CONFIG_HUGETLBFS
57667 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57668 +#endif
57669 +
57670 +static struct acl_object_label *fakefs_obj_rw;
57671 +static struct acl_object_label *fakefs_obj_rwx;
57672 +
57673 +extern int gr_init_uidset(void);
57674 +extern void gr_free_uidset(void);
57675 +extern void gr_remove_uid(uid_t uid);
57676 +extern int gr_find_uid(uid_t uid);
57677 +
57678 +__inline__ int
57679 +gr_acl_is_enabled(void)
57680 +{
57681 + return (gr_status & GR_READY);
57682 +}
57683 +
57684 +static inline dev_t __get_dev(const struct dentry *dentry)
57685 +{
57686 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
57687 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
57688 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
57689 + else
57690 +#endif
57691 + return dentry->d_sb->s_dev;
57692 +}
57693 +
57694 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
57695 +{
57696 + return __get_dev(dentry);
57697 +}
57698 +
57699 +static char gr_task_roletype_to_char(struct task_struct *task)
57700 +{
57701 + switch (task->role->roletype &
57702 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
57703 + GR_ROLE_SPECIAL)) {
57704 + case GR_ROLE_DEFAULT:
57705 + return 'D';
57706 + case GR_ROLE_USER:
57707 + return 'U';
57708 + case GR_ROLE_GROUP:
57709 + return 'G';
57710 + case GR_ROLE_SPECIAL:
57711 + return 'S';
57712 + }
57713 +
57714 + return 'X';
57715 +}
57716 +
57717 +char gr_roletype_to_char(void)
57718 +{
57719 + return gr_task_roletype_to_char(current);
57720 +}
57721 +
57722 +__inline__ int
57723 +gr_acl_tpe_check(void)
57724 +{
57725 + if (unlikely(!(gr_status & GR_READY)))
57726 + return 0;
57727 + if (current->role->roletype & GR_ROLE_TPE)
57728 + return 1;
57729 + else
57730 + return 0;
57731 +}
57732 +
57733 +int
57734 +gr_handle_rawio(const struct inode *inode)
57735 +{
57736 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
57737 + if (inode && S_ISBLK(inode->i_mode) &&
57738 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
57739 + !capable(CAP_SYS_RAWIO))
57740 + return 1;
57741 +#endif
57742 + return 0;
57743 +}
57744 +
57745 +static int
57746 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
57747 +{
57748 + if (likely(lena != lenb))
57749 + return 0;
57750 +
57751 + return !memcmp(a, b, lena);
57752 +}
57753 +
57754 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
57755 +{
57756 + *buflen -= namelen;
57757 + if (*buflen < 0)
57758 + return -ENAMETOOLONG;
57759 + *buffer -= namelen;
57760 + memcpy(*buffer, str, namelen);
57761 + return 0;
57762 +}
57763 +
57764 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
57765 +{
57766 + return prepend(buffer, buflen, name->name, name->len);
57767 +}
57768 +
57769 +static int prepend_path(const struct path *path, struct path *root,
57770 + char **buffer, int *buflen)
57771 +{
57772 + struct dentry *dentry = path->dentry;
57773 + struct vfsmount *vfsmnt = path->mnt;
57774 + struct mount *mnt = real_mount(vfsmnt);
57775 + bool slash = false;
57776 + int error = 0;
57777 +
57778 + while (dentry != root->dentry || vfsmnt != root->mnt) {
57779 + struct dentry * parent;
57780 +
57781 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
57782 + /* Global root? */
57783 + if (!mnt_has_parent(mnt)) {
57784 + goto out;
57785 + }
57786 + dentry = mnt->mnt_mountpoint;
57787 + mnt = mnt->mnt_parent;
57788 + vfsmnt = &mnt->mnt;
57789 + continue;
57790 + }
57791 + parent = dentry->d_parent;
57792 + prefetch(parent);
57793 + spin_lock(&dentry->d_lock);
57794 + error = prepend_name(buffer, buflen, &dentry->d_name);
57795 + spin_unlock(&dentry->d_lock);
57796 + if (!error)
57797 + error = prepend(buffer, buflen, "/", 1);
57798 + if (error)
57799 + break;
57800 +
57801 + slash = true;
57802 + dentry = parent;
57803 + }
57804 +
57805 +out:
57806 + if (!error && !slash)
57807 + error = prepend(buffer, buflen, "/", 1);
57808 +
57809 + return error;
57810 +}
57811 +
57812 +/* this must be called with vfsmount_lock and rename_lock held */
57813 +
57814 +static char *__our_d_path(const struct path *path, struct path *root,
57815 + char *buf, int buflen)
57816 +{
57817 + char *res = buf + buflen;
57818 + int error;
57819 +
57820 + prepend(&res, &buflen, "\0", 1);
57821 + error = prepend_path(path, root, &res, &buflen);
57822 + if (error)
57823 + return ERR_PTR(error);
57824 +
57825 + return res;
57826 +}
57827 +
57828 +static char *
57829 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
57830 +{
57831 + char *retval;
57832 +
57833 + retval = __our_d_path(path, root, buf, buflen);
57834 + if (unlikely(IS_ERR(retval)))
57835 + retval = strcpy(buf, "<path too long>");
57836 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
57837 + retval[1] = '\0';
57838 +
57839 + return retval;
57840 +}
57841 +
57842 +static char *
57843 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57844 + char *buf, int buflen)
57845 +{
57846 + struct path path;
57847 + char *res;
57848 +
57849 + path.dentry = (struct dentry *)dentry;
57850 + path.mnt = (struct vfsmount *)vfsmnt;
57851 +
57852 + /* we can use real_root.dentry, real_root.mnt, because this is only called
57853 + by the RBAC system */
57854 + res = gen_full_path(&path, &real_root, buf, buflen);
57855 +
57856 + return res;
57857 +}
57858 +
57859 +static char *
57860 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57861 + char *buf, int buflen)
57862 +{
57863 + char *res;
57864 + struct path path;
57865 + struct path root;
57866 + struct task_struct *reaper = init_pid_ns.child_reaper;
57867 +
57868 + path.dentry = (struct dentry *)dentry;
57869 + path.mnt = (struct vfsmount *)vfsmnt;
57870 +
57871 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
57872 + get_fs_root(reaper->fs, &root);
57873 +
57874 + br_read_lock(&vfsmount_lock);
57875 + write_seqlock(&rename_lock);
57876 + res = gen_full_path(&path, &root, buf, buflen);
57877 + write_sequnlock(&rename_lock);
57878 + br_read_unlock(&vfsmount_lock);
57879 +
57880 + path_put(&root);
57881 + return res;
57882 +}
57883 +
57884 +static char *
57885 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57886 +{
57887 + char *ret;
57888 + br_read_lock(&vfsmount_lock);
57889 + write_seqlock(&rename_lock);
57890 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57891 + PAGE_SIZE);
57892 + write_sequnlock(&rename_lock);
57893 + br_read_unlock(&vfsmount_lock);
57894 + return ret;
57895 +}
57896 +
57897 +static char *
57898 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57899 +{
57900 + char *ret;
57901 + char *buf;
57902 + int buflen;
57903 +
57904 + br_read_lock(&vfsmount_lock);
57905 + write_seqlock(&rename_lock);
57906 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
57907 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
57908 + buflen = (int)(ret - buf);
57909 + if (buflen >= 5)
57910 + prepend(&ret, &buflen, "/proc", 5);
57911 + else
57912 + ret = strcpy(buf, "<path too long>");
57913 + write_sequnlock(&rename_lock);
57914 + br_read_unlock(&vfsmount_lock);
57915 + return ret;
57916 +}
57917 +
57918 +char *
57919 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
57920 +{
57921 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57922 + PAGE_SIZE);
57923 +}
57924 +
57925 +char *
57926 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
57927 +{
57928 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
57929 + PAGE_SIZE);
57930 +}
57931 +
57932 +char *
57933 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
57934 +{
57935 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
57936 + PAGE_SIZE);
57937 +}
57938 +
57939 +char *
57940 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
57941 +{
57942 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
57943 + PAGE_SIZE);
57944 +}
57945 +
57946 +char *
57947 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
57948 +{
57949 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
57950 + PAGE_SIZE);
57951 +}
57952 +
57953 +__inline__ __u32
57954 +to_gr_audit(const __u32 reqmode)
57955 +{
57956 + /* masks off auditable permission flags, then shifts them to create
57957 + auditing flags, and adds the special case of append auditing if
57958 + we're requesting write */
57959 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
57960 +}
57961 +
57962 +struct acl_subject_label *
57963 +lookup_subject_map(const struct acl_subject_label *userp)
57964 +{
57965 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
57966 + struct subject_map *match;
57967 +
57968 + match = subj_map_set.s_hash[index];
57969 +
57970 + while (match && match->user != userp)
57971 + match = match->next;
57972 +
57973 + if (match != NULL)
57974 + return match->kernel;
57975 + else
57976 + return NULL;
57977 +}
57978 +
57979 +static void
57980 +insert_subj_map_entry(struct subject_map *subjmap)
57981 +{
57982 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
57983 + struct subject_map **curr;
57984 +
57985 + subjmap->prev = NULL;
57986 +
57987 + curr = &subj_map_set.s_hash[index];
57988 + if (*curr != NULL)
57989 + (*curr)->prev = subjmap;
57990 +
57991 + subjmap->next = *curr;
57992 + *curr = subjmap;
57993 +
57994 + return;
57995 +}
57996 +
57997 +static struct acl_role_label *
57998 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
57999 + const gid_t gid)
58000 +{
58001 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58002 + struct acl_role_label *match;
58003 + struct role_allowed_ip *ipp;
58004 + unsigned int x;
58005 + u32 curr_ip = task->signal->curr_ip;
58006 +
58007 + task->signal->saved_ip = curr_ip;
58008 +
58009 + match = acl_role_set.r_hash[index];
58010 +
58011 + while (match) {
58012 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58013 + for (x = 0; x < match->domain_child_num; x++) {
58014 + if (match->domain_children[x] == uid)
58015 + goto found;
58016 + }
58017 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58018 + break;
58019 + match = match->next;
58020 + }
58021 +found:
58022 + if (match == NULL) {
58023 + try_group:
58024 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58025 + match = acl_role_set.r_hash[index];
58026 +
58027 + while (match) {
58028 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58029 + for (x = 0; x < match->domain_child_num; x++) {
58030 + if (match->domain_children[x] == gid)
58031 + goto found2;
58032 + }
58033 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58034 + break;
58035 + match = match->next;
58036 + }
58037 +found2:
58038 + if (match == NULL)
58039 + match = default_role;
58040 + if (match->allowed_ips == NULL)
58041 + return match;
58042 + else {
58043 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58044 + if (likely
58045 + ((ntohl(curr_ip) & ipp->netmask) ==
58046 + (ntohl(ipp->addr) & ipp->netmask)))
58047 + return match;
58048 + }
58049 + match = default_role;
58050 + }
58051 + } else if (match->allowed_ips == NULL) {
58052 + return match;
58053 + } else {
58054 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58055 + if (likely
58056 + ((ntohl(curr_ip) & ipp->netmask) ==
58057 + (ntohl(ipp->addr) & ipp->netmask)))
58058 + return match;
58059 + }
58060 + goto try_group;
58061 + }
58062 +
58063 + return match;
58064 +}
58065 +
58066 +struct acl_subject_label *
58067 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58068 + const struct acl_role_label *role)
58069 +{
58070 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58071 + struct acl_subject_label *match;
58072 +
58073 + match = role->subj_hash[index];
58074 +
58075 + while (match && (match->inode != ino || match->device != dev ||
58076 + (match->mode & GR_DELETED))) {
58077 + match = match->next;
58078 + }
58079 +
58080 + if (match && !(match->mode & GR_DELETED))
58081 + return match;
58082 + else
58083 + return NULL;
58084 +}
58085 +
58086 +struct acl_subject_label *
58087 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58088 + const struct acl_role_label *role)
58089 +{
58090 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58091 + struct acl_subject_label *match;
58092 +
58093 + match = role->subj_hash[index];
58094 +
58095 + while (match && (match->inode != ino || match->device != dev ||
58096 + !(match->mode & GR_DELETED))) {
58097 + match = match->next;
58098 + }
58099 +
58100 + if (match && (match->mode & GR_DELETED))
58101 + return match;
58102 + else
58103 + return NULL;
58104 +}
58105 +
58106 +static struct acl_object_label *
58107 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58108 + const struct acl_subject_label *subj)
58109 +{
58110 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58111 + struct acl_object_label *match;
58112 +
58113 + match = subj->obj_hash[index];
58114 +
58115 + while (match && (match->inode != ino || match->device != dev ||
58116 + (match->mode & GR_DELETED))) {
58117 + match = match->next;
58118 + }
58119 +
58120 + if (match && !(match->mode & GR_DELETED))
58121 + return match;
58122 + else
58123 + return NULL;
58124 +}
58125 +
58126 +static struct acl_object_label *
58127 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58128 + const struct acl_subject_label *subj)
58129 +{
58130 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58131 + struct acl_object_label *match;
58132 +
58133 + match = subj->obj_hash[index];
58134 +
58135 + while (match && (match->inode != ino || match->device != dev ||
58136 + !(match->mode & GR_DELETED))) {
58137 + match = match->next;
58138 + }
58139 +
58140 + if (match && (match->mode & GR_DELETED))
58141 + return match;
58142 +
58143 + match = subj->obj_hash[index];
58144 +
58145 + while (match && (match->inode != ino || match->device != dev ||
58146 + (match->mode & GR_DELETED))) {
58147 + match = match->next;
58148 + }
58149 +
58150 + if (match && !(match->mode & GR_DELETED))
58151 + return match;
58152 + else
58153 + return NULL;
58154 +}
58155 +
58156 +static struct name_entry *
58157 +lookup_name_entry(const char *name)
58158 +{
58159 + unsigned int len = strlen(name);
58160 + unsigned int key = full_name_hash(name, len);
58161 + unsigned int index = key % name_set.n_size;
58162 + struct name_entry *match;
58163 +
58164 + match = name_set.n_hash[index];
58165 +
58166 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58167 + match = match->next;
58168 +
58169 + return match;
58170 +}
58171 +
58172 +static struct name_entry *
58173 +lookup_name_entry_create(const char *name)
58174 +{
58175 + unsigned int len = strlen(name);
58176 + unsigned int key = full_name_hash(name, len);
58177 + unsigned int index = key % name_set.n_size;
58178 + struct name_entry *match;
58179 +
58180 + match = name_set.n_hash[index];
58181 +
58182 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58183 + !match->deleted))
58184 + match = match->next;
58185 +
58186 + if (match && match->deleted)
58187 + return match;
58188 +
58189 + match = name_set.n_hash[index];
58190 +
58191 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58192 + match->deleted))
58193 + match = match->next;
58194 +
58195 + if (match && !match->deleted)
58196 + return match;
58197 + else
58198 + return NULL;
58199 +}
58200 +
58201 +static struct inodev_entry *
58202 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58203 +{
58204 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58205 + struct inodev_entry *match;
58206 +
58207 + match = inodev_set.i_hash[index];
58208 +
58209 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58210 + match = match->next;
58211 +
58212 + return match;
58213 +}
58214 +
58215 +static void
58216 +insert_inodev_entry(struct inodev_entry *entry)
58217 +{
58218 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58219 + inodev_set.i_size);
58220 + struct inodev_entry **curr;
58221 +
58222 + entry->prev = NULL;
58223 +
58224 + curr = &inodev_set.i_hash[index];
58225 + if (*curr != NULL)
58226 + (*curr)->prev = entry;
58227 +
58228 + entry->next = *curr;
58229 + *curr = entry;
58230 +
58231 + return;
58232 +}
58233 +
58234 +static void
58235 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58236 +{
58237 + unsigned int index =
58238 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58239 + struct acl_role_label **curr;
58240 + struct acl_role_label *tmp, *tmp2;
58241 +
58242 + curr = &acl_role_set.r_hash[index];
58243 +
58244 + /* simple case, slot is empty, just set it to our role */
58245 + if (*curr == NULL) {
58246 + *curr = role;
58247 + } else {
58248 + /* example:
58249 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58250 + 2 -> 3
58251 + */
58252 + /* first check to see if we can already be reached via this slot */
58253 + tmp = *curr;
58254 + while (tmp && tmp != role)
58255 + tmp = tmp->next;
58256 + if (tmp == role) {
58257 + /* we don't need to add ourselves to this slot's chain */
58258 + return;
58259 + }
58260 + /* we need to add ourselves to this chain, two cases */
58261 + if (role->next == NULL) {
58262 + /* simple case, append the current chain to our role */
58263 + role->next = *curr;
58264 + *curr = role;
58265 + } else {
58266 + /* 1 -> 2 -> 3 -> 4
58267 + 2 -> 3 -> 4
58268 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58269 + */
58270 + /* trickier case: walk our role's chain until we find
58271 + the role for the start of the current slot's chain */
58272 + tmp = role;
58273 + tmp2 = *curr;
58274 + while (tmp->next && tmp->next != tmp2)
58275 + tmp = tmp->next;
58276 + if (tmp->next == tmp2) {
58277 + /* from example above, we found 3, so just
58278 + replace this slot's chain with ours */
58279 + *curr = role;
58280 + } else {
58281 + /* we didn't find a subset of our role's chain
58282 + in the current slot's chain, so append their
58283 + chain to ours, and set us as the first role in
58284 + the slot's chain
58285 +
58286 + we could fold this case with the case above,
58287 + but making it explicit for clarity
58288 + */
58289 + tmp->next = tmp2;
58290 + *curr = role;
58291 + }
58292 + }
58293 + }
58294 +
58295 + return;
58296 +}
58297 +
58298 +static void
58299 +insert_acl_role_label(struct acl_role_label *role)
58300 +{
58301 + int i;
58302 +
58303 + if (role_list == NULL) {
58304 + role_list = role;
58305 + role->prev = NULL;
58306 + } else {
58307 + role->prev = role_list;
58308 + role_list = role;
58309 + }
58310 +
58311 + /* used for hash chains */
58312 + role->next = NULL;
58313 +
58314 + if (role->roletype & GR_ROLE_DOMAIN) {
58315 + for (i = 0; i < role->domain_child_num; i++)
58316 + __insert_acl_role_label(role, role->domain_children[i]);
58317 + } else
58318 + __insert_acl_role_label(role, role->uidgid);
58319 +}
58320 +
58321 +static int
58322 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58323 +{
58324 + struct name_entry **curr, *nentry;
58325 + struct inodev_entry *ientry;
58326 + unsigned int len = strlen(name);
58327 + unsigned int key = full_name_hash(name, len);
58328 + unsigned int index = key % name_set.n_size;
58329 +
58330 + curr = &name_set.n_hash[index];
58331 +
58332 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58333 + curr = &((*curr)->next);
58334 +
58335 + if (*curr != NULL)
58336 + return 1;
58337 +
58338 + nentry = acl_alloc(sizeof (struct name_entry));
58339 + if (nentry == NULL)
58340 + return 0;
58341 + ientry = acl_alloc(sizeof (struct inodev_entry));
58342 + if (ientry == NULL)
58343 + return 0;
58344 + ientry->nentry = nentry;
58345 +
58346 + nentry->key = key;
58347 + nentry->name = name;
58348 + nentry->inode = inode;
58349 + nentry->device = device;
58350 + nentry->len = len;
58351 + nentry->deleted = deleted;
58352 +
58353 + nentry->prev = NULL;
58354 + curr = &name_set.n_hash[index];
58355 + if (*curr != NULL)
58356 + (*curr)->prev = nentry;
58357 + nentry->next = *curr;
58358 + *curr = nentry;
58359 +
58360 + /* insert us into the table searchable by inode/dev */
58361 + insert_inodev_entry(ientry);
58362 +
58363 + return 1;
58364 +}
58365 +
58366 +static void
58367 +insert_acl_obj_label(struct acl_object_label *obj,
58368 + struct acl_subject_label *subj)
58369 +{
58370 + unsigned int index =
58371 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58372 + struct acl_object_label **curr;
58373 +
58374 +
58375 + obj->prev = NULL;
58376 +
58377 + curr = &subj->obj_hash[index];
58378 + if (*curr != NULL)
58379 + (*curr)->prev = obj;
58380 +
58381 + obj->next = *curr;
58382 + *curr = obj;
58383 +
58384 + return;
58385 +}
58386 +
58387 +static void
58388 +insert_acl_subj_label(struct acl_subject_label *obj,
58389 + struct acl_role_label *role)
58390 +{
58391 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58392 + struct acl_subject_label **curr;
58393 +
58394 + obj->prev = NULL;
58395 +
58396 + curr = &role->subj_hash[index];
58397 + if (*curr != NULL)
58398 + (*curr)->prev = obj;
58399 +
58400 + obj->next = *curr;
58401 + *curr = obj;
58402 +
58403 + return;
58404 +}
58405 +
58406 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58407 +
58408 +static void *
58409 +create_table(__u32 * len, int elementsize)
58410 +{
58411 + unsigned int table_sizes[] = {
58412 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58413 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58414 + 4194301, 8388593, 16777213, 33554393, 67108859
58415 + };
58416 + void *newtable = NULL;
58417 + unsigned int pwr = 0;
58418 +
58419 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58420 + table_sizes[pwr] <= *len)
58421 + pwr++;
58422 +
58423 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58424 + return newtable;
58425 +
58426 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58427 + newtable =
58428 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58429 + else
58430 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58431 +
58432 + *len = table_sizes[pwr];
58433 +
58434 + return newtable;
58435 +}
58436 +
58437 +static int
58438 +init_variables(const struct gr_arg *arg)
58439 +{
58440 + struct task_struct *reaper = init_pid_ns.child_reaper;
58441 + unsigned int stacksize;
58442 +
58443 + subj_map_set.s_size = arg->role_db.num_subjects;
58444 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58445 + name_set.n_size = arg->role_db.num_objects;
58446 + inodev_set.i_size = arg->role_db.num_objects;
58447 +
58448 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58449 + !name_set.n_size || !inodev_set.i_size)
58450 + return 1;
58451 +
58452 + if (!gr_init_uidset())
58453 + return 1;
58454 +
58455 + /* set up the stack that holds allocation info */
58456 +
58457 + stacksize = arg->role_db.num_pointers + 5;
58458 +
58459 + if (!acl_alloc_stack_init(stacksize))
58460 + return 1;
58461 +
58462 + /* grab reference for the real root dentry and vfsmount */
58463 + get_fs_root(reaper->fs, &real_root);
58464 +
58465 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58466 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58467 +#endif
58468 +
58469 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58470 + if (fakefs_obj_rw == NULL)
58471 + return 1;
58472 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58473 +
58474 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58475 + if (fakefs_obj_rwx == NULL)
58476 + return 1;
58477 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58478 +
58479 + subj_map_set.s_hash =
58480 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58481 + acl_role_set.r_hash =
58482 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58483 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58484 + inodev_set.i_hash =
58485 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58486 +
58487 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58488 + !name_set.n_hash || !inodev_set.i_hash)
58489 + return 1;
58490 +
58491 + memset(subj_map_set.s_hash, 0,
58492 + sizeof(struct subject_map *) * subj_map_set.s_size);
58493 + memset(acl_role_set.r_hash, 0,
58494 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
58495 + memset(name_set.n_hash, 0,
58496 + sizeof (struct name_entry *) * name_set.n_size);
58497 + memset(inodev_set.i_hash, 0,
58498 + sizeof (struct inodev_entry *) * inodev_set.i_size);
58499 +
58500 + return 0;
58501 +}
58502 +
58503 +/* free information not needed after startup
58504 + currently contains user->kernel pointer mappings for subjects
58505 +*/
58506 +
58507 +static void
58508 +free_init_variables(void)
58509 +{
58510 + __u32 i;
58511 +
58512 + if (subj_map_set.s_hash) {
58513 + for (i = 0; i < subj_map_set.s_size; i++) {
58514 + if (subj_map_set.s_hash[i]) {
58515 + kfree(subj_map_set.s_hash[i]);
58516 + subj_map_set.s_hash[i] = NULL;
58517 + }
58518 + }
58519 +
58520 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
58521 + PAGE_SIZE)
58522 + kfree(subj_map_set.s_hash);
58523 + else
58524 + vfree(subj_map_set.s_hash);
58525 + }
58526 +
58527 + return;
58528 +}
58529 +
58530 +static void
58531 +free_variables(void)
58532 +{
58533 + struct acl_subject_label *s;
58534 + struct acl_role_label *r;
58535 + struct task_struct *task, *task2;
58536 + unsigned int x;
58537 +
58538 + gr_clear_learn_entries();
58539 +
58540 + read_lock(&tasklist_lock);
58541 + do_each_thread(task2, task) {
58542 + task->acl_sp_role = 0;
58543 + task->acl_role_id = 0;
58544 + task->acl = NULL;
58545 + task->role = NULL;
58546 + } while_each_thread(task2, task);
58547 + read_unlock(&tasklist_lock);
58548 +
58549 + /* release the reference to the real root dentry and vfsmount */
58550 + path_put(&real_root);
58551 + memset(&real_root, 0, sizeof(real_root));
58552 +
58553 + /* free all object hash tables */
58554 +
58555 + FOR_EACH_ROLE_START(r)
58556 + if (r->subj_hash == NULL)
58557 + goto next_role;
58558 + FOR_EACH_SUBJECT_START(r, s, x)
58559 + if (s->obj_hash == NULL)
58560 + break;
58561 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58562 + kfree(s->obj_hash);
58563 + else
58564 + vfree(s->obj_hash);
58565 + FOR_EACH_SUBJECT_END(s, x)
58566 + FOR_EACH_NESTED_SUBJECT_START(r, s)
58567 + if (s->obj_hash == NULL)
58568 + break;
58569 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58570 + kfree(s->obj_hash);
58571 + else
58572 + vfree(s->obj_hash);
58573 + FOR_EACH_NESTED_SUBJECT_END(s)
58574 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
58575 + kfree(r->subj_hash);
58576 + else
58577 + vfree(r->subj_hash);
58578 + r->subj_hash = NULL;
58579 +next_role:
58580 + FOR_EACH_ROLE_END(r)
58581 +
58582 + acl_free_all();
58583 +
58584 + if (acl_role_set.r_hash) {
58585 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
58586 + PAGE_SIZE)
58587 + kfree(acl_role_set.r_hash);
58588 + else
58589 + vfree(acl_role_set.r_hash);
58590 + }
58591 + if (name_set.n_hash) {
58592 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
58593 + PAGE_SIZE)
58594 + kfree(name_set.n_hash);
58595 + else
58596 + vfree(name_set.n_hash);
58597 + }
58598 +
58599 + if (inodev_set.i_hash) {
58600 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
58601 + PAGE_SIZE)
58602 + kfree(inodev_set.i_hash);
58603 + else
58604 + vfree(inodev_set.i_hash);
58605 + }
58606 +
58607 + gr_free_uidset();
58608 +
58609 + memset(&name_set, 0, sizeof (struct name_db));
58610 + memset(&inodev_set, 0, sizeof (struct inodev_db));
58611 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
58612 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
58613 +
58614 + default_role = NULL;
58615 + kernel_role = NULL;
58616 + role_list = NULL;
58617 +
58618 + return;
58619 +}
58620 +
58621 +static __u32
58622 +count_user_objs(struct acl_object_label *userp)
58623 +{
58624 + struct acl_object_label o_tmp;
58625 + __u32 num = 0;
58626 +
58627 + while (userp) {
58628 + if (copy_from_user(&o_tmp, userp,
58629 + sizeof (struct acl_object_label)))
58630 + break;
58631 +
58632 + userp = o_tmp.prev;
58633 + num++;
58634 + }
58635 +
58636 + return num;
58637 +}
58638 +
58639 +static struct acl_subject_label *
58640 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
58641 +
58642 +static int
58643 +copy_user_glob(struct acl_object_label *obj)
58644 +{
58645 + struct acl_object_label *g_tmp, **guser;
58646 + unsigned int len;
58647 + char *tmp;
58648 +
58649 + if (obj->globbed == NULL)
58650 + return 0;
58651 +
58652 + guser = &obj->globbed;
58653 + while (*guser) {
58654 + g_tmp = (struct acl_object_label *)
58655 + acl_alloc(sizeof (struct acl_object_label));
58656 + if (g_tmp == NULL)
58657 + return -ENOMEM;
58658 +
58659 + if (copy_from_user(g_tmp, *guser,
58660 + sizeof (struct acl_object_label)))
58661 + return -EFAULT;
58662 +
58663 + len = strnlen_user(g_tmp->filename, PATH_MAX);
58664 +
58665 + if (!len || len >= PATH_MAX)
58666 + return -EINVAL;
58667 +
58668 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58669 + return -ENOMEM;
58670 +
58671 + if (copy_from_user(tmp, g_tmp->filename, len))
58672 + return -EFAULT;
58673 + tmp[len-1] = '\0';
58674 + g_tmp->filename = tmp;
58675 +
58676 + *guser = g_tmp;
58677 + guser = &(g_tmp->next);
58678 + }
58679 +
58680 + return 0;
58681 +}
58682 +
58683 +static int
58684 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
58685 + struct acl_role_label *role)
58686 +{
58687 + struct acl_object_label *o_tmp;
58688 + unsigned int len;
58689 + int ret;
58690 + char *tmp;
58691 +
58692 + while (userp) {
58693 + if ((o_tmp = (struct acl_object_label *)
58694 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
58695 + return -ENOMEM;
58696 +
58697 + if (copy_from_user(o_tmp, userp,
58698 + sizeof (struct acl_object_label)))
58699 + return -EFAULT;
58700 +
58701 + userp = o_tmp->prev;
58702 +
58703 + len = strnlen_user(o_tmp->filename, PATH_MAX);
58704 +
58705 + if (!len || len >= PATH_MAX)
58706 + return -EINVAL;
58707 +
58708 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58709 + return -ENOMEM;
58710 +
58711 + if (copy_from_user(tmp, o_tmp->filename, len))
58712 + return -EFAULT;
58713 + tmp[len-1] = '\0';
58714 + o_tmp->filename = tmp;
58715 +
58716 + insert_acl_obj_label(o_tmp, subj);
58717 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
58718 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
58719 + return -ENOMEM;
58720 +
58721 + ret = copy_user_glob(o_tmp);
58722 + if (ret)
58723 + return ret;
58724 +
58725 + if (o_tmp->nested) {
58726 + int already_copied;
58727 +
58728 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
58729 + if (IS_ERR(o_tmp->nested))
58730 + return PTR_ERR(o_tmp->nested);
58731 +
58732 + /* insert into nested subject list if we haven't copied this one yet
58733 + to prevent duplicate entries */
58734 + if (!already_copied) {
58735 + o_tmp->nested->next = role->hash->first;
58736 + role->hash->first = o_tmp->nested;
58737 + }
58738 + }
58739 + }
58740 +
58741 + return 0;
58742 +}
58743 +
58744 +static __u32
58745 +count_user_subjs(struct acl_subject_label *userp)
58746 +{
58747 + struct acl_subject_label s_tmp;
58748 + __u32 num = 0;
58749 +
58750 + while (userp) {
58751 + if (copy_from_user(&s_tmp, userp,
58752 + sizeof (struct acl_subject_label)))
58753 + break;
58754 +
58755 + userp = s_tmp.prev;
58756 + }
58757 +
58758 + return num;
58759 +}
58760 +
58761 +static int
58762 +copy_user_allowedips(struct acl_role_label *rolep)
58763 +{
58764 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
58765 +
58766 + ruserip = rolep->allowed_ips;
58767 +
58768 + while (ruserip) {
58769 + rlast = rtmp;
58770 +
58771 + if ((rtmp = (struct role_allowed_ip *)
58772 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
58773 + return -ENOMEM;
58774 +
58775 + if (copy_from_user(rtmp, ruserip,
58776 + sizeof (struct role_allowed_ip)))
58777 + return -EFAULT;
58778 +
58779 + ruserip = rtmp->prev;
58780 +
58781 + if (!rlast) {
58782 + rtmp->prev = NULL;
58783 + rolep->allowed_ips = rtmp;
58784 + } else {
58785 + rlast->next = rtmp;
58786 + rtmp->prev = rlast;
58787 + }
58788 +
58789 + if (!ruserip)
58790 + rtmp->next = NULL;
58791 + }
58792 +
58793 + return 0;
58794 +}
58795 +
58796 +static int
58797 +copy_user_transitions(struct acl_role_label *rolep)
58798 +{
58799 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
58800 +
58801 + unsigned int len;
58802 + char *tmp;
58803 +
58804 + rusertp = rolep->transitions;
58805 +
58806 + while (rusertp) {
58807 + rlast = rtmp;
58808 +
58809 + if ((rtmp = (struct role_transition *)
58810 + acl_alloc(sizeof (struct role_transition))) == NULL)
58811 + return -ENOMEM;
58812 +
58813 + if (copy_from_user(rtmp, rusertp,
58814 + sizeof (struct role_transition)))
58815 + return -EFAULT;
58816 +
58817 + rusertp = rtmp->prev;
58818 +
58819 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
58820 +
58821 + if (!len || len >= GR_SPROLE_LEN)
58822 + return -EINVAL;
58823 +
58824 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58825 + return -ENOMEM;
58826 +
58827 + if (copy_from_user(tmp, rtmp->rolename, len))
58828 + return -EFAULT;
58829 + tmp[len-1] = '\0';
58830 + rtmp->rolename = tmp;
58831 +
58832 + if (!rlast) {
58833 + rtmp->prev = NULL;
58834 + rolep->transitions = rtmp;
58835 + } else {
58836 + rlast->next = rtmp;
58837 + rtmp->prev = rlast;
58838 + }
58839 +
58840 + if (!rusertp)
58841 + rtmp->next = NULL;
58842 + }
58843 +
58844 + return 0;
58845 +}
58846 +
58847 +static struct acl_subject_label *
58848 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
58849 +{
58850 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
58851 + unsigned int len;
58852 + char *tmp;
58853 + __u32 num_objs;
58854 + struct acl_ip_label **i_tmp, *i_utmp2;
58855 + struct gr_hash_struct ghash;
58856 + struct subject_map *subjmap;
58857 + unsigned int i_num;
58858 + int err;
58859 +
58860 + if (already_copied != NULL)
58861 + *already_copied = 0;
58862 +
58863 + s_tmp = lookup_subject_map(userp);
58864 +
58865 + /* we've already copied this subject into the kernel, just return
58866 + the reference to it, and don't copy it over again
58867 + */
58868 + if (s_tmp) {
58869 + if (already_copied != NULL)
58870 + *already_copied = 1;
58871 + return(s_tmp);
58872 + }
58873 +
58874 + if ((s_tmp = (struct acl_subject_label *)
58875 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
58876 + return ERR_PTR(-ENOMEM);
58877 +
58878 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
58879 + if (subjmap == NULL)
58880 + return ERR_PTR(-ENOMEM);
58881 +
58882 + subjmap->user = userp;
58883 + subjmap->kernel = s_tmp;
58884 + insert_subj_map_entry(subjmap);
58885 +
58886 + if (copy_from_user(s_tmp, userp,
58887 + sizeof (struct acl_subject_label)))
58888 + return ERR_PTR(-EFAULT);
58889 +
58890 + len = strnlen_user(s_tmp->filename, PATH_MAX);
58891 +
58892 + if (!len || len >= PATH_MAX)
58893 + return ERR_PTR(-EINVAL);
58894 +
58895 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58896 + return ERR_PTR(-ENOMEM);
58897 +
58898 + if (copy_from_user(tmp, s_tmp->filename, len))
58899 + return ERR_PTR(-EFAULT);
58900 + tmp[len-1] = '\0';
58901 + s_tmp->filename = tmp;
58902 +
58903 + if (!strcmp(s_tmp->filename, "/"))
58904 + role->root_label = s_tmp;
58905 +
58906 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
58907 + return ERR_PTR(-EFAULT);
58908 +
58909 + /* copy user and group transition tables */
58910 +
58911 + if (s_tmp->user_trans_num) {
58912 + uid_t *uidlist;
58913 +
58914 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
58915 + if (uidlist == NULL)
58916 + return ERR_PTR(-ENOMEM);
58917 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
58918 + return ERR_PTR(-EFAULT);
58919 +
58920 + s_tmp->user_transitions = uidlist;
58921 + }
58922 +
58923 + if (s_tmp->group_trans_num) {
58924 + gid_t *gidlist;
58925 +
58926 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
58927 + if (gidlist == NULL)
58928 + return ERR_PTR(-ENOMEM);
58929 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
58930 + return ERR_PTR(-EFAULT);
58931 +
58932 + s_tmp->group_transitions = gidlist;
58933 + }
58934 +
58935 + /* set up object hash table */
58936 + num_objs = count_user_objs(ghash.first);
58937 +
58938 + s_tmp->obj_hash_size = num_objs;
58939 + s_tmp->obj_hash =
58940 + (struct acl_object_label **)
58941 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
58942 +
58943 + if (!s_tmp->obj_hash)
58944 + return ERR_PTR(-ENOMEM);
58945 +
58946 + memset(s_tmp->obj_hash, 0,
58947 + s_tmp->obj_hash_size *
58948 + sizeof (struct acl_object_label *));
58949 +
58950 + /* add in objects */
58951 + err = copy_user_objs(ghash.first, s_tmp, role);
58952 +
58953 + if (err)
58954 + return ERR_PTR(err);
58955 +
58956 + /* set pointer for parent subject */
58957 + if (s_tmp->parent_subject) {
58958 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
58959 +
58960 + if (IS_ERR(s_tmp2))
58961 + return s_tmp2;
58962 +
58963 + s_tmp->parent_subject = s_tmp2;
58964 + }
58965 +
58966 + /* add in ip acls */
58967 +
58968 + if (!s_tmp->ip_num) {
58969 + s_tmp->ips = NULL;
58970 + goto insert;
58971 + }
58972 +
58973 + i_tmp =
58974 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
58975 + sizeof (struct acl_ip_label *));
58976 +
58977 + if (!i_tmp)
58978 + return ERR_PTR(-ENOMEM);
58979 +
58980 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
58981 + *(i_tmp + i_num) =
58982 + (struct acl_ip_label *)
58983 + acl_alloc(sizeof (struct acl_ip_label));
58984 + if (!*(i_tmp + i_num))
58985 + return ERR_PTR(-ENOMEM);
58986 +
58987 + if (copy_from_user
58988 + (&i_utmp2, s_tmp->ips + i_num,
58989 + sizeof (struct acl_ip_label *)))
58990 + return ERR_PTR(-EFAULT);
58991 +
58992 + if (copy_from_user
58993 + (*(i_tmp + i_num), i_utmp2,
58994 + sizeof (struct acl_ip_label)))
58995 + return ERR_PTR(-EFAULT);
58996 +
58997 + if ((*(i_tmp + i_num))->iface == NULL)
58998 + continue;
58999 +
59000 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59001 + if (!len || len >= IFNAMSIZ)
59002 + return ERR_PTR(-EINVAL);
59003 + tmp = acl_alloc(len);
59004 + if (tmp == NULL)
59005 + return ERR_PTR(-ENOMEM);
59006 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59007 + return ERR_PTR(-EFAULT);
59008 + (*(i_tmp + i_num))->iface = tmp;
59009 + }
59010 +
59011 + s_tmp->ips = i_tmp;
59012 +
59013 +insert:
59014 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59015 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59016 + return ERR_PTR(-ENOMEM);
59017 +
59018 + return s_tmp;
59019 +}
59020 +
59021 +static int
59022 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59023 +{
59024 + struct acl_subject_label s_pre;
59025 + struct acl_subject_label * ret;
59026 + int err;
59027 +
59028 + while (userp) {
59029 + if (copy_from_user(&s_pre, userp,
59030 + sizeof (struct acl_subject_label)))
59031 + return -EFAULT;
59032 +
59033 + ret = do_copy_user_subj(userp, role, NULL);
59034 +
59035 + err = PTR_ERR(ret);
59036 + if (IS_ERR(ret))
59037 + return err;
59038 +
59039 + insert_acl_subj_label(ret, role);
59040 +
59041 + userp = s_pre.prev;
59042 + }
59043 +
59044 + return 0;
59045 +}
59046 +
59047 +static int
59048 +copy_user_acl(struct gr_arg *arg)
59049 +{
59050 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59051 + struct acl_subject_label *subj_list;
59052 + struct sprole_pw *sptmp;
59053 + struct gr_hash_struct *ghash;
59054 + uid_t *domainlist;
59055 + unsigned int r_num;
59056 + unsigned int len;
59057 + char *tmp;
59058 + int err = 0;
59059 + __u16 i;
59060 + __u32 num_subjs;
59061 +
59062 + /* we need a default and kernel role */
59063 + if (arg->role_db.num_roles < 2)
59064 + return -EINVAL;
59065 +
59066 + /* copy special role authentication info from userspace */
59067 +
59068 + num_sprole_pws = arg->num_sprole_pws;
59069 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59070 +
59071 + if (!acl_special_roles && num_sprole_pws)
59072 + return -ENOMEM;
59073 +
59074 + for (i = 0; i < num_sprole_pws; i++) {
59075 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59076 + if (!sptmp)
59077 + return -ENOMEM;
59078 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59079 + sizeof (struct sprole_pw)))
59080 + return -EFAULT;
59081 +
59082 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59083 +
59084 + if (!len || len >= GR_SPROLE_LEN)
59085 + return -EINVAL;
59086 +
59087 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59088 + return -ENOMEM;
59089 +
59090 + if (copy_from_user(tmp, sptmp->rolename, len))
59091 + return -EFAULT;
59092 +
59093 + tmp[len-1] = '\0';
59094 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59095 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59096 +#endif
59097 + sptmp->rolename = tmp;
59098 + acl_special_roles[i] = sptmp;
59099 + }
59100 +
59101 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59102 +
59103 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59104 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59105 +
59106 + if (!r_tmp)
59107 + return -ENOMEM;
59108 +
59109 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59110 + sizeof (struct acl_role_label *)))
59111 + return -EFAULT;
59112 +
59113 + if (copy_from_user(r_tmp, r_utmp2,
59114 + sizeof (struct acl_role_label)))
59115 + return -EFAULT;
59116 +
59117 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59118 +
59119 + if (!len || len >= PATH_MAX)
59120 + return -EINVAL;
59121 +
59122 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59123 + return -ENOMEM;
59124 +
59125 + if (copy_from_user(tmp, r_tmp->rolename, len))
59126 + return -EFAULT;
59127 +
59128 + tmp[len-1] = '\0';
59129 + r_tmp->rolename = tmp;
59130 +
59131 + if (!strcmp(r_tmp->rolename, "default")
59132 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59133 + default_role = r_tmp;
59134 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59135 + kernel_role = r_tmp;
59136 + }
59137 +
59138 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59139 + return -ENOMEM;
59140 +
59141 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59142 + return -EFAULT;
59143 +
59144 + r_tmp->hash = ghash;
59145 +
59146 + num_subjs = count_user_subjs(r_tmp->hash->first);
59147 +
59148 + r_tmp->subj_hash_size = num_subjs;
59149 + r_tmp->subj_hash =
59150 + (struct acl_subject_label **)
59151 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59152 +
59153 + if (!r_tmp->subj_hash)
59154 + return -ENOMEM;
59155 +
59156 + err = copy_user_allowedips(r_tmp);
59157 + if (err)
59158 + return err;
59159 +
59160 + /* copy domain info */
59161 + if (r_tmp->domain_children != NULL) {
59162 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59163 + if (domainlist == NULL)
59164 + return -ENOMEM;
59165 +
59166 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59167 + return -EFAULT;
59168 +
59169 + r_tmp->domain_children = domainlist;
59170 + }
59171 +
59172 + err = copy_user_transitions(r_tmp);
59173 + if (err)
59174 + return err;
59175 +
59176 + memset(r_tmp->subj_hash, 0,
59177 + r_tmp->subj_hash_size *
59178 + sizeof (struct acl_subject_label *));
59179 +
59180 + /* acquire the list of subjects, then NULL out
59181 + the list prior to parsing the subjects for this role,
59182 + as during this parsing the list is replaced with a list
59183 + of *nested* subjects for the role
59184 + */
59185 + subj_list = r_tmp->hash->first;
59186 +
59187 + /* set nested subject list to null */
59188 + r_tmp->hash->first = NULL;
59189 +
59190 + err = copy_user_subjs(subj_list, r_tmp);
59191 +
59192 + if (err)
59193 + return err;
59194 +
59195 + insert_acl_role_label(r_tmp);
59196 + }
59197 +
59198 + if (default_role == NULL || kernel_role == NULL)
59199 + return -EINVAL;
59200 +
59201 + return err;
59202 +}
59203 +
59204 +static int
59205 +gracl_init(struct gr_arg *args)
59206 +{
59207 + int error = 0;
59208 +
59209 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59210 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59211 +
59212 + if (init_variables(args)) {
59213 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59214 + error = -ENOMEM;
59215 + free_variables();
59216 + goto out;
59217 + }
59218 +
59219 + error = copy_user_acl(args);
59220 + free_init_variables();
59221 + if (error) {
59222 + free_variables();
59223 + goto out;
59224 + }
59225 +
59226 + if ((error = gr_set_acls(0))) {
59227 + free_variables();
59228 + goto out;
59229 + }
59230 +
59231 + pax_open_kernel();
59232 + gr_status |= GR_READY;
59233 + pax_close_kernel();
59234 +
59235 + out:
59236 + return error;
59237 +}
59238 +
59239 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59240 +
59241 +static int
59242 +glob_match(const char *p, const char *n)
59243 +{
59244 + char c;
59245 +
59246 + while ((c = *p++) != '\0') {
59247 + switch (c) {
59248 + case '?':
59249 + if (*n == '\0')
59250 + return 1;
59251 + else if (*n == '/')
59252 + return 1;
59253 + break;
59254 + case '\\':
59255 + if (*n != c)
59256 + return 1;
59257 + break;
59258 + case '*':
59259 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59260 + if (*n == '/')
59261 + return 1;
59262 + else if (c == '?') {
59263 + if (*n == '\0')
59264 + return 1;
59265 + else
59266 + ++n;
59267 + }
59268 + }
59269 + if (c == '\0') {
59270 + return 0;
59271 + } else {
59272 + const char *endp;
59273 +
59274 + if ((endp = strchr(n, '/')) == NULL)
59275 + endp = n + strlen(n);
59276 +
59277 + if (c == '[') {
59278 + for (--p; n < endp; ++n)
59279 + if (!glob_match(p, n))
59280 + return 0;
59281 + } else if (c == '/') {
59282 + while (*n != '\0' && *n != '/')
59283 + ++n;
59284 + if (*n == '/' && !glob_match(p, n + 1))
59285 + return 0;
59286 + } else {
59287 + for (--p; n < endp; ++n)
59288 + if (*n == c && !glob_match(p, n))
59289 + return 0;
59290 + }
59291 +
59292 + return 1;
59293 + }
59294 + case '[':
59295 + {
59296 + int not;
59297 + char cold;
59298 +
59299 + if (*n == '\0' || *n == '/')
59300 + return 1;
59301 +
59302 + not = (*p == '!' || *p == '^');
59303 + if (not)
59304 + ++p;
59305 +
59306 + c = *p++;
59307 + for (;;) {
59308 + unsigned char fn = (unsigned char)*n;
59309 +
59310 + if (c == '\0')
59311 + return 1;
59312 + else {
59313 + if (c == fn)
59314 + goto matched;
59315 + cold = c;
59316 + c = *p++;
59317 +
59318 + if (c == '-' && *p != ']') {
59319 + unsigned char cend = *p++;
59320 +
59321 + if (cend == '\0')
59322 + return 1;
59323 +
59324 + if (cold <= fn && fn <= cend)
59325 + goto matched;
59326 +
59327 + c = *p++;
59328 + }
59329 + }
59330 +
59331 + if (c == ']')
59332 + break;
59333 + }
59334 + if (!not)
59335 + return 1;
59336 + break;
59337 + matched:
59338 + while (c != ']') {
59339 + if (c == '\0')
59340 + return 1;
59341 +
59342 + c = *p++;
59343 + }
59344 + if (not)
59345 + return 1;
59346 + }
59347 + break;
59348 + default:
59349 + if (c != *n)
59350 + return 1;
59351 + }
59352 +
59353 + ++n;
59354 + }
59355 +
59356 + if (*n == '\0')
59357 + return 0;
59358 +
59359 + if (*n == '/')
59360 + return 0;
59361 +
59362 + return 1;
59363 +}
59364 +
59365 +static struct acl_object_label *
59366 +chk_glob_label(struct acl_object_label *globbed,
59367 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59368 +{
59369 + struct acl_object_label *tmp;
59370 +
59371 + if (*path == NULL)
59372 + *path = gr_to_filename_nolock(dentry, mnt);
59373 +
59374 + tmp = globbed;
59375 +
59376 + while (tmp) {
59377 + if (!glob_match(tmp->filename, *path))
59378 + return tmp;
59379 + tmp = tmp->next;
59380 + }
59381 +
59382 + return NULL;
59383 +}
59384 +
59385 +static struct acl_object_label *
59386 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59387 + const ino_t curr_ino, const dev_t curr_dev,
59388 + const struct acl_subject_label *subj, char **path, const int checkglob)
59389 +{
59390 + struct acl_subject_label *tmpsubj;
59391 + struct acl_object_label *retval;
59392 + struct acl_object_label *retval2;
59393 +
59394 + tmpsubj = (struct acl_subject_label *) subj;
59395 + read_lock(&gr_inode_lock);
59396 + do {
59397 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59398 + if (retval) {
59399 + if (checkglob && retval->globbed) {
59400 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59401 + if (retval2)
59402 + retval = retval2;
59403 + }
59404 + break;
59405 + }
59406 + } while ((tmpsubj = tmpsubj->parent_subject));
59407 + read_unlock(&gr_inode_lock);
59408 +
59409 + return retval;
59410 +}
59411 +
59412 +static __inline__ struct acl_object_label *
59413 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59414 + struct dentry *curr_dentry,
59415 + const struct acl_subject_label *subj, char **path, const int checkglob)
59416 +{
59417 + int newglob = checkglob;
59418 + ino_t inode;
59419 + dev_t device;
59420 +
59421 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59422 + as we don't want a / * rule to match instead of the / object
59423 + don't do this for create lookups that call this function though, since they're looking up
59424 + on the parent and thus need globbing checks on all paths
59425 + */
59426 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59427 + newglob = GR_NO_GLOB;
59428 +
59429 + spin_lock(&curr_dentry->d_lock);
59430 + inode = curr_dentry->d_inode->i_ino;
59431 + device = __get_dev(curr_dentry);
59432 + spin_unlock(&curr_dentry->d_lock);
59433 +
59434 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59435 +}
59436 +
59437 +#ifdef CONFIG_HUGETLBFS
59438 +static inline bool
59439 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59440 +{
59441 + int i;
59442 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59443 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59444 + return true;
59445 + }
59446 +
59447 + return false;
59448 +}
59449 +#endif
59450 +
59451 +static struct acl_object_label *
59452 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59453 + const struct acl_subject_label *subj, char *path, const int checkglob)
59454 +{
59455 + struct dentry *dentry = (struct dentry *) l_dentry;
59456 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59457 + struct mount *real_mnt = real_mount(mnt);
59458 + struct acl_object_label *retval;
59459 + struct dentry *parent;
59460 +
59461 + br_read_lock(&vfsmount_lock);
59462 + write_seqlock(&rename_lock);
59463 +
59464 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59465 +#ifdef CONFIG_NET
59466 + mnt == sock_mnt ||
59467 +#endif
59468 +#ifdef CONFIG_HUGETLBFS
59469 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59470 +#endif
59471 + /* ignore Eric Biederman */
59472 + IS_PRIVATE(l_dentry->d_inode))) {
59473 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59474 + goto out;
59475 + }
59476 +
59477 + for (;;) {
59478 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59479 + break;
59480 +
59481 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59482 + if (!mnt_has_parent(real_mnt))
59483 + break;
59484 +
59485 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59486 + if (retval != NULL)
59487 + goto out;
59488 +
59489 + dentry = real_mnt->mnt_mountpoint;
59490 + real_mnt = real_mnt->mnt_parent;
59491 + mnt = &real_mnt->mnt;
59492 + continue;
59493 + }
59494 +
59495 + parent = dentry->d_parent;
59496 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59497 + if (retval != NULL)
59498 + goto out;
59499 +
59500 + dentry = parent;
59501 + }
59502 +
59503 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59504 +
59505 + /* real_root is pinned so we don't have to hold a reference */
59506 + if (retval == NULL)
59507 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
59508 +out:
59509 + write_sequnlock(&rename_lock);
59510 + br_read_unlock(&vfsmount_lock);
59511 +
59512 + BUG_ON(retval == NULL);
59513 +
59514 + return retval;
59515 +}
59516 +
59517 +static __inline__ struct acl_object_label *
59518 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59519 + const struct acl_subject_label *subj)
59520 +{
59521 + char *path = NULL;
59522 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
59523 +}
59524 +
59525 +static __inline__ struct acl_object_label *
59526 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59527 + const struct acl_subject_label *subj)
59528 +{
59529 + char *path = NULL;
59530 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
59531 +}
59532 +
59533 +static __inline__ struct acl_object_label *
59534 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59535 + const struct acl_subject_label *subj, char *path)
59536 +{
59537 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
59538 +}
59539 +
59540 +static struct acl_subject_label *
59541 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59542 + const struct acl_role_label *role)
59543 +{
59544 + struct dentry *dentry = (struct dentry *) l_dentry;
59545 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59546 + struct mount *real_mnt = real_mount(mnt);
59547 + struct acl_subject_label *retval;
59548 + struct dentry *parent;
59549 +
59550 + br_read_lock(&vfsmount_lock);
59551 + write_seqlock(&rename_lock);
59552 +
59553 + for (;;) {
59554 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59555 + break;
59556 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59557 + if (!mnt_has_parent(real_mnt))
59558 + break;
59559 +
59560 + spin_lock(&dentry->d_lock);
59561 + read_lock(&gr_inode_lock);
59562 + retval =
59563 + lookup_acl_subj_label(dentry->d_inode->i_ino,
59564 + __get_dev(dentry), role);
59565 + read_unlock(&gr_inode_lock);
59566 + spin_unlock(&dentry->d_lock);
59567 + if (retval != NULL)
59568 + goto out;
59569 +
59570 + dentry = real_mnt->mnt_mountpoint;
59571 + real_mnt = real_mnt->mnt_parent;
59572 + mnt = &real_mnt->mnt;
59573 + continue;
59574 + }
59575 +
59576 + spin_lock(&dentry->d_lock);
59577 + read_lock(&gr_inode_lock);
59578 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59579 + __get_dev(dentry), role);
59580 + read_unlock(&gr_inode_lock);
59581 + parent = dentry->d_parent;
59582 + spin_unlock(&dentry->d_lock);
59583 +
59584 + if (retval != NULL)
59585 + goto out;
59586 +
59587 + dentry = parent;
59588 + }
59589 +
59590 + spin_lock(&dentry->d_lock);
59591 + read_lock(&gr_inode_lock);
59592 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59593 + __get_dev(dentry), role);
59594 + read_unlock(&gr_inode_lock);
59595 + spin_unlock(&dentry->d_lock);
59596 +
59597 + if (unlikely(retval == NULL)) {
59598 + /* real_root is pinned, we don't need to hold a reference */
59599 + read_lock(&gr_inode_lock);
59600 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
59601 + __get_dev(real_root.dentry), role);
59602 + read_unlock(&gr_inode_lock);
59603 + }
59604 +out:
59605 + write_sequnlock(&rename_lock);
59606 + br_read_unlock(&vfsmount_lock);
59607 +
59608 + BUG_ON(retval == NULL);
59609 +
59610 + return retval;
59611 +}
59612 +
59613 +static void
59614 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
59615 +{
59616 + struct task_struct *task = current;
59617 + const struct cred *cred = current_cred();
59618 +
59619 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
59620 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59621 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59622 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
59623 +
59624 + return;
59625 +}
59626 +
59627 +static void
59628 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
59629 +{
59630 + struct task_struct *task = current;
59631 + const struct cred *cred = current_cred();
59632 +
59633 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59634 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59635 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59636 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
59637 +
59638 + return;
59639 +}
59640 +
59641 +static void
59642 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
59643 +{
59644 + struct task_struct *task = current;
59645 + const struct cred *cred = current_cred();
59646 +
59647 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59648 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59649 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59650 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
59651 +
59652 + return;
59653 +}
59654 +
59655 +__u32
59656 +gr_search_file(const struct dentry * dentry, const __u32 mode,
59657 + const struct vfsmount * mnt)
59658 +{
59659 + __u32 retval = mode;
59660 + struct acl_subject_label *curracl;
59661 + struct acl_object_label *currobj;
59662 +
59663 + if (unlikely(!(gr_status & GR_READY)))
59664 + return (mode & ~GR_AUDITS);
59665 +
59666 + curracl = current->acl;
59667 +
59668 + currobj = chk_obj_label(dentry, mnt, curracl);
59669 + retval = currobj->mode & mode;
59670 +
59671 + /* if we're opening a specified transfer file for writing
59672 + (e.g. /dev/initctl), then transfer our role to init
59673 + */
59674 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
59675 + current->role->roletype & GR_ROLE_PERSIST)) {
59676 + struct task_struct *task = init_pid_ns.child_reaper;
59677 +
59678 + if (task->role != current->role) {
59679 + task->acl_sp_role = 0;
59680 + task->acl_role_id = current->acl_role_id;
59681 + task->role = current->role;
59682 + rcu_read_lock();
59683 + read_lock(&grsec_exec_file_lock);
59684 + gr_apply_subject_to_task(task);
59685 + read_unlock(&grsec_exec_file_lock);
59686 + rcu_read_unlock();
59687 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
59688 + }
59689 + }
59690 +
59691 + if (unlikely
59692 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
59693 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
59694 + __u32 new_mode = mode;
59695 +
59696 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59697 +
59698 + retval = new_mode;
59699 +
59700 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
59701 + new_mode |= GR_INHERIT;
59702 +
59703 + if (!(mode & GR_NOLEARN))
59704 + gr_log_learn(dentry, mnt, new_mode);
59705 + }
59706 +
59707 + return retval;
59708 +}
59709 +
59710 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
59711 + const struct dentry *parent,
59712 + const struct vfsmount *mnt)
59713 +{
59714 + struct name_entry *match;
59715 + struct acl_object_label *matchpo;
59716 + struct acl_subject_label *curracl;
59717 + char *path;
59718 +
59719 + if (unlikely(!(gr_status & GR_READY)))
59720 + return NULL;
59721 +
59722 + preempt_disable();
59723 + path = gr_to_filename_rbac(new_dentry, mnt);
59724 + match = lookup_name_entry_create(path);
59725 +
59726 + curracl = current->acl;
59727 +
59728 + if (match) {
59729 + read_lock(&gr_inode_lock);
59730 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
59731 + read_unlock(&gr_inode_lock);
59732 +
59733 + if (matchpo) {
59734 + preempt_enable();
59735 + return matchpo;
59736 + }
59737 + }
59738 +
59739 + // lookup parent
59740 +
59741 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
59742 +
59743 + preempt_enable();
59744 + return matchpo;
59745 +}
59746 +
59747 +__u32
59748 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
59749 + const struct vfsmount * mnt, const __u32 mode)
59750 +{
59751 + struct acl_object_label *matchpo;
59752 + __u32 retval;
59753 +
59754 + if (unlikely(!(gr_status & GR_READY)))
59755 + return (mode & ~GR_AUDITS);
59756 +
59757 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
59758 +
59759 + retval = matchpo->mode & mode;
59760 +
59761 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
59762 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59763 + __u32 new_mode = mode;
59764 +
59765 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59766 +
59767 + gr_log_learn(new_dentry, mnt, new_mode);
59768 + return new_mode;
59769 + }
59770 +
59771 + return retval;
59772 +}
59773 +
59774 +__u32
59775 +gr_check_link(const struct dentry * new_dentry,
59776 + const struct dentry * parent_dentry,
59777 + const struct vfsmount * parent_mnt,
59778 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
59779 +{
59780 + struct acl_object_label *obj;
59781 + __u32 oldmode, newmode;
59782 + __u32 needmode;
59783 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
59784 + GR_DELETE | GR_INHERIT;
59785 +
59786 + if (unlikely(!(gr_status & GR_READY)))
59787 + return (GR_CREATE | GR_LINK);
59788 +
59789 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
59790 + oldmode = obj->mode;
59791 +
59792 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
59793 + newmode = obj->mode;
59794 +
59795 + needmode = newmode & checkmodes;
59796 +
59797 + // old name for hardlink must have at least the permissions of the new name
59798 + if ((oldmode & needmode) != needmode)
59799 + goto bad;
59800 +
59801 + // if old name had restrictions/auditing, make sure the new name does as well
59802 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
59803 +
59804 + // don't allow hardlinking of suid/sgid/fcapped files without permission
59805 + if (is_privileged_binary(old_dentry))
59806 + needmode |= GR_SETID;
59807 +
59808 + if ((newmode & needmode) != needmode)
59809 + goto bad;
59810 +
59811 + // enforce minimum permissions
59812 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
59813 + return newmode;
59814 +bad:
59815 + needmode = oldmode;
59816 + if (is_privileged_binary(old_dentry))
59817 + needmode |= GR_SETID;
59818 +
59819 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
59820 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
59821 + return (GR_CREATE | GR_LINK);
59822 + } else if (newmode & GR_SUPPRESS)
59823 + return GR_SUPPRESS;
59824 + else
59825 + return 0;
59826 +}
59827 +
59828 +int
59829 +gr_check_hidden_task(const struct task_struct *task)
59830 +{
59831 + if (unlikely(!(gr_status & GR_READY)))
59832 + return 0;
59833 +
59834 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
59835 + return 1;
59836 +
59837 + return 0;
59838 +}
59839 +
59840 +int
59841 +gr_check_protected_task(const struct task_struct *task)
59842 +{
59843 + if (unlikely(!(gr_status & GR_READY) || !task))
59844 + return 0;
59845 +
59846 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59847 + task->acl != current->acl)
59848 + return 1;
59849 +
59850 + return 0;
59851 +}
59852 +
59853 +int
59854 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
59855 +{
59856 + struct task_struct *p;
59857 + int ret = 0;
59858 +
59859 + if (unlikely(!(gr_status & GR_READY) || !pid))
59860 + return ret;
59861 +
59862 + read_lock(&tasklist_lock);
59863 + do_each_pid_task(pid, type, p) {
59864 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59865 + p->acl != current->acl) {
59866 + ret = 1;
59867 + goto out;
59868 + }
59869 + } while_each_pid_task(pid, type, p);
59870 +out:
59871 + read_unlock(&tasklist_lock);
59872 +
59873 + return ret;
59874 +}
59875 +
59876 +void
59877 +gr_copy_label(struct task_struct *tsk)
59878 +{
59879 + tsk->signal->used_accept = 0;
59880 + tsk->acl_sp_role = 0;
59881 + tsk->acl_role_id = current->acl_role_id;
59882 + tsk->acl = current->acl;
59883 + tsk->role = current->role;
59884 + tsk->signal->curr_ip = current->signal->curr_ip;
59885 + tsk->signal->saved_ip = current->signal->saved_ip;
59886 + if (current->exec_file)
59887 + get_file(current->exec_file);
59888 + tsk->exec_file = current->exec_file;
59889 + tsk->is_writable = current->is_writable;
59890 + if (unlikely(current->signal->used_accept)) {
59891 + current->signal->curr_ip = 0;
59892 + current->signal->saved_ip = 0;
59893 + }
59894 +
59895 + return;
59896 +}
59897 +
59898 +static void
59899 +gr_set_proc_res(struct task_struct *task)
59900 +{
59901 + struct acl_subject_label *proc;
59902 + unsigned short i;
59903 +
59904 + proc = task->acl;
59905 +
59906 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
59907 + return;
59908 +
59909 + for (i = 0; i < RLIM_NLIMITS; i++) {
59910 + if (!(proc->resmask & (1U << i)))
59911 + continue;
59912 +
59913 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
59914 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
59915 +
59916 + if (i == RLIMIT_CPU)
59917 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
59918 + }
59919 +
59920 + return;
59921 +}
59922 +
59923 +extern int __gr_process_user_ban(struct user_struct *user);
59924 +
59925 +int
59926 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
59927 +{
59928 + unsigned int i;
59929 + __u16 num;
59930 + uid_t *uidlist;
59931 + uid_t curuid;
59932 + int realok = 0;
59933 + int effectiveok = 0;
59934 + int fsok = 0;
59935 + uid_t globalreal, globaleffective, globalfs;
59936 +
59937 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
59938 + struct user_struct *user;
59939 +
59940 + if (!uid_valid(real))
59941 + goto skipit;
59942 +
59943 + /* find user based on global namespace */
59944 +
59945 + globalreal = GR_GLOBAL_UID(real);
59946 +
59947 + user = find_user(make_kuid(&init_user_ns, globalreal));
59948 + if (user == NULL)
59949 + goto skipit;
59950 +
59951 + if (__gr_process_user_ban(user)) {
59952 + /* for find_user */
59953 + free_uid(user);
59954 + return 1;
59955 + }
59956 +
59957 + /* for find_user */
59958 + free_uid(user);
59959 +
59960 +skipit:
59961 +#endif
59962 +
59963 + if (unlikely(!(gr_status & GR_READY)))
59964 + return 0;
59965 +
59966 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
59967 + gr_log_learn_uid_change(real, effective, fs);
59968 +
59969 + num = current->acl->user_trans_num;
59970 + uidlist = current->acl->user_transitions;
59971 +
59972 + if (uidlist == NULL)
59973 + return 0;
59974 +
59975 + if (!uid_valid(real)) {
59976 + realok = 1;
59977 + globalreal = (uid_t)-1;
59978 + } else {
59979 + globalreal = GR_GLOBAL_UID(real);
59980 + }
59981 + if (!uid_valid(effective)) {
59982 + effectiveok = 1;
59983 + globaleffective = (uid_t)-1;
59984 + } else {
59985 + globaleffective = GR_GLOBAL_UID(effective);
59986 + }
59987 + if (!uid_valid(fs)) {
59988 + fsok = 1;
59989 + globalfs = (uid_t)-1;
59990 + } else {
59991 + globalfs = GR_GLOBAL_UID(fs);
59992 + }
59993 +
59994 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
59995 + for (i = 0; i < num; i++) {
59996 + curuid = uidlist[i];
59997 + if (globalreal == curuid)
59998 + realok = 1;
59999 + if (globaleffective == curuid)
60000 + effectiveok = 1;
60001 + if (globalfs == curuid)
60002 + fsok = 1;
60003 + }
60004 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60005 + for (i = 0; i < num; i++) {
60006 + curuid = uidlist[i];
60007 + if (globalreal == curuid)
60008 + break;
60009 + if (globaleffective == curuid)
60010 + break;
60011 + if (globalfs == curuid)
60012 + break;
60013 + }
60014 + /* not in deny list */
60015 + if (i == num) {
60016 + realok = 1;
60017 + effectiveok = 1;
60018 + fsok = 1;
60019 + }
60020 + }
60021 +
60022 + if (realok && effectiveok && fsok)
60023 + return 0;
60024 + else {
60025 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60026 + return 1;
60027 + }
60028 +}
60029 +
60030 +int
60031 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60032 +{
60033 + unsigned int i;
60034 + __u16 num;
60035 + gid_t *gidlist;
60036 + gid_t curgid;
60037 + int realok = 0;
60038 + int effectiveok = 0;
60039 + int fsok = 0;
60040 + gid_t globalreal, globaleffective, globalfs;
60041 +
60042 + if (unlikely(!(gr_status & GR_READY)))
60043 + return 0;
60044 +
60045 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60046 + gr_log_learn_gid_change(real, effective, fs);
60047 +
60048 + num = current->acl->group_trans_num;
60049 + gidlist = current->acl->group_transitions;
60050 +
60051 + if (gidlist == NULL)
60052 + return 0;
60053 +
60054 + if (!gid_valid(real)) {
60055 + realok = 1;
60056 + globalreal = (gid_t)-1;
60057 + } else {
60058 + globalreal = GR_GLOBAL_GID(real);
60059 + }
60060 + if (!gid_valid(effective)) {
60061 + effectiveok = 1;
60062 + globaleffective = (gid_t)-1;
60063 + } else {
60064 + globaleffective = GR_GLOBAL_GID(effective);
60065 + }
60066 + if (!gid_valid(fs)) {
60067 + fsok = 1;
60068 + globalfs = (gid_t)-1;
60069 + } else {
60070 + globalfs = GR_GLOBAL_GID(fs);
60071 + }
60072 +
60073 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60074 + for (i = 0; i < num; i++) {
60075 + curgid = gidlist[i];
60076 + if (globalreal == curgid)
60077 + realok = 1;
60078 + if (globaleffective == curgid)
60079 + effectiveok = 1;
60080 + if (globalfs == curgid)
60081 + fsok = 1;
60082 + }
60083 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60084 + for (i = 0; i < num; i++) {
60085 + curgid = gidlist[i];
60086 + if (globalreal == curgid)
60087 + break;
60088 + if (globaleffective == curgid)
60089 + break;
60090 + if (globalfs == curgid)
60091 + break;
60092 + }
60093 + /* not in deny list */
60094 + if (i == num) {
60095 + realok = 1;
60096 + effectiveok = 1;
60097 + fsok = 1;
60098 + }
60099 + }
60100 +
60101 + if (realok && effectiveok && fsok)
60102 + return 0;
60103 + else {
60104 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60105 + return 1;
60106 + }
60107 +}
60108 +
60109 +extern int gr_acl_is_capable(const int cap);
60110 +
60111 +void
60112 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60113 +{
60114 + struct acl_role_label *role = task->role;
60115 + struct acl_subject_label *subj = NULL;
60116 + struct acl_object_label *obj;
60117 + struct file *filp;
60118 + uid_t uid;
60119 + gid_t gid;
60120 +
60121 + if (unlikely(!(gr_status & GR_READY)))
60122 + return;
60123 +
60124 + uid = GR_GLOBAL_UID(kuid);
60125 + gid = GR_GLOBAL_GID(kgid);
60126 +
60127 + filp = task->exec_file;
60128 +
60129 + /* kernel process, we'll give them the kernel role */
60130 + if (unlikely(!filp)) {
60131 + task->role = kernel_role;
60132 + task->acl = kernel_role->root_label;
60133 + return;
60134 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60135 + role = lookup_acl_role_label(task, uid, gid);
60136 +
60137 + /* don't change the role if we're not a privileged process */
60138 + if (role && task->role != role &&
60139 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60140 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60141 + return;
60142 +
60143 + /* perform subject lookup in possibly new role
60144 + we can use this result below in the case where role == task->role
60145 + */
60146 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60147 +
60148 + /* if we changed uid/gid, but result in the same role
60149 + and are using inheritance, don't lose the inherited subject
60150 + if current subject is other than what normal lookup
60151 + would result in, we arrived via inheritance, don't
60152 + lose subject
60153 + */
60154 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60155 + (subj == task->acl)))
60156 + task->acl = subj;
60157 +
60158 + task->role = role;
60159 +
60160 + task->is_writable = 0;
60161 +
60162 + /* ignore additional mmap checks for processes that are writable
60163 + by the default ACL */
60164 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60165 + if (unlikely(obj->mode & GR_WRITE))
60166 + task->is_writable = 1;
60167 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60168 + if (unlikely(obj->mode & GR_WRITE))
60169 + task->is_writable = 1;
60170 +
60171 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60172 + 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);
60173 +#endif
60174 +
60175 + gr_set_proc_res(task);
60176 +
60177 + return;
60178 +}
60179 +
60180 +int
60181 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60182 + const int unsafe_flags)
60183 +{
60184 + struct task_struct *task = current;
60185 + struct acl_subject_label *newacl;
60186 + struct acl_object_label *obj;
60187 + __u32 retmode;
60188 +
60189 + if (unlikely(!(gr_status & GR_READY)))
60190 + return 0;
60191 +
60192 + newacl = chk_subj_label(dentry, mnt, task->role);
60193 +
60194 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60195 + did an exec
60196 + */
60197 + rcu_read_lock();
60198 + read_lock(&tasklist_lock);
60199 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60200 + (task->parent->acl->mode & GR_POVERRIDE))) {
60201 + read_unlock(&tasklist_lock);
60202 + rcu_read_unlock();
60203 + goto skip_check;
60204 + }
60205 + read_unlock(&tasklist_lock);
60206 + rcu_read_unlock();
60207 +
60208 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60209 + !(task->role->roletype & GR_ROLE_GOD) &&
60210 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60211 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60212 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60213 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60214 + else
60215 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60216 + return -EACCES;
60217 + }
60218 +
60219 +skip_check:
60220 +
60221 + obj = chk_obj_label(dentry, mnt, task->acl);
60222 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60223 +
60224 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60225 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60226 + if (obj->nested)
60227 + task->acl = obj->nested;
60228 + else
60229 + task->acl = newacl;
60230 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60231 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60232 +
60233 + task->is_writable = 0;
60234 +
60235 + /* ignore additional mmap checks for processes that are writable
60236 + by the default ACL */
60237 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60238 + if (unlikely(obj->mode & GR_WRITE))
60239 + task->is_writable = 1;
60240 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60241 + if (unlikely(obj->mode & GR_WRITE))
60242 + task->is_writable = 1;
60243 +
60244 + gr_set_proc_res(task);
60245 +
60246 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60247 + 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);
60248 +#endif
60249 + return 0;
60250 +}
60251 +
60252 +/* always called with valid inodev ptr */
60253 +static void
60254 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60255 +{
60256 + struct acl_object_label *matchpo;
60257 + struct acl_subject_label *matchps;
60258 + struct acl_subject_label *subj;
60259 + struct acl_role_label *role;
60260 + unsigned int x;
60261 +
60262 + FOR_EACH_ROLE_START(role)
60263 + FOR_EACH_SUBJECT_START(role, subj, x)
60264 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60265 + matchpo->mode |= GR_DELETED;
60266 + FOR_EACH_SUBJECT_END(subj,x)
60267 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60268 + /* nested subjects aren't in the role's subj_hash table */
60269 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60270 + matchpo->mode |= GR_DELETED;
60271 + FOR_EACH_NESTED_SUBJECT_END(subj)
60272 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60273 + matchps->mode |= GR_DELETED;
60274 + FOR_EACH_ROLE_END(role)
60275 +
60276 + inodev->nentry->deleted = 1;
60277 +
60278 + return;
60279 +}
60280 +
60281 +void
60282 +gr_handle_delete(const ino_t ino, const dev_t dev)
60283 +{
60284 + struct inodev_entry *inodev;
60285 +
60286 + if (unlikely(!(gr_status & GR_READY)))
60287 + return;
60288 +
60289 + write_lock(&gr_inode_lock);
60290 + inodev = lookup_inodev_entry(ino, dev);
60291 + if (inodev != NULL)
60292 + do_handle_delete(inodev, ino, dev);
60293 + write_unlock(&gr_inode_lock);
60294 +
60295 + return;
60296 +}
60297 +
60298 +static void
60299 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60300 + const ino_t newinode, const dev_t newdevice,
60301 + struct acl_subject_label *subj)
60302 +{
60303 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60304 + struct acl_object_label *match;
60305 +
60306 + match = subj->obj_hash[index];
60307 +
60308 + while (match && (match->inode != oldinode ||
60309 + match->device != olddevice ||
60310 + !(match->mode & GR_DELETED)))
60311 + match = match->next;
60312 +
60313 + if (match && (match->inode == oldinode)
60314 + && (match->device == olddevice)
60315 + && (match->mode & GR_DELETED)) {
60316 + if (match->prev == NULL) {
60317 + subj->obj_hash[index] = match->next;
60318 + if (match->next != NULL)
60319 + match->next->prev = NULL;
60320 + } else {
60321 + match->prev->next = match->next;
60322 + if (match->next != NULL)
60323 + match->next->prev = match->prev;
60324 + }
60325 + match->prev = NULL;
60326 + match->next = NULL;
60327 + match->inode = newinode;
60328 + match->device = newdevice;
60329 + match->mode &= ~GR_DELETED;
60330 +
60331 + insert_acl_obj_label(match, subj);
60332 + }
60333 +
60334 + return;
60335 +}
60336 +
60337 +static void
60338 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60339 + const ino_t newinode, const dev_t newdevice,
60340 + struct acl_role_label *role)
60341 +{
60342 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60343 + struct acl_subject_label *match;
60344 +
60345 + match = role->subj_hash[index];
60346 +
60347 + while (match && (match->inode != oldinode ||
60348 + match->device != olddevice ||
60349 + !(match->mode & GR_DELETED)))
60350 + match = match->next;
60351 +
60352 + if (match && (match->inode == oldinode)
60353 + && (match->device == olddevice)
60354 + && (match->mode & GR_DELETED)) {
60355 + if (match->prev == NULL) {
60356 + role->subj_hash[index] = match->next;
60357 + if (match->next != NULL)
60358 + match->next->prev = NULL;
60359 + } else {
60360 + match->prev->next = match->next;
60361 + if (match->next != NULL)
60362 + match->next->prev = match->prev;
60363 + }
60364 + match->prev = NULL;
60365 + match->next = NULL;
60366 + match->inode = newinode;
60367 + match->device = newdevice;
60368 + match->mode &= ~GR_DELETED;
60369 +
60370 + insert_acl_subj_label(match, role);
60371 + }
60372 +
60373 + return;
60374 +}
60375 +
60376 +static void
60377 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60378 + const ino_t newinode, const dev_t newdevice)
60379 +{
60380 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60381 + struct inodev_entry *match;
60382 +
60383 + match = inodev_set.i_hash[index];
60384 +
60385 + while (match && (match->nentry->inode != oldinode ||
60386 + match->nentry->device != olddevice || !match->nentry->deleted))
60387 + match = match->next;
60388 +
60389 + if (match && (match->nentry->inode == oldinode)
60390 + && (match->nentry->device == olddevice) &&
60391 + match->nentry->deleted) {
60392 + if (match->prev == NULL) {
60393 + inodev_set.i_hash[index] = match->next;
60394 + if (match->next != NULL)
60395 + match->next->prev = NULL;
60396 + } else {
60397 + match->prev->next = match->next;
60398 + if (match->next != NULL)
60399 + match->next->prev = match->prev;
60400 + }
60401 + match->prev = NULL;
60402 + match->next = NULL;
60403 + match->nentry->inode = newinode;
60404 + match->nentry->device = newdevice;
60405 + match->nentry->deleted = 0;
60406 +
60407 + insert_inodev_entry(match);
60408 + }
60409 +
60410 + return;
60411 +}
60412 +
60413 +static void
60414 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60415 +{
60416 + struct acl_subject_label *subj;
60417 + struct acl_role_label *role;
60418 + unsigned int x;
60419 +
60420 + FOR_EACH_ROLE_START(role)
60421 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60422 +
60423 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60424 + if ((subj->inode == ino) && (subj->device == dev)) {
60425 + subj->inode = ino;
60426 + subj->device = dev;
60427 + }
60428 + /* nested subjects aren't in the role's subj_hash table */
60429 + update_acl_obj_label(matchn->inode, matchn->device,
60430 + ino, dev, subj);
60431 + FOR_EACH_NESTED_SUBJECT_END(subj)
60432 + FOR_EACH_SUBJECT_START(role, subj, x)
60433 + update_acl_obj_label(matchn->inode, matchn->device,
60434 + ino, dev, subj);
60435 + FOR_EACH_SUBJECT_END(subj,x)
60436 + FOR_EACH_ROLE_END(role)
60437 +
60438 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60439 +
60440 + return;
60441 +}
60442 +
60443 +static void
60444 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60445 + const struct vfsmount *mnt)
60446 +{
60447 + ino_t ino = dentry->d_inode->i_ino;
60448 + dev_t dev = __get_dev(dentry);
60449 +
60450 + __do_handle_create(matchn, ino, dev);
60451 +
60452 + return;
60453 +}
60454 +
60455 +void
60456 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60457 +{
60458 + struct name_entry *matchn;
60459 +
60460 + if (unlikely(!(gr_status & GR_READY)))
60461 + return;
60462 +
60463 + preempt_disable();
60464 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60465 +
60466 + if (unlikely((unsigned long)matchn)) {
60467 + write_lock(&gr_inode_lock);
60468 + do_handle_create(matchn, dentry, mnt);
60469 + write_unlock(&gr_inode_lock);
60470 + }
60471 + preempt_enable();
60472 +
60473 + return;
60474 +}
60475 +
60476 +void
60477 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60478 +{
60479 + struct name_entry *matchn;
60480 +
60481 + if (unlikely(!(gr_status & GR_READY)))
60482 + return;
60483 +
60484 + preempt_disable();
60485 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60486 +
60487 + if (unlikely((unsigned long)matchn)) {
60488 + write_lock(&gr_inode_lock);
60489 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
60490 + write_unlock(&gr_inode_lock);
60491 + }
60492 + preempt_enable();
60493 +
60494 + return;
60495 +}
60496 +
60497 +void
60498 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
60499 + struct dentry *old_dentry,
60500 + struct dentry *new_dentry,
60501 + struct vfsmount *mnt, const __u8 replace)
60502 +{
60503 + struct name_entry *matchn;
60504 + struct inodev_entry *inodev;
60505 + struct inode *inode = new_dentry->d_inode;
60506 + ino_t old_ino = old_dentry->d_inode->i_ino;
60507 + dev_t old_dev = __get_dev(old_dentry);
60508 +
60509 + /* vfs_rename swaps the name and parent link for old_dentry and
60510 + new_dentry
60511 + at this point, old_dentry has the new name, parent link, and inode
60512 + for the renamed file
60513 + if a file is being replaced by a rename, new_dentry has the inode
60514 + and name for the replaced file
60515 + */
60516 +
60517 + if (unlikely(!(gr_status & GR_READY)))
60518 + return;
60519 +
60520 + preempt_disable();
60521 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
60522 +
60523 + /* we wouldn't have to check d_inode if it weren't for
60524 + NFS silly-renaming
60525 + */
60526 +
60527 + write_lock(&gr_inode_lock);
60528 + if (unlikely(replace && inode)) {
60529 + ino_t new_ino = inode->i_ino;
60530 + dev_t new_dev = __get_dev(new_dentry);
60531 +
60532 + inodev = lookup_inodev_entry(new_ino, new_dev);
60533 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
60534 + do_handle_delete(inodev, new_ino, new_dev);
60535 + }
60536 +
60537 + inodev = lookup_inodev_entry(old_ino, old_dev);
60538 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
60539 + do_handle_delete(inodev, old_ino, old_dev);
60540 +
60541 + if (unlikely((unsigned long)matchn))
60542 + do_handle_create(matchn, old_dentry, mnt);
60543 +
60544 + write_unlock(&gr_inode_lock);
60545 + preempt_enable();
60546 +
60547 + return;
60548 +}
60549 +
60550 +static int
60551 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
60552 + unsigned char **sum)
60553 +{
60554 + struct acl_role_label *r;
60555 + struct role_allowed_ip *ipp;
60556 + struct role_transition *trans;
60557 + unsigned int i;
60558 + int found = 0;
60559 + u32 curr_ip = current->signal->curr_ip;
60560 +
60561 + current->signal->saved_ip = curr_ip;
60562 +
60563 + /* check transition table */
60564 +
60565 + for (trans = current->role->transitions; trans; trans = trans->next) {
60566 + if (!strcmp(rolename, trans->rolename)) {
60567 + found = 1;
60568 + break;
60569 + }
60570 + }
60571 +
60572 + if (!found)
60573 + return 0;
60574 +
60575 + /* handle special roles that do not require authentication
60576 + and check ip */
60577 +
60578 + FOR_EACH_ROLE_START(r)
60579 + if (!strcmp(rolename, r->rolename) &&
60580 + (r->roletype & GR_ROLE_SPECIAL)) {
60581 + found = 0;
60582 + if (r->allowed_ips != NULL) {
60583 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
60584 + if ((ntohl(curr_ip) & ipp->netmask) ==
60585 + (ntohl(ipp->addr) & ipp->netmask))
60586 + found = 1;
60587 + }
60588 + } else
60589 + found = 2;
60590 + if (!found)
60591 + return 0;
60592 +
60593 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
60594 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
60595 + *salt = NULL;
60596 + *sum = NULL;
60597 + return 1;
60598 + }
60599 + }
60600 + FOR_EACH_ROLE_END(r)
60601 +
60602 + for (i = 0; i < num_sprole_pws; i++) {
60603 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
60604 + *salt = acl_special_roles[i]->salt;
60605 + *sum = acl_special_roles[i]->sum;
60606 + return 1;
60607 + }
60608 + }
60609 +
60610 + return 0;
60611 +}
60612 +
60613 +static void
60614 +assign_special_role(char *rolename)
60615 +{
60616 + struct acl_object_label *obj;
60617 + struct acl_role_label *r;
60618 + struct acl_role_label *assigned = NULL;
60619 + struct task_struct *tsk;
60620 + struct file *filp;
60621 +
60622 + FOR_EACH_ROLE_START(r)
60623 + if (!strcmp(rolename, r->rolename) &&
60624 + (r->roletype & GR_ROLE_SPECIAL)) {
60625 + assigned = r;
60626 + break;
60627 + }
60628 + FOR_EACH_ROLE_END(r)
60629 +
60630 + if (!assigned)
60631 + return;
60632 +
60633 + read_lock(&tasklist_lock);
60634 + read_lock(&grsec_exec_file_lock);
60635 +
60636 + tsk = current->real_parent;
60637 + if (tsk == NULL)
60638 + goto out_unlock;
60639 +
60640 + filp = tsk->exec_file;
60641 + if (filp == NULL)
60642 + goto out_unlock;
60643 +
60644 + tsk->is_writable = 0;
60645 +
60646 + tsk->acl_sp_role = 1;
60647 + tsk->acl_role_id = ++acl_sp_role_value;
60648 + tsk->role = assigned;
60649 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
60650 +
60651 + /* ignore additional mmap checks for processes that are writable
60652 + by the default ACL */
60653 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60654 + if (unlikely(obj->mode & GR_WRITE))
60655 + tsk->is_writable = 1;
60656 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
60657 + if (unlikely(obj->mode & GR_WRITE))
60658 + tsk->is_writable = 1;
60659 +
60660 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60661 + 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));
60662 +#endif
60663 +
60664 +out_unlock:
60665 + read_unlock(&grsec_exec_file_lock);
60666 + read_unlock(&tasklist_lock);
60667 + return;
60668 +}
60669 +
60670 +int gr_check_secure_terminal(struct task_struct *task)
60671 +{
60672 + struct task_struct *p, *p2, *p3;
60673 + struct files_struct *files;
60674 + struct fdtable *fdt;
60675 + struct file *our_file = NULL, *file;
60676 + int i;
60677 +
60678 + if (task->signal->tty == NULL)
60679 + return 1;
60680 +
60681 + files = get_files_struct(task);
60682 + if (files != NULL) {
60683 + rcu_read_lock();
60684 + fdt = files_fdtable(files);
60685 + for (i=0; i < fdt->max_fds; i++) {
60686 + file = fcheck_files(files, i);
60687 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
60688 + get_file(file);
60689 + our_file = file;
60690 + }
60691 + }
60692 + rcu_read_unlock();
60693 + put_files_struct(files);
60694 + }
60695 +
60696 + if (our_file == NULL)
60697 + return 1;
60698 +
60699 + read_lock(&tasklist_lock);
60700 + do_each_thread(p2, p) {
60701 + files = get_files_struct(p);
60702 + if (files == NULL ||
60703 + (p->signal && p->signal->tty == task->signal->tty)) {
60704 + if (files != NULL)
60705 + put_files_struct(files);
60706 + continue;
60707 + }
60708 + rcu_read_lock();
60709 + fdt = files_fdtable(files);
60710 + for (i=0; i < fdt->max_fds; i++) {
60711 + file = fcheck_files(files, i);
60712 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
60713 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
60714 + p3 = task;
60715 + while (task_pid_nr(p3) > 0) {
60716 + if (p3 == p)
60717 + break;
60718 + p3 = p3->real_parent;
60719 + }
60720 + if (p3 == p)
60721 + break;
60722 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
60723 + gr_handle_alertkill(p);
60724 + rcu_read_unlock();
60725 + put_files_struct(files);
60726 + read_unlock(&tasklist_lock);
60727 + fput(our_file);
60728 + return 0;
60729 + }
60730 + }
60731 + rcu_read_unlock();
60732 + put_files_struct(files);
60733 + } while_each_thread(p2, p);
60734 + read_unlock(&tasklist_lock);
60735 +
60736 + fput(our_file);
60737 + return 1;
60738 +}
60739 +
60740 +static int gr_rbac_disable(void *unused)
60741 +{
60742 + pax_open_kernel();
60743 + gr_status &= ~GR_READY;
60744 + pax_close_kernel();
60745 +
60746 + return 0;
60747 +}
60748 +
60749 +ssize_t
60750 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
60751 +{
60752 + struct gr_arg_wrapper uwrap;
60753 + unsigned char *sprole_salt = NULL;
60754 + unsigned char *sprole_sum = NULL;
60755 + int error = sizeof (struct gr_arg_wrapper);
60756 + int error2 = 0;
60757 +
60758 + mutex_lock(&gr_dev_mutex);
60759 +
60760 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
60761 + error = -EPERM;
60762 + goto out;
60763 + }
60764 +
60765 + if (count != sizeof (struct gr_arg_wrapper)) {
60766 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
60767 + error = -EINVAL;
60768 + goto out;
60769 + }
60770 +
60771 +
60772 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
60773 + gr_auth_expires = 0;
60774 + gr_auth_attempts = 0;
60775 + }
60776 +
60777 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
60778 + error = -EFAULT;
60779 + goto out;
60780 + }
60781 +
60782 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
60783 + error = -EINVAL;
60784 + goto out;
60785 + }
60786 +
60787 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
60788 + error = -EFAULT;
60789 + goto out;
60790 + }
60791 +
60792 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60793 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60794 + time_after(gr_auth_expires, get_seconds())) {
60795 + error = -EBUSY;
60796 + goto out;
60797 + }
60798 +
60799 + /* if non-root trying to do anything other than use a special role,
60800 + do not attempt authentication, do not count towards authentication
60801 + locking
60802 + */
60803 +
60804 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
60805 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60806 + gr_is_global_nonroot(current_uid())) {
60807 + error = -EPERM;
60808 + goto out;
60809 + }
60810 +
60811 + /* ensure pw and special role name are null terminated */
60812 +
60813 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
60814 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
60815 +
60816 + /* Okay.
60817 + * We have our enough of the argument structure..(we have yet
60818 + * to copy_from_user the tables themselves) . Copy the tables
60819 + * only if we need them, i.e. for loading operations. */
60820 +
60821 + switch (gr_usermode->mode) {
60822 + case GR_STATUS:
60823 + if (gr_status & GR_READY) {
60824 + error = 1;
60825 + if (!gr_check_secure_terminal(current))
60826 + error = 3;
60827 + } else
60828 + error = 2;
60829 + goto out;
60830 + case GR_SHUTDOWN:
60831 + if ((gr_status & GR_READY)
60832 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60833 + stop_machine(gr_rbac_disable, NULL, NULL);
60834 + free_variables();
60835 + memset(gr_usermode, 0, sizeof (struct gr_arg));
60836 + memset(gr_system_salt, 0, GR_SALT_LEN);
60837 + memset(gr_system_sum, 0, GR_SHA_LEN);
60838 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
60839 + } else if (gr_status & GR_READY) {
60840 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
60841 + error = -EPERM;
60842 + } else {
60843 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
60844 + error = -EAGAIN;
60845 + }
60846 + break;
60847 + case GR_ENABLE:
60848 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
60849 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
60850 + else {
60851 + if (gr_status & GR_READY)
60852 + error = -EAGAIN;
60853 + else
60854 + error = error2;
60855 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
60856 + }
60857 + break;
60858 + case GR_RELOAD:
60859 + if (!(gr_status & GR_READY)) {
60860 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
60861 + error = -EAGAIN;
60862 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60863 + stop_machine(gr_rbac_disable, NULL, NULL);
60864 + free_variables();
60865 + error2 = gracl_init(gr_usermode);
60866 + if (!error2)
60867 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
60868 + else {
60869 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60870 + error = error2;
60871 + }
60872 + } else {
60873 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60874 + error = -EPERM;
60875 + }
60876 + break;
60877 + case GR_SEGVMOD:
60878 + if (unlikely(!(gr_status & GR_READY))) {
60879 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
60880 + error = -EAGAIN;
60881 + break;
60882 + }
60883 +
60884 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60885 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
60886 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
60887 + struct acl_subject_label *segvacl;
60888 + segvacl =
60889 + lookup_acl_subj_label(gr_usermode->segv_inode,
60890 + gr_usermode->segv_device,
60891 + current->role);
60892 + if (segvacl) {
60893 + segvacl->crashes = 0;
60894 + segvacl->expires = 0;
60895 + }
60896 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
60897 + gr_remove_uid(gr_usermode->segv_uid);
60898 + }
60899 + } else {
60900 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
60901 + error = -EPERM;
60902 + }
60903 + break;
60904 + case GR_SPROLE:
60905 + case GR_SPROLEPAM:
60906 + if (unlikely(!(gr_status & GR_READY))) {
60907 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
60908 + error = -EAGAIN;
60909 + break;
60910 + }
60911 +
60912 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
60913 + current->role->expires = 0;
60914 + current->role->auth_attempts = 0;
60915 + }
60916 +
60917 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60918 + time_after(current->role->expires, get_seconds())) {
60919 + error = -EBUSY;
60920 + goto out;
60921 + }
60922 +
60923 + if (lookup_special_role_auth
60924 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
60925 + && ((!sprole_salt && !sprole_sum)
60926 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
60927 + char *p = "";
60928 + assign_special_role(gr_usermode->sp_role);
60929 + read_lock(&tasklist_lock);
60930 + if (current->real_parent)
60931 + p = current->real_parent->role->rolename;
60932 + read_unlock(&tasklist_lock);
60933 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
60934 + p, acl_sp_role_value);
60935 + } else {
60936 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
60937 + error = -EPERM;
60938 + if(!(current->role->auth_attempts++))
60939 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60940 +
60941 + goto out;
60942 + }
60943 + break;
60944 + case GR_UNSPROLE:
60945 + if (unlikely(!(gr_status & GR_READY))) {
60946 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
60947 + error = -EAGAIN;
60948 + break;
60949 + }
60950 +
60951 + if (current->role->roletype & GR_ROLE_SPECIAL) {
60952 + char *p = "";
60953 + int i = 0;
60954 +
60955 + read_lock(&tasklist_lock);
60956 + if (current->real_parent) {
60957 + p = current->real_parent->role->rolename;
60958 + i = current->real_parent->acl_role_id;
60959 + }
60960 + read_unlock(&tasklist_lock);
60961 +
60962 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
60963 + gr_set_acls(1);
60964 + } else {
60965 + error = -EPERM;
60966 + goto out;
60967 + }
60968 + break;
60969 + default:
60970 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
60971 + error = -EINVAL;
60972 + break;
60973 + }
60974 +
60975 + if (error != -EPERM)
60976 + goto out;
60977 +
60978 + if(!(gr_auth_attempts++))
60979 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60980 +
60981 + out:
60982 + mutex_unlock(&gr_dev_mutex);
60983 + return error;
60984 +}
60985 +
60986 +/* must be called with
60987 + rcu_read_lock();
60988 + read_lock(&tasklist_lock);
60989 + read_lock(&grsec_exec_file_lock);
60990 +*/
60991 +int gr_apply_subject_to_task(struct task_struct *task)
60992 +{
60993 + struct acl_object_label *obj;
60994 + char *tmpname;
60995 + struct acl_subject_label *tmpsubj;
60996 + struct file *filp;
60997 + struct name_entry *nmatch;
60998 +
60999 + filp = task->exec_file;
61000 + if (filp == NULL)
61001 + return 0;
61002 +
61003 + /* the following is to apply the correct subject
61004 + on binaries running when the RBAC system
61005 + is enabled, when the binaries have been
61006 + replaced or deleted since their execution
61007 + -----
61008 + when the RBAC system starts, the inode/dev
61009 + from exec_file will be one the RBAC system
61010 + is unaware of. It only knows the inode/dev
61011 + of the present file on disk, or the absence
61012 + of it.
61013 + */
61014 + preempt_disable();
61015 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61016 +
61017 + nmatch = lookup_name_entry(tmpname);
61018 + preempt_enable();
61019 + tmpsubj = NULL;
61020 + if (nmatch) {
61021 + if (nmatch->deleted)
61022 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61023 + else
61024 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61025 + if (tmpsubj != NULL)
61026 + task->acl = tmpsubj;
61027 + }
61028 + if (tmpsubj == NULL)
61029 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61030 + task->role);
61031 + if (task->acl) {
61032 + task->is_writable = 0;
61033 + /* ignore additional mmap checks for processes that are writable
61034 + by the default ACL */
61035 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61036 + if (unlikely(obj->mode & GR_WRITE))
61037 + task->is_writable = 1;
61038 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61039 + if (unlikely(obj->mode & GR_WRITE))
61040 + task->is_writable = 1;
61041 +
61042 + gr_set_proc_res(task);
61043 +
61044 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61045 + 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);
61046 +#endif
61047 + } else {
61048 + return 1;
61049 + }
61050 +
61051 + return 0;
61052 +}
61053 +
61054 +int
61055 +gr_set_acls(const int type)
61056 +{
61057 + struct task_struct *task, *task2;
61058 + struct acl_role_label *role = current->role;
61059 + __u16 acl_role_id = current->acl_role_id;
61060 + const struct cred *cred;
61061 + int ret;
61062 +
61063 + rcu_read_lock();
61064 + read_lock(&tasklist_lock);
61065 + read_lock(&grsec_exec_file_lock);
61066 + do_each_thread(task2, task) {
61067 + /* check to see if we're called from the exit handler,
61068 + if so, only replace ACLs that have inherited the admin
61069 + ACL */
61070 +
61071 + if (type && (task->role != role ||
61072 + task->acl_role_id != acl_role_id))
61073 + continue;
61074 +
61075 + task->acl_role_id = 0;
61076 + task->acl_sp_role = 0;
61077 +
61078 + if (task->exec_file) {
61079 + cred = __task_cred(task);
61080 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61081 + ret = gr_apply_subject_to_task(task);
61082 + if (ret) {
61083 + read_unlock(&grsec_exec_file_lock);
61084 + read_unlock(&tasklist_lock);
61085 + rcu_read_unlock();
61086 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61087 + return ret;
61088 + }
61089 + } else {
61090 + // it's a kernel process
61091 + task->role = kernel_role;
61092 + task->acl = kernel_role->root_label;
61093 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61094 + task->acl->mode &= ~GR_PROCFIND;
61095 +#endif
61096 + }
61097 + } while_each_thread(task2, task);
61098 + read_unlock(&grsec_exec_file_lock);
61099 + read_unlock(&tasklist_lock);
61100 + rcu_read_unlock();
61101 +
61102 + return 0;
61103 +}
61104 +
61105 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61106 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61107 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61108 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61109 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61110 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61111 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61112 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61113 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61114 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61115 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61116 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61117 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61118 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61119 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61120 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61121 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61122 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61123 +};
61124 +
61125 +void
61126 +gr_learn_resource(const struct task_struct *task,
61127 + const int res, const unsigned long wanted, const int gt)
61128 +{
61129 + struct acl_subject_label *acl;
61130 + const struct cred *cred;
61131 +
61132 + if (unlikely((gr_status & GR_READY) &&
61133 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61134 + goto skip_reslog;
61135 +
61136 + gr_log_resource(task, res, wanted, gt);
61137 +skip_reslog:
61138 +
61139 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61140 + return;
61141 +
61142 + acl = task->acl;
61143 +
61144 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61145 + !(acl->resmask & (1U << (unsigned short) res))))
61146 + return;
61147 +
61148 + if (wanted >= acl->res[res].rlim_cur) {
61149 + unsigned long res_add;
61150 +
61151 + res_add = wanted + res_learn_bumps[res];
61152 +
61153 + acl->res[res].rlim_cur = res_add;
61154 +
61155 + if (wanted > acl->res[res].rlim_max)
61156 + acl->res[res].rlim_max = res_add;
61157 +
61158 + /* only log the subject filename, since resource logging is supported for
61159 + single-subject learning only */
61160 + rcu_read_lock();
61161 + cred = __task_cred(task);
61162 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61163 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61164 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61165 + "", (unsigned long) res, &task->signal->saved_ip);
61166 + rcu_read_unlock();
61167 + }
61168 +
61169 + return;
61170 +}
61171 +EXPORT_SYMBOL(gr_learn_resource);
61172 +#endif
61173 +
61174 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61175 +void
61176 +pax_set_initial_flags(struct linux_binprm *bprm)
61177 +{
61178 + struct task_struct *task = current;
61179 + struct acl_subject_label *proc;
61180 + unsigned long flags;
61181 +
61182 + if (unlikely(!(gr_status & GR_READY)))
61183 + return;
61184 +
61185 + flags = pax_get_flags(task);
61186 +
61187 + proc = task->acl;
61188 +
61189 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61190 + flags &= ~MF_PAX_PAGEEXEC;
61191 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61192 + flags &= ~MF_PAX_SEGMEXEC;
61193 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61194 + flags &= ~MF_PAX_RANDMMAP;
61195 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61196 + flags &= ~MF_PAX_EMUTRAMP;
61197 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61198 + flags &= ~MF_PAX_MPROTECT;
61199 +
61200 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61201 + flags |= MF_PAX_PAGEEXEC;
61202 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61203 + flags |= MF_PAX_SEGMEXEC;
61204 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61205 + flags |= MF_PAX_RANDMMAP;
61206 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61207 + flags |= MF_PAX_EMUTRAMP;
61208 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61209 + flags |= MF_PAX_MPROTECT;
61210 +
61211 + pax_set_flags(task, flags);
61212 +
61213 + return;
61214 +}
61215 +#endif
61216 +
61217 +int
61218 +gr_handle_proc_ptrace(struct task_struct *task)
61219 +{
61220 + struct file *filp;
61221 + struct task_struct *tmp = task;
61222 + struct task_struct *curtemp = current;
61223 + __u32 retmode;
61224 +
61225 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61226 + if (unlikely(!(gr_status & GR_READY)))
61227 + return 0;
61228 +#endif
61229 +
61230 + read_lock(&tasklist_lock);
61231 + read_lock(&grsec_exec_file_lock);
61232 + filp = task->exec_file;
61233 +
61234 + while (task_pid_nr(tmp) > 0) {
61235 + if (tmp == curtemp)
61236 + break;
61237 + tmp = tmp->real_parent;
61238 + }
61239 +
61240 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61241 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61242 + read_unlock(&grsec_exec_file_lock);
61243 + read_unlock(&tasklist_lock);
61244 + return 1;
61245 + }
61246 +
61247 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61248 + if (!(gr_status & GR_READY)) {
61249 + read_unlock(&grsec_exec_file_lock);
61250 + read_unlock(&tasklist_lock);
61251 + return 0;
61252 + }
61253 +#endif
61254 +
61255 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61256 + read_unlock(&grsec_exec_file_lock);
61257 + read_unlock(&tasklist_lock);
61258 +
61259 + if (retmode & GR_NOPTRACE)
61260 + return 1;
61261 +
61262 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61263 + && (current->acl != task->acl || (current->acl != current->role->root_label
61264 + && task_pid_nr(current) != task_pid_nr(task))))
61265 + return 1;
61266 +
61267 + return 0;
61268 +}
61269 +
61270 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61271 +{
61272 + if (unlikely(!(gr_status & GR_READY)))
61273 + return;
61274 +
61275 + if (!(current->role->roletype & GR_ROLE_GOD))
61276 + return;
61277 +
61278 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61279 + p->role->rolename, gr_task_roletype_to_char(p),
61280 + p->acl->filename);
61281 +}
61282 +
61283 +int
61284 +gr_handle_ptrace(struct task_struct *task, const long request)
61285 +{
61286 + struct task_struct *tmp = task;
61287 + struct task_struct *curtemp = current;
61288 + __u32 retmode;
61289 +
61290 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61291 + if (unlikely(!(gr_status & GR_READY)))
61292 + return 0;
61293 +#endif
61294 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61295 + read_lock(&tasklist_lock);
61296 + while (task_pid_nr(tmp) > 0) {
61297 + if (tmp == curtemp)
61298 + break;
61299 + tmp = tmp->real_parent;
61300 + }
61301 +
61302 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61303 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61304 + read_unlock(&tasklist_lock);
61305 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61306 + return 1;
61307 + }
61308 + read_unlock(&tasklist_lock);
61309 + }
61310 +
61311 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61312 + if (!(gr_status & GR_READY))
61313 + return 0;
61314 +#endif
61315 +
61316 + read_lock(&grsec_exec_file_lock);
61317 + if (unlikely(!task->exec_file)) {
61318 + read_unlock(&grsec_exec_file_lock);
61319 + return 0;
61320 + }
61321 +
61322 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61323 + read_unlock(&grsec_exec_file_lock);
61324 +
61325 + if (retmode & GR_NOPTRACE) {
61326 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61327 + return 1;
61328 + }
61329 +
61330 + if (retmode & GR_PTRACERD) {
61331 + switch (request) {
61332 + case PTRACE_SEIZE:
61333 + case PTRACE_POKETEXT:
61334 + case PTRACE_POKEDATA:
61335 + case PTRACE_POKEUSR:
61336 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61337 + case PTRACE_SETREGS:
61338 + case PTRACE_SETFPREGS:
61339 +#endif
61340 +#ifdef CONFIG_X86
61341 + case PTRACE_SETFPXREGS:
61342 +#endif
61343 +#ifdef CONFIG_ALTIVEC
61344 + case PTRACE_SETVRREGS:
61345 +#endif
61346 + return 1;
61347 + default:
61348 + return 0;
61349 + }
61350 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61351 + !(current->role->roletype & GR_ROLE_GOD) &&
61352 + (current->acl != task->acl)) {
61353 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61354 + return 1;
61355 + }
61356 +
61357 + return 0;
61358 +}
61359 +
61360 +static int is_writable_mmap(const struct file *filp)
61361 +{
61362 + struct task_struct *task = current;
61363 + struct acl_object_label *obj, *obj2;
61364 +
61365 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61366 + !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))) {
61367 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61368 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61369 + task->role->root_label);
61370 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61371 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61372 + return 1;
61373 + }
61374 + }
61375 + return 0;
61376 +}
61377 +
61378 +int
61379 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61380 +{
61381 + __u32 mode;
61382 +
61383 + if (unlikely(!file || !(prot & PROT_EXEC)))
61384 + return 1;
61385 +
61386 + if (is_writable_mmap(file))
61387 + return 0;
61388 +
61389 + mode =
61390 + gr_search_file(file->f_path.dentry,
61391 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61392 + file->f_path.mnt);
61393 +
61394 + if (!gr_tpe_allow(file))
61395 + return 0;
61396 +
61397 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61398 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61399 + return 0;
61400 + } else if (unlikely(!(mode & GR_EXEC))) {
61401 + return 0;
61402 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61403 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61404 + return 1;
61405 + }
61406 +
61407 + return 1;
61408 +}
61409 +
61410 +int
61411 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61412 +{
61413 + __u32 mode;
61414 +
61415 + if (unlikely(!file || !(prot & PROT_EXEC)))
61416 + return 1;
61417 +
61418 + if (is_writable_mmap(file))
61419 + return 0;
61420 +
61421 + mode =
61422 + gr_search_file(file->f_path.dentry,
61423 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61424 + file->f_path.mnt);
61425 +
61426 + if (!gr_tpe_allow(file))
61427 + return 0;
61428 +
61429 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61430 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61431 + return 0;
61432 + } else if (unlikely(!(mode & GR_EXEC))) {
61433 + return 0;
61434 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61435 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61436 + return 1;
61437 + }
61438 +
61439 + return 1;
61440 +}
61441 +
61442 +void
61443 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61444 +{
61445 + unsigned long runtime;
61446 + unsigned long cputime;
61447 + unsigned int wday, cday;
61448 + __u8 whr, chr;
61449 + __u8 wmin, cmin;
61450 + __u8 wsec, csec;
61451 + struct timespec timeval;
61452 +
61453 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61454 + !(task->acl->mode & GR_PROCACCT)))
61455 + return;
61456 +
61457 + do_posix_clock_monotonic_gettime(&timeval);
61458 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61459 + wday = runtime / (3600 * 24);
61460 + runtime -= wday * (3600 * 24);
61461 + whr = runtime / 3600;
61462 + runtime -= whr * 3600;
61463 + wmin = runtime / 60;
61464 + runtime -= wmin * 60;
61465 + wsec = runtime;
61466 +
61467 + cputime = (task->utime + task->stime) / HZ;
61468 + cday = cputime / (3600 * 24);
61469 + cputime -= cday * (3600 * 24);
61470 + chr = cputime / 3600;
61471 + cputime -= chr * 3600;
61472 + cmin = cputime / 60;
61473 + cputime -= cmin * 60;
61474 + csec = cputime;
61475 +
61476 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61477 +
61478 + return;
61479 +}
61480 +
61481 +void gr_set_kernel_label(struct task_struct *task)
61482 +{
61483 + if (gr_status & GR_READY) {
61484 + task->role = kernel_role;
61485 + task->acl = kernel_role->root_label;
61486 + }
61487 + return;
61488 +}
61489 +
61490 +#ifdef CONFIG_TASKSTATS
61491 +int gr_is_taskstats_denied(int pid)
61492 +{
61493 + struct task_struct *task;
61494 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61495 + const struct cred *cred;
61496 +#endif
61497 + int ret = 0;
61498 +
61499 + /* restrict taskstats viewing to un-chrooted root users
61500 + who have the 'view' subject flag if the RBAC system is enabled
61501 + */
61502 +
61503 + rcu_read_lock();
61504 + read_lock(&tasklist_lock);
61505 + task = find_task_by_vpid(pid);
61506 + if (task) {
61507 +#ifdef CONFIG_GRKERNSEC_CHROOT
61508 + if (proc_is_chrooted(task))
61509 + ret = -EACCES;
61510 +#endif
61511 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61512 + cred = __task_cred(task);
61513 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61514 + if (gr_is_global_nonroot(cred->uid))
61515 + ret = -EACCES;
61516 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61517 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
61518 + ret = -EACCES;
61519 +#endif
61520 +#endif
61521 + if (gr_status & GR_READY) {
61522 + if (!(task->acl->mode & GR_VIEW))
61523 + ret = -EACCES;
61524 + }
61525 + } else
61526 + ret = -ENOENT;
61527 +
61528 + read_unlock(&tasklist_lock);
61529 + rcu_read_unlock();
61530 +
61531 + return ret;
61532 +}
61533 +#endif
61534 +
61535 +/* AUXV entries are filled via a descendant of search_binary_handler
61536 + after we've already applied the subject for the target
61537 +*/
61538 +int gr_acl_enable_at_secure(void)
61539 +{
61540 + if (unlikely(!(gr_status & GR_READY)))
61541 + return 0;
61542 +
61543 + if (current->acl->mode & GR_ATSECURE)
61544 + return 1;
61545 +
61546 + return 0;
61547 +}
61548 +
61549 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
61550 +{
61551 + struct task_struct *task = current;
61552 + struct dentry *dentry = file->f_path.dentry;
61553 + struct vfsmount *mnt = file->f_path.mnt;
61554 + struct acl_object_label *obj, *tmp;
61555 + struct acl_subject_label *subj;
61556 + unsigned int bufsize;
61557 + int is_not_root;
61558 + char *path;
61559 + dev_t dev = __get_dev(dentry);
61560 +
61561 + if (unlikely(!(gr_status & GR_READY)))
61562 + return 1;
61563 +
61564 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61565 + return 1;
61566 +
61567 + /* ignore Eric Biederman */
61568 + if (IS_PRIVATE(dentry->d_inode))
61569 + return 1;
61570 +
61571 + subj = task->acl;
61572 + read_lock(&gr_inode_lock);
61573 + do {
61574 + obj = lookup_acl_obj_label(ino, dev, subj);
61575 + if (obj != NULL) {
61576 + read_unlock(&gr_inode_lock);
61577 + return (obj->mode & GR_FIND) ? 1 : 0;
61578 + }
61579 + } while ((subj = subj->parent_subject));
61580 + read_unlock(&gr_inode_lock);
61581 +
61582 + /* this is purely an optimization since we're looking for an object
61583 + for the directory we're doing a readdir on
61584 + if it's possible for any globbed object to match the entry we're
61585 + filling into the directory, then the object we find here will be
61586 + an anchor point with attached globbed objects
61587 + */
61588 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
61589 + if (obj->globbed == NULL)
61590 + return (obj->mode & GR_FIND) ? 1 : 0;
61591 +
61592 + is_not_root = ((obj->filename[0] == '/') &&
61593 + (obj->filename[1] == '\0')) ? 0 : 1;
61594 + bufsize = PAGE_SIZE - namelen - is_not_root;
61595 +
61596 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
61597 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
61598 + return 1;
61599 +
61600 + preempt_disable();
61601 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
61602 + bufsize);
61603 +
61604 + bufsize = strlen(path);
61605 +
61606 + /* if base is "/", don't append an additional slash */
61607 + if (is_not_root)
61608 + *(path + bufsize) = '/';
61609 + memcpy(path + bufsize + is_not_root, name, namelen);
61610 + *(path + bufsize + namelen + is_not_root) = '\0';
61611 +
61612 + tmp = obj->globbed;
61613 + while (tmp) {
61614 + if (!glob_match(tmp->filename, path)) {
61615 + preempt_enable();
61616 + return (tmp->mode & GR_FIND) ? 1 : 0;
61617 + }
61618 + tmp = tmp->next;
61619 + }
61620 + preempt_enable();
61621 + return (obj->mode & GR_FIND) ? 1 : 0;
61622 +}
61623 +
61624 +void gr_put_exec_file(struct task_struct *task)
61625 +{
61626 + struct file *filp;
61627 +
61628 + write_lock(&grsec_exec_file_lock);
61629 + filp = task->exec_file;
61630 + task->exec_file = NULL;
61631 + write_unlock(&grsec_exec_file_lock);
61632 +
61633 + if (filp)
61634 + fput(filp);
61635 +
61636 + return;
61637 +}
61638 +
61639 +
61640 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
61641 +EXPORT_SYMBOL(gr_acl_is_enabled);
61642 +#endif
61643 +EXPORT_SYMBOL(gr_set_kernel_label);
61644 +#ifdef CONFIG_SECURITY
61645 +EXPORT_SYMBOL(gr_check_user_change);
61646 +EXPORT_SYMBOL(gr_check_group_change);
61647 +#endif
61648 +
61649 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
61650 new file mode 100644
61651 index 0000000..34fefda
61652 --- /dev/null
61653 +++ b/grsecurity/gracl_alloc.c
61654 @@ -0,0 +1,105 @@
61655 +#include <linux/kernel.h>
61656 +#include <linux/mm.h>
61657 +#include <linux/slab.h>
61658 +#include <linux/vmalloc.h>
61659 +#include <linux/gracl.h>
61660 +#include <linux/grsecurity.h>
61661 +
61662 +static unsigned long alloc_stack_next = 1;
61663 +static unsigned long alloc_stack_size = 1;
61664 +static void **alloc_stack;
61665 +
61666 +static __inline__ int
61667 +alloc_pop(void)
61668 +{
61669 + if (alloc_stack_next == 1)
61670 + return 0;
61671 +
61672 + kfree(alloc_stack[alloc_stack_next - 2]);
61673 +
61674 + alloc_stack_next--;
61675 +
61676 + return 1;
61677 +}
61678 +
61679 +static __inline__ int
61680 +alloc_push(void *buf)
61681 +{
61682 + if (alloc_stack_next >= alloc_stack_size)
61683 + return 1;
61684 +
61685 + alloc_stack[alloc_stack_next - 1] = buf;
61686 +
61687 + alloc_stack_next++;
61688 +
61689 + return 0;
61690 +}
61691 +
61692 +void *
61693 +acl_alloc(unsigned long len)
61694 +{
61695 + void *ret = NULL;
61696 +
61697 + if (!len || len > PAGE_SIZE)
61698 + goto out;
61699 +
61700 + ret = kmalloc(len, GFP_KERNEL);
61701 +
61702 + if (ret) {
61703 + if (alloc_push(ret)) {
61704 + kfree(ret);
61705 + ret = NULL;
61706 + }
61707 + }
61708 +
61709 +out:
61710 + return ret;
61711 +}
61712 +
61713 +void *
61714 +acl_alloc_num(unsigned long num, unsigned long len)
61715 +{
61716 + if (!len || (num > (PAGE_SIZE / len)))
61717 + return NULL;
61718 +
61719 + return acl_alloc(num * len);
61720 +}
61721 +
61722 +void
61723 +acl_free_all(void)
61724 +{
61725 + if (gr_acl_is_enabled() || !alloc_stack)
61726 + return;
61727 +
61728 + while (alloc_pop()) ;
61729 +
61730 + if (alloc_stack) {
61731 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
61732 + kfree(alloc_stack);
61733 + else
61734 + vfree(alloc_stack);
61735 + }
61736 +
61737 + alloc_stack = NULL;
61738 + alloc_stack_size = 1;
61739 + alloc_stack_next = 1;
61740 +
61741 + return;
61742 +}
61743 +
61744 +int
61745 +acl_alloc_stack_init(unsigned long size)
61746 +{
61747 + if ((size * sizeof (void *)) <= PAGE_SIZE)
61748 + alloc_stack =
61749 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
61750 + else
61751 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
61752 +
61753 + alloc_stack_size = size;
61754 +
61755 + if (!alloc_stack)
61756 + return 0;
61757 + else
61758 + return 1;
61759 +}
61760 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
61761 new file mode 100644
61762 index 0000000..bdd51ea
61763 --- /dev/null
61764 +++ b/grsecurity/gracl_cap.c
61765 @@ -0,0 +1,110 @@
61766 +#include <linux/kernel.h>
61767 +#include <linux/module.h>
61768 +#include <linux/sched.h>
61769 +#include <linux/gracl.h>
61770 +#include <linux/grsecurity.h>
61771 +#include <linux/grinternal.h>
61772 +
61773 +extern const char *captab_log[];
61774 +extern int captab_log_entries;
61775 +
61776 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
61777 +{
61778 + struct acl_subject_label *curracl;
61779 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61780 + kernel_cap_t cap_audit = __cap_empty_set;
61781 +
61782 + if (!gr_acl_is_enabled())
61783 + return 1;
61784 +
61785 + curracl = task->acl;
61786 +
61787 + cap_drop = curracl->cap_lower;
61788 + cap_mask = curracl->cap_mask;
61789 + cap_audit = curracl->cap_invert_audit;
61790 +
61791 + while ((curracl = curracl->parent_subject)) {
61792 + /* if the cap isn't specified in the current computed mask but is specified in the
61793 + current level subject, and is lowered in the current level subject, then add
61794 + it to the set of dropped capabilities
61795 + otherwise, add the current level subject's mask to the current computed mask
61796 + */
61797 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61798 + cap_raise(cap_mask, cap);
61799 + if (cap_raised(curracl->cap_lower, cap))
61800 + cap_raise(cap_drop, cap);
61801 + if (cap_raised(curracl->cap_invert_audit, cap))
61802 + cap_raise(cap_audit, cap);
61803 + }
61804 + }
61805 +
61806 + if (!cap_raised(cap_drop, cap)) {
61807 + if (cap_raised(cap_audit, cap))
61808 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
61809 + return 1;
61810 + }
61811 +
61812 + curracl = task->acl;
61813 +
61814 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
61815 + && cap_raised(cred->cap_effective, cap)) {
61816 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61817 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
61818 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
61819 + gr_to_filename(task->exec_file->f_path.dentry,
61820 + task->exec_file->f_path.mnt) : curracl->filename,
61821 + curracl->filename, 0UL,
61822 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
61823 + return 1;
61824 + }
61825 +
61826 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
61827 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
61828 +
61829 + return 0;
61830 +}
61831 +
61832 +int
61833 +gr_acl_is_capable(const int cap)
61834 +{
61835 + return gr_task_acl_is_capable(current, current_cred(), cap);
61836 +}
61837 +
61838 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
61839 +{
61840 + struct acl_subject_label *curracl;
61841 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61842 +
61843 + if (!gr_acl_is_enabled())
61844 + return 1;
61845 +
61846 + curracl = task->acl;
61847 +
61848 + cap_drop = curracl->cap_lower;
61849 + cap_mask = curracl->cap_mask;
61850 +
61851 + while ((curracl = curracl->parent_subject)) {
61852 + /* if the cap isn't specified in the current computed mask but is specified in the
61853 + current level subject, and is lowered in the current level subject, then add
61854 + it to the set of dropped capabilities
61855 + otherwise, add the current level subject's mask to the current computed mask
61856 + */
61857 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61858 + cap_raise(cap_mask, cap);
61859 + if (cap_raised(curracl->cap_lower, cap))
61860 + cap_raise(cap_drop, cap);
61861 + }
61862 + }
61863 +
61864 + if (!cap_raised(cap_drop, cap))
61865 + return 1;
61866 +
61867 + return 0;
61868 +}
61869 +
61870 +int
61871 +gr_acl_is_capable_nolog(const int cap)
61872 +{
61873 + return gr_task_acl_is_capable_nolog(current, cap);
61874 +}
61875 +
61876 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
61877 new file mode 100644
61878 index 0000000..a340c17
61879 --- /dev/null
61880 +++ b/grsecurity/gracl_fs.c
61881 @@ -0,0 +1,431 @@
61882 +#include <linux/kernel.h>
61883 +#include <linux/sched.h>
61884 +#include <linux/types.h>
61885 +#include <linux/fs.h>
61886 +#include <linux/file.h>
61887 +#include <linux/stat.h>
61888 +#include <linux/grsecurity.h>
61889 +#include <linux/grinternal.h>
61890 +#include <linux/gracl.h>
61891 +
61892 +umode_t
61893 +gr_acl_umask(void)
61894 +{
61895 + if (unlikely(!gr_acl_is_enabled()))
61896 + return 0;
61897 +
61898 + return current->role->umask;
61899 +}
61900 +
61901 +__u32
61902 +gr_acl_handle_hidden_file(const struct dentry * dentry,
61903 + const struct vfsmount * mnt)
61904 +{
61905 + __u32 mode;
61906 +
61907 + if (unlikely(!dentry->d_inode))
61908 + return GR_FIND;
61909 +
61910 + mode =
61911 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
61912 +
61913 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
61914 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61915 + return mode;
61916 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
61917 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61918 + return 0;
61919 + } else if (unlikely(!(mode & GR_FIND)))
61920 + return 0;
61921 +
61922 + return GR_FIND;
61923 +}
61924 +
61925 +__u32
61926 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
61927 + int acc_mode)
61928 +{
61929 + __u32 reqmode = GR_FIND;
61930 + __u32 mode;
61931 +
61932 + if (unlikely(!dentry->d_inode))
61933 + return reqmode;
61934 +
61935 + if (acc_mode & MAY_APPEND)
61936 + reqmode |= GR_APPEND;
61937 + else if (acc_mode & MAY_WRITE)
61938 + reqmode |= GR_WRITE;
61939 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
61940 + reqmode |= GR_READ;
61941 +
61942 + mode =
61943 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61944 + mnt);
61945 +
61946 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61947 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61948 + reqmode & GR_READ ? " reading" : "",
61949 + reqmode & GR_WRITE ? " writing" : reqmode &
61950 + GR_APPEND ? " appending" : "");
61951 + return reqmode;
61952 + } else
61953 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61954 + {
61955 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61956 + reqmode & GR_READ ? " reading" : "",
61957 + reqmode & GR_WRITE ? " writing" : reqmode &
61958 + GR_APPEND ? " appending" : "");
61959 + return 0;
61960 + } else if (unlikely((mode & reqmode) != reqmode))
61961 + return 0;
61962 +
61963 + return reqmode;
61964 +}
61965 +
61966 +__u32
61967 +gr_acl_handle_creat(const struct dentry * dentry,
61968 + const struct dentry * p_dentry,
61969 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
61970 + const int imode)
61971 +{
61972 + __u32 reqmode = GR_WRITE | GR_CREATE;
61973 + __u32 mode;
61974 +
61975 + if (acc_mode & MAY_APPEND)
61976 + reqmode |= GR_APPEND;
61977 + // if a directory was required or the directory already exists, then
61978 + // don't count this open as a read
61979 + if ((acc_mode & MAY_READ) &&
61980 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
61981 + reqmode |= GR_READ;
61982 + if ((open_flags & O_CREAT) &&
61983 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
61984 + reqmode |= GR_SETID;
61985 +
61986 + mode =
61987 + gr_check_create(dentry, p_dentry, p_mnt,
61988 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
61989 +
61990 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61991 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
61992 + reqmode & GR_READ ? " reading" : "",
61993 + reqmode & GR_WRITE ? " writing" : reqmode &
61994 + GR_APPEND ? " appending" : "");
61995 + return reqmode;
61996 + } else
61997 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61998 + {
61999 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62000 + reqmode & GR_READ ? " reading" : "",
62001 + reqmode & GR_WRITE ? " writing" : reqmode &
62002 + GR_APPEND ? " appending" : "");
62003 + return 0;
62004 + } else if (unlikely((mode & reqmode) != reqmode))
62005 + return 0;
62006 +
62007 + return reqmode;
62008 +}
62009 +
62010 +__u32
62011 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62012 + const int fmode)
62013 +{
62014 + __u32 mode, reqmode = GR_FIND;
62015 +
62016 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62017 + reqmode |= GR_EXEC;
62018 + if (fmode & S_IWOTH)
62019 + reqmode |= GR_WRITE;
62020 + if (fmode & S_IROTH)
62021 + reqmode |= GR_READ;
62022 +
62023 + mode =
62024 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62025 + mnt);
62026 +
62027 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62028 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62029 + reqmode & GR_READ ? " reading" : "",
62030 + reqmode & GR_WRITE ? " writing" : "",
62031 + reqmode & GR_EXEC ? " executing" : "");
62032 + return reqmode;
62033 + } else
62034 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62035 + {
62036 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62037 + reqmode & GR_READ ? " reading" : "",
62038 + reqmode & GR_WRITE ? " writing" : "",
62039 + reqmode & GR_EXEC ? " executing" : "");
62040 + return 0;
62041 + } else if (unlikely((mode & reqmode) != reqmode))
62042 + return 0;
62043 +
62044 + return reqmode;
62045 +}
62046 +
62047 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62048 +{
62049 + __u32 mode;
62050 +
62051 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62052 +
62053 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62054 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62055 + return mode;
62056 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62057 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62058 + return 0;
62059 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62060 + return 0;
62061 +
62062 + return (reqmode);
62063 +}
62064 +
62065 +__u32
62066 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62067 +{
62068 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62069 +}
62070 +
62071 +__u32
62072 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62073 +{
62074 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62075 +}
62076 +
62077 +__u32
62078 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62079 +{
62080 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62081 +}
62082 +
62083 +__u32
62084 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62085 +{
62086 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62087 +}
62088 +
62089 +__u32
62090 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62091 + umode_t *modeptr)
62092 +{
62093 + umode_t mode;
62094 +
62095 + *modeptr &= ~gr_acl_umask();
62096 + mode = *modeptr;
62097 +
62098 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62099 + return 1;
62100 +
62101 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62102 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62103 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62104 + GR_CHMOD_ACL_MSG);
62105 + } else {
62106 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62107 + }
62108 +}
62109 +
62110 +__u32
62111 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62112 +{
62113 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62114 +}
62115 +
62116 +__u32
62117 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62118 +{
62119 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62120 +}
62121 +
62122 +__u32
62123 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62124 +{
62125 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62126 +}
62127 +
62128 +__u32
62129 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62130 +{
62131 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62132 + GR_UNIXCONNECT_ACL_MSG);
62133 +}
62134 +
62135 +/* hardlinks require at minimum create and link permission,
62136 + any additional privilege required is based on the
62137 + privilege of the file being linked to
62138 +*/
62139 +__u32
62140 +gr_acl_handle_link(const struct dentry * new_dentry,
62141 + const struct dentry * parent_dentry,
62142 + const struct vfsmount * parent_mnt,
62143 + const struct dentry * old_dentry,
62144 + const struct vfsmount * old_mnt, const struct filename *to)
62145 +{
62146 + __u32 mode;
62147 + __u32 needmode = GR_CREATE | GR_LINK;
62148 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62149 +
62150 + mode =
62151 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62152 + old_mnt);
62153 +
62154 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62155 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62156 + return mode;
62157 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62158 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62159 + return 0;
62160 + } else if (unlikely((mode & needmode) != needmode))
62161 + return 0;
62162 +
62163 + return 1;
62164 +}
62165 +
62166 +__u32
62167 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62168 + const struct dentry * parent_dentry,
62169 + const struct vfsmount * parent_mnt, const struct filename *from)
62170 +{
62171 + __u32 needmode = GR_WRITE | GR_CREATE;
62172 + __u32 mode;
62173 +
62174 + mode =
62175 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62176 + GR_CREATE | GR_AUDIT_CREATE |
62177 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62178 +
62179 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62180 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62181 + return mode;
62182 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62183 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62184 + return 0;
62185 + } else if (unlikely((mode & needmode) != needmode))
62186 + return 0;
62187 +
62188 + return (GR_WRITE | GR_CREATE);
62189 +}
62190 +
62191 +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)
62192 +{
62193 + __u32 mode;
62194 +
62195 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62196 +
62197 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62198 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62199 + return mode;
62200 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62201 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62202 + return 0;
62203 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62204 + return 0;
62205 +
62206 + return (reqmode);
62207 +}
62208 +
62209 +__u32
62210 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62211 + const struct dentry * parent_dentry,
62212 + const struct vfsmount * parent_mnt,
62213 + const int mode)
62214 +{
62215 + __u32 reqmode = GR_WRITE | GR_CREATE;
62216 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62217 + reqmode |= GR_SETID;
62218 +
62219 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62220 + reqmode, GR_MKNOD_ACL_MSG);
62221 +}
62222 +
62223 +__u32
62224 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62225 + const struct dentry *parent_dentry,
62226 + const struct vfsmount *parent_mnt)
62227 +{
62228 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62229 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62230 +}
62231 +
62232 +#define RENAME_CHECK_SUCCESS(old, new) \
62233 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62234 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62235 +
62236 +int
62237 +gr_acl_handle_rename(struct dentry *new_dentry,
62238 + struct dentry *parent_dentry,
62239 + const struct vfsmount *parent_mnt,
62240 + struct dentry *old_dentry,
62241 + struct inode *old_parent_inode,
62242 + struct vfsmount *old_mnt, const struct filename *newname)
62243 +{
62244 + __u32 comp1, comp2;
62245 + int error = 0;
62246 +
62247 + if (unlikely(!gr_acl_is_enabled()))
62248 + return 0;
62249 +
62250 + if (!new_dentry->d_inode) {
62251 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62252 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62253 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62254 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62255 + GR_DELETE | GR_AUDIT_DELETE |
62256 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62257 + GR_SUPPRESS, old_mnt);
62258 + } else {
62259 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62260 + GR_CREATE | GR_DELETE |
62261 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62262 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62263 + GR_SUPPRESS, parent_mnt);
62264 + comp2 =
62265 + gr_search_file(old_dentry,
62266 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62267 + GR_DELETE | GR_AUDIT_DELETE |
62268 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62269 + }
62270 +
62271 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62272 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62273 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62274 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62275 + && !(comp2 & GR_SUPPRESS)) {
62276 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62277 + error = -EACCES;
62278 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62279 + error = -EACCES;
62280 +
62281 + return error;
62282 +}
62283 +
62284 +void
62285 +gr_acl_handle_exit(void)
62286 +{
62287 + u16 id;
62288 + char *rolename;
62289 +
62290 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62291 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62292 + id = current->acl_role_id;
62293 + rolename = current->role->rolename;
62294 + gr_set_acls(1);
62295 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62296 + }
62297 +
62298 + gr_put_exec_file(current);
62299 + return;
62300 +}
62301 +
62302 +int
62303 +gr_acl_handle_procpidmem(const struct task_struct *task)
62304 +{
62305 + if (unlikely(!gr_acl_is_enabled()))
62306 + return 0;
62307 +
62308 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62309 + return -EACCES;
62310 +
62311 + return 0;
62312 +}
62313 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62314 new file mode 100644
62315 index 0000000..8132048
62316 --- /dev/null
62317 +++ b/grsecurity/gracl_ip.c
62318 @@ -0,0 +1,387 @@
62319 +#include <linux/kernel.h>
62320 +#include <asm/uaccess.h>
62321 +#include <asm/errno.h>
62322 +#include <net/sock.h>
62323 +#include <linux/file.h>
62324 +#include <linux/fs.h>
62325 +#include <linux/net.h>
62326 +#include <linux/in.h>
62327 +#include <linux/skbuff.h>
62328 +#include <linux/ip.h>
62329 +#include <linux/udp.h>
62330 +#include <linux/types.h>
62331 +#include <linux/sched.h>
62332 +#include <linux/netdevice.h>
62333 +#include <linux/inetdevice.h>
62334 +#include <linux/gracl.h>
62335 +#include <linux/grsecurity.h>
62336 +#include <linux/grinternal.h>
62337 +
62338 +#define GR_BIND 0x01
62339 +#define GR_CONNECT 0x02
62340 +#define GR_INVERT 0x04
62341 +#define GR_BINDOVERRIDE 0x08
62342 +#define GR_CONNECTOVERRIDE 0x10
62343 +#define GR_SOCK_FAMILY 0x20
62344 +
62345 +static const char * gr_protocols[IPPROTO_MAX] = {
62346 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62347 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62348 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62349 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62350 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62351 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62352 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62353 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62354 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62355 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62356 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62357 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62358 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62359 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62360 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62361 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62362 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62363 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62364 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62365 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62366 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62367 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62368 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62369 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62370 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62371 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62372 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62373 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62374 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62375 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62376 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62377 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62378 + };
62379 +
62380 +static const char * gr_socktypes[SOCK_MAX] = {
62381 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62382 + "unknown:7", "unknown:8", "unknown:9", "packet"
62383 + };
62384 +
62385 +static const char * gr_sockfamilies[AF_MAX+1] = {
62386 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62387 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62388 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62389 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62390 + };
62391 +
62392 +const char *
62393 +gr_proto_to_name(unsigned char proto)
62394 +{
62395 + return gr_protocols[proto];
62396 +}
62397 +
62398 +const char *
62399 +gr_socktype_to_name(unsigned char type)
62400 +{
62401 + return gr_socktypes[type];
62402 +}
62403 +
62404 +const char *
62405 +gr_sockfamily_to_name(unsigned char family)
62406 +{
62407 + return gr_sockfamilies[family];
62408 +}
62409 +
62410 +int
62411 +gr_search_socket(const int domain, const int type, const int protocol)
62412 +{
62413 + struct acl_subject_label *curr;
62414 + const struct cred *cred = current_cred();
62415 +
62416 + if (unlikely(!gr_acl_is_enabled()))
62417 + goto exit;
62418 +
62419 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62420 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62421 + goto exit; // let the kernel handle it
62422 +
62423 + curr = current->acl;
62424 +
62425 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
62426 + /* the family is allowed, if this is PF_INET allow it only if
62427 + the extra sock type/protocol checks pass */
62428 + if (domain == PF_INET)
62429 + goto inet_check;
62430 + goto exit;
62431 + } else {
62432 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62433 + __u32 fakeip = 0;
62434 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62435 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62436 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62437 + gr_to_filename(current->exec_file->f_path.dentry,
62438 + current->exec_file->f_path.mnt) :
62439 + curr->filename, curr->filename,
62440 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62441 + &current->signal->saved_ip);
62442 + goto exit;
62443 + }
62444 + goto exit_fail;
62445 + }
62446 +
62447 +inet_check:
62448 + /* the rest of this checking is for IPv4 only */
62449 + if (!curr->ips)
62450 + goto exit;
62451 +
62452 + if ((curr->ip_type & (1U << type)) &&
62453 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
62454 + goto exit;
62455 +
62456 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62457 + /* we don't place acls on raw sockets , and sometimes
62458 + dgram/ip sockets are opened for ioctl and not
62459 + bind/connect, so we'll fake a bind learn log */
62460 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62461 + __u32 fakeip = 0;
62462 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62463 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62464 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62465 + gr_to_filename(current->exec_file->f_path.dentry,
62466 + current->exec_file->f_path.mnt) :
62467 + curr->filename, curr->filename,
62468 + &fakeip, 0, type,
62469 + protocol, GR_CONNECT, &current->signal->saved_ip);
62470 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62471 + __u32 fakeip = 0;
62472 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62473 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62474 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62475 + gr_to_filename(current->exec_file->f_path.dentry,
62476 + current->exec_file->f_path.mnt) :
62477 + curr->filename, curr->filename,
62478 + &fakeip, 0, type,
62479 + protocol, GR_BIND, &current->signal->saved_ip);
62480 + }
62481 + /* we'll log when they use connect or bind */
62482 + goto exit;
62483 + }
62484 +
62485 +exit_fail:
62486 + if (domain == PF_INET)
62487 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62488 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62489 + else
62490 +#ifndef CONFIG_IPV6
62491 + if (domain != PF_INET6)
62492 +#endif
62493 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
62494 + gr_socktype_to_name(type), protocol);
62495 +
62496 + return 0;
62497 +exit:
62498 + return 1;
62499 +}
62500 +
62501 +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)
62502 +{
62503 + if ((ip->mode & mode) &&
62504 + (ip_port >= ip->low) &&
62505 + (ip_port <= ip->high) &&
62506 + ((ntohl(ip_addr) & our_netmask) ==
62507 + (ntohl(our_addr) & our_netmask))
62508 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
62509 + && (ip->type & (1U << type))) {
62510 + if (ip->mode & GR_INVERT)
62511 + return 2; // specifically denied
62512 + else
62513 + return 1; // allowed
62514 + }
62515 +
62516 + return 0; // not specifically allowed, may continue parsing
62517 +}
62518 +
62519 +static int
62520 +gr_search_connectbind(const int full_mode, struct sock *sk,
62521 + struct sockaddr_in *addr, const int type)
62522 +{
62523 + char iface[IFNAMSIZ] = {0};
62524 + struct acl_subject_label *curr;
62525 + struct acl_ip_label *ip;
62526 + struct inet_sock *isk;
62527 + struct net_device *dev;
62528 + struct in_device *idev;
62529 + unsigned long i;
62530 + int ret;
62531 + int mode = full_mode & (GR_BIND | GR_CONNECT);
62532 + __u32 ip_addr = 0;
62533 + __u32 our_addr;
62534 + __u32 our_netmask;
62535 + char *p;
62536 + __u16 ip_port = 0;
62537 + const struct cred *cred = current_cred();
62538 +
62539 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
62540 + return 0;
62541 +
62542 + curr = current->acl;
62543 + isk = inet_sk(sk);
62544 +
62545 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
62546 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
62547 + addr->sin_addr.s_addr = curr->inaddr_any_override;
62548 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
62549 + struct sockaddr_in saddr;
62550 + int err;
62551 +
62552 + saddr.sin_family = AF_INET;
62553 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
62554 + saddr.sin_port = isk->inet_sport;
62555 +
62556 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62557 + if (err)
62558 + return err;
62559 +
62560 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62561 + if (err)
62562 + return err;
62563 + }
62564 +
62565 + if (!curr->ips)
62566 + return 0;
62567 +
62568 + ip_addr = addr->sin_addr.s_addr;
62569 + ip_port = ntohs(addr->sin_port);
62570 +
62571 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62572 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62573 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62574 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62575 + gr_to_filename(current->exec_file->f_path.dentry,
62576 + current->exec_file->f_path.mnt) :
62577 + curr->filename, curr->filename,
62578 + &ip_addr, ip_port, type,
62579 + sk->sk_protocol, mode, &current->signal->saved_ip);
62580 + return 0;
62581 + }
62582 +
62583 + for (i = 0; i < curr->ip_num; i++) {
62584 + ip = *(curr->ips + i);
62585 + if (ip->iface != NULL) {
62586 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
62587 + p = strchr(iface, ':');
62588 + if (p != NULL)
62589 + *p = '\0';
62590 + dev = dev_get_by_name(sock_net(sk), iface);
62591 + if (dev == NULL)
62592 + continue;
62593 + idev = in_dev_get(dev);
62594 + if (idev == NULL) {
62595 + dev_put(dev);
62596 + continue;
62597 + }
62598 + rcu_read_lock();
62599 + for_ifa(idev) {
62600 + if (!strcmp(ip->iface, ifa->ifa_label)) {
62601 + our_addr = ifa->ifa_address;
62602 + our_netmask = 0xffffffff;
62603 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62604 + if (ret == 1) {
62605 + rcu_read_unlock();
62606 + in_dev_put(idev);
62607 + dev_put(dev);
62608 + return 0;
62609 + } else if (ret == 2) {
62610 + rcu_read_unlock();
62611 + in_dev_put(idev);
62612 + dev_put(dev);
62613 + goto denied;
62614 + }
62615 + }
62616 + } endfor_ifa(idev);
62617 + rcu_read_unlock();
62618 + in_dev_put(idev);
62619 + dev_put(dev);
62620 + } else {
62621 + our_addr = ip->addr;
62622 + our_netmask = ip->netmask;
62623 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62624 + if (ret == 1)
62625 + return 0;
62626 + else if (ret == 2)
62627 + goto denied;
62628 + }
62629 + }
62630 +
62631 +denied:
62632 + if (mode == GR_BIND)
62633 + 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));
62634 + else if (mode == GR_CONNECT)
62635 + 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));
62636 +
62637 + return -EACCES;
62638 +}
62639 +
62640 +int
62641 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
62642 +{
62643 + /* always allow disconnection of dgram sockets with connect */
62644 + if (addr->sin_family == AF_UNSPEC)
62645 + return 0;
62646 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
62647 +}
62648 +
62649 +int
62650 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
62651 +{
62652 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
62653 +}
62654 +
62655 +int gr_search_listen(struct socket *sock)
62656 +{
62657 + struct sock *sk = sock->sk;
62658 + struct sockaddr_in addr;
62659 +
62660 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62661 + addr.sin_port = inet_sk(sk)->inet_sport;
62662 +
62663 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62664 +}
62665 +
62666 +int gr_search_accept(struct socket *sock)
62667 +{
62668 + struct sock *sk = sock->sk;
62669 + struct sockaddr_in addr;
62670 +
62671 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62672 + addr.sin_port = inet_sk(sk)->inet_sport;
62673 +
62674 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62675 +}
62676 +
62677 +int
62678 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
62679 +{
62680 + if (addr)
62681 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
62682 + else {
62683 + struct sockaddr_in sin;
62684 + const struct inet_sock *inet = inet_sk(sk);
62685 +
62686 + sin.sin_addr.s_addr = inet->inet_daddr;
62687 + sin.sin_port = inet->inet_dport;
62688 +
62689 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62690 + }
62691 +}
62692 +
62693 +int
62694 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
62695 +{
62696 + struct sockaddr_in sin;
62697 +
62698 + if (unlikely(skb->len < sizeof (struct udphdr)))
62699 + return 0; // skip this packet
62700 +
62701 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
62702 + sin.sin_port = udp_hdr(skb)->source;
62703 +
62704 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62705 +}
62706 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
62707 new file mode 100644
62708 index 0000000..25f54ef
62709 --- /dev/null
62710 +++ b/grsecurity/gracl_learn.c
62711 @@ -0,0 +1,207 @@
62712 +#include <linux/kernel.h>
62713 +#include <linux/mm.h>
62714 +#include <linux/sched.h>
62715 +#include <linux/poll.h>
62716 +#include <linux/string.h>
62717 +#include <linux/file.h>
62718 +#include <linux/types.h>
62719 +#include <linux/vmalloc.h>
62720 +#include <linux/grinternal.h>
62721 +
62722 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
62723 + size_t count, loff_t *ppos);
62724 +extern int gr_acl_is_enabled(void);
62725 +
62726 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
62727 +static int gr_learn_attached;
62728 +
62729 +/* use a 512k buffer */
62730 +#define LEARN_BUFFER_SIZE (512 * 1024)
62731 +
62732 +static DEFINE_SPINLOCK(gr_learn_lock);
62733 +static DEFINE_MUTEX(gr_learn_user_mutex);
62734 +
62735 +/* we need to maintain two buffers, so that the kernel context of grlearn
62736 + uses a semaphore around the userspace copying, and the other kernel contexts
62737 + use a spinlock when copying into the buffer, since they cannot sleep
62738 +*/
62739 +static char *learn_buffer;
62740 +static char *learn_buffer_user;
62741 +static int learn_buffer_len;
62742 +static int learn_buffer_user_len;
62743 +
62744 +static ssize_t
62745 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
62746 +{
62747 + DECLARE_WAITQUEUE(wait, current);
62748 + ssize_t retval = 0;
62749 +
62750 + add_wait_queue(&learn_wait, &wait);
62751 + set_current_state(TASK_INTERRUPTIBLE);
62752 + do {
62753 + mutex_lock(&gr_learn_user_mutex);
62754 + spin_lock(&gr_learn_lock);
62755 + if (learn_buffer_len)
62756 + break;
62757 + spin_unlock(&gr_learn_lock);
62758 + mutex_unlock(&gr_learn_user_mutex);
62759 + if (file->f_flags & O_NONBLOCK) {
62760 + retval = -EAGAIN;
62761 + goto out;
62762 + }
62763 + if (signal_pending(current)) {
62764 + retval = -ERESTARTSYS;
62765 + goto out;
62766 + }
62767 +
62768 + schedule();
62769 + } while (1);
62770 +
62771 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
62772 + learn_buffer_user_len = learn_buffer_len;
62773 + retval = learn_buffer_len;
62774 + learn_buffer_len = 0;
62775 +
62776 + spin_unlock(&gr_learn_lock);
62777 +
62778 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
62779 + retval = -EFAULT;
62780 +
62781 + mutex_unlock(&gr_learn_user_mutex);
62782 +out:
62783 + set_current_state(TASK_RUNNING);
62784 + remove_wait_queue(&learn_wait, &wait);
62785 + return retval;
62786 +}
62787 +
62788 +static unsigned int
62789 +poll_learn(struct file * file, poll_table * wait)
62790 +{
62791 + poll_wait(file, &learn_wait, wait);
62792 +
62793 + if (learn_buffer_len)
62794 + return (POLLIN | POLLRDNORM);
62795 +
62796 + return 0;
62797 +}
62798 +
62799 +void
62800 +gr_clear_learn_entries(void)
62801 +{
62802 + char *tmp;
62803 +
62804 + mutex_lock(&gr_learn_user_mutex);
62805 + spin_lock(&gr_learn_lock);
62806 + tmp = learn_buffer;
62807 + learn_buffer = NULL;
62808 + spin_unlock(&gr_learn_lock);
62809 + if (tmp)
62810 + vfree(tmp);
62811 + if (learn_buffer_user != NULL) {
62812 + vfree(learn_buffer_user);
62813 + learn_buffer_user = NULL;
62814 + }
62815 + learn_buffer_len = 0;
62816 + mutex_unlock(&gr_learn_user_mutex);
62817 +
62818 + return;
62819 +}
62820 +
62821 +void
62822 +gr_add_learn_entry(const char *fmt, ...)
62823 +{
62824 + va_list args;
62825 + unsigned int len;
62826 +
62827 + if (!gr_learn_attached)
62828 + return;
62829 +
62830 + spin_lock(&gr_learn_lock);
62831 +
62832 + /* leave a gap at the end so we know when it's "full" but don't have to
62833 + compute the exact length of the string we're trying to append
62834 + */
62835 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
62836 + spin_unlock(&gr_learn_lock);
62837 + wake_up_interruptible(&learn_wait);
62838 + return;
62839 + }
62840 + if (learn_buffer == NULL) {
62841 + spin_unlock(&gr_learn_lock);
62842 + return;
62843 + }
62844 +
62845 + va_start(args, fmt);
62846 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
62847 + va_end(args);
62848 +
62849 + learn_buffer_len += len + 1;
62850 +
62851 + spin_unlock(&gr_learn_lock);
62852 + wake_up_interruptible(&learn_wait);
62853 +
62854 + return;
62855 +}
62856 +
62857 +static int
62858 +open_learn(struct inode *inode, struct file *file)
62859 +{
62860 + if (file->f_mode & FMODE_READ && gr_learn_attached)
62861 + return -EBUSY;
62862 + if (file->f_mode & FMODE_READ) {
62863 + int retval = 0;
62864 + mutex_lock(&gr_learn_user_mutex);
62865 + if (learn_buffer == NULL)
62866 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
62867 + if (learn_buffer_user == NULL)
62868 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
62869 + if (learn_buffer == NULL) {
62870 + retval = -ENOMEM;
62871 + goto out_error;
62872 + }
62873 + if (learn_buffer_user == NULL) {
62874 + retval = -ENOMEM;
62875 + goto out_error;
62876 + }
62877 + learn_buffer_len = 0;
62878 + learn_buffer_user_len = 0;
62879 + gr_learn_attached = 1;
62880 +out_error:
62881 + mutex_unlock(&gr_learn_user_mutex);
62882 + return retval;
62883 + }
62884 + return 0;
62885 +}
62886 +
62887 +static int
62888 +close_learn(struct inode *inode, struct file *file)
62889 +{
62890 + if (file->f_mode & FMODE_READ) {
62891 + char *tmp = NULL;
62892 + mutex_lock(&gr_learn_user_mutex);
62893 + spin_lock(&gr_learn_lock);
62894 + tmp = learn_buffer;
62895 + learn_buffer = NULL;
62896 + spin_unlock(&gr_learn_lock);
62897 + if (tmp)
62898 + vfree(tmp);
62899 + if (learn_buffer_user != NULL) {
62900 + vfree(learn_buffer_user);
62901 + learn_buffer_user = NULL;
62902 + }
62903 + learn_buffer_len = 0;
62904 + learn_buffer_user_len = 0;
62905 + gr_learn_attached = 0;
62906 + mutex_unlock(&gr_learn_user_mutex);
62907 + }
62908 +
62909 + return 0;
62910 +}
62911 +
62912 +const struct file_operations grsec_fops = {
62913 + .read = read_learn,
62914 + .write = write_grsec_handler,
62915 + .open = open_learn,
62916 + .release = close_learn,
62917 + .poll = poll_learn,
62918 +};
62919 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
62920 new file mode 100644
62921 index 0000000..39645c9
62922 --- /dev/null
62923 +++ b/grsecurity/gracl_res.c
62924 @@ -0,0 +1,68 @@
62925 +#include <linux/kernel.h>
62926 +#include <linux/sched.h>
62927 +#include <linux/gracl.h>
62928 +#include <linux/grinternal.h>
62929 +
62930 +static const char *restab_log[] = {
62931 + [RLIMIT_CPU] = "RLIMIT_CPU",
62932 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
62933 + [RLIMIT_DATA] = "RLIMIT_DATA",
62934 + [RLIMIT_STACK] = "RLIMIT_STACK",
62935 + [RLIMIT_CORE] = "RLIMIT_CORE",
62936 + [RLIMIT_RSS] = "RLIMIT_RSS",
62937 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
62938 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
62939 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
62940 + [RLIMIT_AS] = "RLIMIT_AS",
62941 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
62942 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
62943 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
62944 + [RLIMIT_NICE] = "RLIMIT_NICE",
62945 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
62946 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
62947 + [GR_CRASH_RES] = "RLIMIT_CRASH"
62948 +};
62949 +
62950 +void
62951 +gr_log_resource(const struct task_struct *task,
62952 + const int res, const unsigned long wanted, const int gt)
62953 +{
62954 + const struct cred *cred;
62955 + unsigned long rlim;
62956 +
62957 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
62958 + return;
62959 +
62960 + // not yet supported resource
62961 + if (unlikely(!restab_log[res]))
62962 + return;
62963 +
62964 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
62965 + rlim = task_rlimit_max(task, res);
62966 + else
62967 + rlim = task_rlimit(task, res);
62968 +
62969 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
62970 + return;
62971 +
62972 + rcu_read_lock();
62973 + cred = __task_cred(task);
62974 +
62975 + if (res == RLIMIT_NPROC &&
62976 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
62977 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
62978 + goto out_rcu_unlock;
62979 + else if (res == RLIMIT_MEMLOCK &&
62980 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
62981 + goto out_rcu_unlock;
62982 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
62983 + goto out_rcu_unlock;
62984 + rcu_read_unlock();
62985 +
62986 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
62987 +
62988 + return;
62989 +out_rcu_unlock:
62990 + rcu_read_unlock();
62991 + return;
62992 +}
62993 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
62994 new file mode 100644
62995 index 0000000..4dcc92a
62996 --- /dev/null
62997 +++ b/grsecurity/gracl_segv.c
62998 @@ -0,0 +1,305 @@
62999 +#include <linux/kernel.h>
63000 +#include <linux/mm.h>
63001 +#include <asm/uaccess.h>
63002 +#include <asm/errno.h>
63003 +#include <asm/mman.h>
63004 +#include <net/sock.h>
63005 +#include <linux/file.h>
63006 +#include <linux/fs.h>
63007 +#include <linux/net.h>
63008 +#include <linux/in.h>
63009 +#include <linux/slab.h>
63010 +#include <linux/types.h>
63011 +#include <linux/sched.h>
63012 +#include <linux/timer.h>
63013 +#include <linux/gracl.h>
63014 +#include <linux/grsecurity.h>
63015 +#include <linux/grinternal.h>
63016 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63017 +#include <linux/magic.h>
63018 +#include <linux/pagemap.h>
63019 +#include "../fs/btrfs/async-thread.h"
63020 +#include "../fs/btrfs/ctree.h"
63021 +#include "../fs/btrfs/btrfs_inode.h"
63022 +#endif
63023 +
63024 +static struct crash_uid *uid_set;
63025 +static unsigned short uid_used;
63026 +static DEFINE_SPINLOCK(gr_uid_lock);
63027 +extern rwlock_t gr_inode_lock;
63028 +extern struct acl_subject_label *
63029 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63030 + struct acl_role_label *role);
63031 +
63032 +static inline dev_t __get_dev(const struct dentry *dentry)
63033 +{
63034 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63035 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63036 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63037 + else
63038 +#endif
63039 + return dentry->d_sb->s_dev;
63040 +}
63041 +
63042 +int
63043 +gr_init_uidset(void)
63044 +{
63045 + uid_set =
63046 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63047 + uid_used = 0;
63048 +
63049 + return uid_set ? 1 : 0;
63050 +}
63051 +
63052 +void
63053 +gr_free_uidset(void)
63054 +{
63055 + if (uid_set)
63056 + kfree(uid_set);
63057 +
63058 + return;
63059 +}
63060 +
63061 +int
63062 +gr_find_uid(const uid_t uid)
63063 +{
63064 + struct crash_uid *tmp = uid_set;
63065 + uid_t buid;
63066 + int low = 0, high = uid_used - 1, mid;
63067 +
63068 + while (high >= low) {
63069 + mid = (low + high) >> 1;
63070 + buid = tmp[mid].uid;
63071 + if (buid == uid)
63072 + return mid;
63073 + if (buid > uid)
63074 + high = mid - 1;
63075 + if (buid < uid)
63076 + low = mid + 1;
63077 + }
63078 +
63079 + return -1;
63080 +}
63081 +
63082 +static __inline__ void
63083 +gr_insertsort(void)
63084 +{
63085 + unsigned short i, j;
63086 + struct crash_uid index;
63087 +
63088 + for (i = 1; i < uid_used; i++) {
63089 + index = uid_set[i];
63090 + j = i;
63091 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63092 + uid_set[j] = uid_set[j - 1];
63093 + j--;
63094 + }
63095 + uid_set[j] = index;
63096 + }
63097 +
63098 + return;
63099 +}
63100 +
63101 +static __inline__ void
63102 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63103 +{
63104 + int loc;
63105 + uid_t uid = GR_GLOBAL_UID(kuid);
63106 +
63107 + if (uid_used == GR_UIDTABLE_MAX)
63108 + return;
63109 +
63110 + loc = gr_find_uid(uid);
63111 +
63112 + if (loc >= 0) {
63113 + uid_set[loc].expires = expires;
63114 + return;
63115 + }
63116 +
63117 + uid_set[uid_used].uid = uid;
63118 + uid_set[uid_used].expires = expires;
63119 + uid_used++;
63120 +
63121 + gr_insertsort();
63122 +
63123 + return;
63124 +}
63125 +
63126 +void
63127 +gr_remove_uid(const unsigned short loc)
63128 +{
63129 + unsigned short i;
63130 +
63131 + for (i = loc + 1; i < uid_used; i++)
63132 + uid_set[i - 1] = uid_set[i];
63133 +
63134 + uid_used--;
63135 +
63136 + return;
63137 +}
63138 +
63139 +int
63140 +gr_check_crash_uid(const kuid_t kuid)
63141 +{
63142 + int loc;
63143 + int ret = 0;
63144 + uid_t uid;
63145 +
63146 + if (unlikely(!gr_acl_is_enabled()))
63147 + return 0;
63148 +
63149 + uid = GR_GLOBAL_UID(kuid);
63150 +
63151 + spin_lock(&gr_uid_lock);
63152 + loc = gr_find_uid(uid);
63153 +
63154 + if (loc < 0)
63155 + goto out_unlock;
63156 +
63157 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63158 + gr_remove_uid(loc);
63159 + else
63160 + ret = 1;
63161 +
63162 +out_unlock:
63163 + spin_unlock(&gr_uid_lock);
63164 + return ret;
63165 +}
63166 +
63167 +static __inline__ int
63168 +proc_is_setxid(const struct cred *cred)
63169 +{
63170 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63171 + !uid_eq(cred->uid, cred->fsuid))
63172 + return 1;
63173 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63174 + !gid_eq(cred->gid, cred->fsgid))
63175 + return 1;
63176 +
63177 + return 0;
63178 +}
63179 +
63180 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63181 +
63182 +void
63183 +gr_handle_crash(struct task_struct *task, const int sig)
63184 +{
63185 + struct acl_subject_label *curr;
63186 + struct task_struct *tsk, *tsk2;
63187 + const struct cred *cred;
63188 + const struct cred *cred2;
63189 +
63190 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63191 + return;
63192 +
63193 + if (unlikely(!gr_acl_is_enabled()))
63194 + return;
63195 +
63196 + curr = task->acl;
63197 +
63198 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63199 + return;
63200 +
63201 + if (time_before_eq(curr->expires, get_seconds())) {
63202 + curr->expires = 0;
63203 + curr->crashes = 0;
63204 + }
63205 +
63206 + curr->crashes++;
63207 +
63208 + if (!curr->expires)
63209 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63210 +
63211 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63212 + time_after(curr->expires, get_seconds())) {
63213 + rcu_read_lock();
63214 + cred = __task_cred(task);
63215 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63216 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63217 + spin_lock(&gr_uid_lock);
63218 + gr_insert_uid(cred->uid, curr->expires);
63219 + spin_unlock(&gr_uid_lock);
63220 + curr->expires = 0;
63221 + curr->crashes = 0;
63222 + read_lock(&tasklist_lock);
63223 + do_each_thread(tsk2, tsk) {
63224 + cred2 = __task_cred(tsk);
63225 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63226 + gr_fake_force_sig(SIGKILL, tsk);
63227 + } while_each_thread(tsk2, tsk);
63228 + read_unlock(&tasklist_lock);
63229 + } else {
63230 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63231 + read_lock(&tasklist_lock);
63232 + read_lock(&grsec_exec_file_lock);
63233 + do_each_thread(tsk2, tsk) {
63234 + if (likely(tsk != task)) {
63235 + // if this thread has the same subject as the one that triggered
63236 + // RES_CRASH and it's the same binary, kill it
63237 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63238 + gr_fake_force_sig(SIGKILL, tsk);
63239 + }
63240 + } while_each_thread(tsk2, tsk);
63241 + read_unlock(&grsec_exec_file_lock);
63242 + read_unlock(&tasklist_lock);
63243 + }
63244 + rcu_read_unlock();
63245 + }
63246 +
63247 + return;
63248 +}
63249 +
63250 +int
63251 +gr_check_crash_exec(const struct file *filp)
63252 +{
63253 + struct acl_subject_label *curr;
63254 +
63255 + if (unlikely(!gr_acl_is_enabled()))
63256 + return 0;
63257 +
63258 + read_lock(&gr_inode_lock);
63259 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63260 + __get_dev(filp->f_path.dentry),
63261 + current->role);
63262 + read_unlock(&gr_inode_lock);
63263 +
63264 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63265 + (!curr->crashes && !curr->expires))
63266 + return 0;
63267 +
63268 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63269 + time_after(curr->expires, get_seconds()))
63270 + return 1;
63271 + else if (time_before_eq(curr->expires, get_seconds())) {
63272 + curr->crashes = 0;
63273 + curr->expires = 0;
63274 + }
63275 +
63276 + return 0;
63277 +}
63278 +
63279 +void
63280 +gr_handle_alertkill(struct task_struct *task)
63281 +{
63282 + struct acl_subject_label *curracl;
63283 + __u32 curr_ip;
63284 + struct task_struct *p, *p2;
63285 +
63286 + if (unlikely(!gr_acl_is_enabled()))
63287 + return;
63288 +
63289 + curracl = task->acl;
63290 + curr_ip = task->signal->curr_ip;
63291 +
63292 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63293 + read_lock(&tasklist_lock);
63294 + do_each_thread(p2, p) {
63295 + if (p->signal->curr_ip == curr_ip)
63296 + gr_fake_force_sig(SIGKILL, p);
63297 + } while_each_thread(p2, p);
63298 + read_unlock(&tasklist_lock);
63299 + } else if (curracl->mode & GR_KILLPROC)
63300 + gr_fake_force_sig(SIGKILL, task);
63301 +
63302 + return;
63303 +}
63304 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63305 new file mode 100644
63306 index 0000000..98011b0
63307 --- /dev/null
63308 +++ b/grsecurity/gracl_shm.c
63309 @@ -0,0 +1,40 @@
63310 +#include <linux/kernel.h>
63311 +#include <linux/mm.h>
63312 +#include <linux/sched.h>
63313 +#include <linux/file.h>
63314 +#include <linux/ipc.h>
63315 +#include <linux/gracl.h>
63316 +#include <linux/grsecurity.h>
63317 +#include <linux/grinternal.h>
63318 +
63319 +int
63320 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63321 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63322 +{
63323 + struct task_struct *task;
63324 +
63325 + if (!gr_acl_is_enabled())
63326 + return 1;
63327 +
63328 + rcu_read_lock();
63329 + read_lock(&tasklist_lock);
63330 +
63331 + task = find_task_by_vpid(shm_cprid);
63332 +
63333 + if (unlikely(!task))
63334 + task = find_task_by_vpid(shm_lapid);
63335 +
63336 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63337 + (task_pid_nr(task) == shm_lapid)) &&
63338 + (task->acl->mode & GR_PROTSHM) &&
63339 + (task->acl != current->acl))) {
63340 + read_unlock(&tasklist_lock);
63341 + rcu_read_unlock();
63342 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63343 + return 0;
63344 + }
63345 + read_unlock(&tasklist_lock);
63346 + rcu_read_unlock();
63347 +
63348 + return 1;
63349 +}
63350 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63351 new file mode 100644
63352 index 0000000..bc0be01
63353 --- /dev/null
63354 +++ b/grsecurity/grsec_chdir.c
63355 @@ -0,0 +1,19 @@
63356 +#include <linux/kernel.h>
63357 +#include <linux/sched.h>
63358 +#include <linux/fs.h>
63359 +#include <linux/file.h>
63360 +#include <linux/grsecurity.h>
63361 +#include <linux/grinternal.h>
63362 +
63363 +void
63364 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63365 +{
63366 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63367 + if ((grsec_enable_chdir && grsec_enable_group &&
63368 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63369 + !grsec_enable_group)) {
63370 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63371 + }
63372 +#endif
63373 + return;
63374 +}
63375 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63376 new file mode 100644
63377 index 0000000..bd6e105
63378 --- /dev/null
63379 +++ b/grsecurity/grsec_chroot.c
63380 @@ -0,0 +1,370 @@
63381 +#include <linux/kernel.h>
63382 +#include <linux/module.h>
63383 +#include <linux/sched.h>
63384 +#include <linux/file.h>
63385 +#include <linux/fs.h>
63386 +#include <linux/mount.h>
63387 +#include <linux/types.h>
63388 +#include "../fs/mount.h"
63389 +#include <linux/grsecurity.h>
63390 +#include <linux/grinternal.h>
63391 +
63392 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63393 +static int gr_init_ran;
63394 +#endif
63395 +
63396 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
63397 +{
63398 +#ifdef CONFIG_GRKERNSEC
63399 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63400 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
63401 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63402 + && gr_init_ran
63403 +#endif
63404 + )
63405 + task->gr_is_chrooted = 1;
63406 + else {
63407 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63408 + if (task_pid_nr(task) == 1 && !gr_init_ran)
63409 + gr_init_ran = 1;
63410 +#endif
63411 + task->gr_is_chrooted = 0;
63412 + }
63413 +
63414 + task->gr_chroot_dentry = path->dentry;
63415 +#endif
63416 + return;
63417 +}
63418 +
63419 +void gr_clear_chroot_entries(struct task_struct *task)
63420 +{
63421 +#ifdef CONFIG_GRKERNSEC
63422 + task->gr_is_chrooted = 0;
63423 + task->gr_chroot_dentry = NULL;
63424 +#endif
63425 + return;
63426 +}
63427 +
63428 +int
63429 +gr_handle_chroot_unix(const pid_t pid)
63430 +{
63431 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63432 + struct task_struct *p;
63433 +
63434 + if (unlikely(!grsec_enable_chroot_unix))
63435 + return 1;
63436 +
63437 + if (likely(!proc_is_chrooted(current)))
63438 + return 1;
63439 +
63440 + rcu_read_lock();
63441 + read_lock(&tasklist_lock);
63442 + p = find_task_by_vpid_unrestricted(pid);
63443 + if (unlikely(p && !have_same_root(current, p))) {
63444 + read_unlock(&tasklist_lock);
63445 + rcu_read_unlock();
63446 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63447 + return 0;
63448 + }
63449 + read_unlock(&tasklist_lock);
63450 + rcu_read_unlock();
63451 +#endif
63452 + return 1;
63453 +}
63454 +
63455 +int
63456 +gr_handle_chroot_nice(void)
63457 +{
63458 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63459 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63460 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63461 + return -EPERM;
63462 + }
63463 +#endif
63464 + return 0;
63465 +}
63466 +
63467 +int
63468 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63469 +{
63470 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63471 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63472 + && proc_is_chrooted(current)) {
63473 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63474 + return -EACCES;
63475 + }
63476 +#endif
63477 + return 0;
63478 +}
63479 +
63480 +int
63481 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63482 +{
63483 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63484 + struct task_struct *p;
63485 + int ret = 0;
63486 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63487 + return ret;
63488 +
63489 + read_lock(&tasklist_lock);
63490 + do_each_pid_task(pid, type, p) {
63491 + if (!have_same_root(current, p)) {
63492 + ret = 1;
63493 + goto out;
63494 + }
63495 + } while_each_pid_task(pid, type, p);
63496 +out:
63497 + read_unlock(&tasklist_lock);
63498 + return ret;
63499 +#endif
63500 + return 0;
63501 +}
63502 +
63503 +int
63504 +gr_pid_is_chrooted(struct task_struct *p)
63505 +{
63506 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63507 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
63508 + return 0;
63509 +
63510 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
63511 + !have_same_root(current, p)) {
63512 + return 1;
63513 + }
63514 +#endif
63515 + return 0;
63516 +}
63517 +
63518 +EXPORT_SYMBOL(gr_pid_is_chrooted);
63519 +
63520 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
63521 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
63522 +{
63523 + struct path path, currentroot;
63524 + int ret = 0;
63525 +
63526 + path.dentry = (struct dentry *)u_dentry;
63527 + path.mnt = (struct vfsmount *)u_mnt;
63528 + get_fs_root(current->fs, &currentroot);
63529 + if (path_is_under(&path, &currentroot))
63530 + ret = 1;
63531 + path_put(&currentroot);
63532 +
63533 + return ret;
63534 +}
63535 +#endif
63536 +
63537 +int
63538 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
63539 +{
63540 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
63541 + if (!grsec_enable_chroot_fchdir)
63542 + return 1;
63543 +
63544 + if (!proc_is_chrooted(current))
63545 + return 1;
63546 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
63547 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
63548 + return 0;
63549 + }
63550 +#endif
63551 + return 1;
63552 +}
63553 +
63554 +int
63555 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63556 + const time_t shm_createtime)
63557 +{
63558 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
63559 + struct task_struct *p;
63560 + time_t starttime;
63561 +
63562 + if (unlikely(!grsec_enable_chroot_shmat))
63563 + return 1;
63564 +
63565 + if (likely(!proc_is_chrooted(current)))
63566 + return 1;
63567 +
63568 + rcu_read_lock();
63569 + read_lock(&tasklist_lock);
63570 +
63571 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
63572 + starttime = p->start_time.tv_sec;
63573 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
63574 + if (have_same_root(current, p)) {
63575 + goto allow;
63576 + } else {
63577 + read_unlock(&tasklist_lock);
63578 + rcu_read_unlock();
63579 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63580 + return 0;
63581 + }
63582 + }
63583 + /* creator exited, pid reuse, fall through to next check */
63584 + }
63585 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
63586 + if (unlikely(!have_same_root(current, p))) {
63587 + read_unlock(&tasklist_lock);
63588 + rcu_read_unlock();
63589 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63590 + return 0;
63591 + }
63592 + }
63593 +
63594 +allow:
63595 + read_unlock(&tasklist_lock);
63596 + rcu_read_unlock();
63597 +#endif
63598 + return 1;
63599 +}
63600 +
63601 +void
63602 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
63603 +{
63604 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
63605 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
63606 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
63607 +#endif
63608 + return;
63609 +}
63610 +
63611 +int
63612 +gr_handle_chroot_mknod(const struct dentry *dentry,
63613 + const struct vfsmount *mnt, const int mode)
63614 +{
63615 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
63616 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
63617 + proc_is_chrooted(current)) {
63618 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
63619 + return -EPERM;
63620 + }
63621 +#endif
63622 + return 0;
63623 +}
63624 +
63625 +int
63626 +gr_handle_chroot_mount(const struct dentry *dentry,
63627 + const struct vfsmount *mnt, const char *dev_name)
63628 +{
63629 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
63630 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
63631 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
63632 + return -EPERM;
63633 + }
63634 +#endif
63635 + return 0;
63636 +}
63637 +
63638 +int
63639 +gr_handle_chroot_pivot(void)
63640 +{
63641 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
63642 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
63643 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
63644 + return -EPERM;
63645 + }
63646 +#endif
63647 + return 0;
63648 +}
63649 +
63650 +int
63651 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
63652 +{
63653 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
63654 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
63655 + !gr_is_outside_chroot(dentry, mnt)) {
63656 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
63657 + return -EPERM;
63658 + }
63659 +#endif
63660 + return 0;
63661 +}
63662 +
63663 +extern const char *captab_log[];
63664 +extern int captab_log_entries;
63665 +
63666 +int
63667 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63668 +{
63669 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63670 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63671 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63672 + if (cap_raised(chroot_caps, cap)) {
63673 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
63674 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
63675 + }
63676 + return 0;
63677 + }
63678 + }
63679 +#endif
63680 + return 1;
63681 +}
63682 +
63683 +int
63684 +gr_chroot_is_capable(const int cap)
63685 +{
63686 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63687 + return gr_task_chroot_is_capable(current, current_cred(), cap);
63688 +#endif
63689 + return 1;
63690 +}
63691 +
63692 +int
63693 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
63694 +{
63695 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63696 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63697 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63698 + if (cap_raised(chroot_caps, cap)) {
63699 + return 0;
63700 + }
63701 + }
63702 +#endif
63703 + return 1;
63704 +}
63705 +
63706 +int
63707 +gr_chroot_is_capable_nolog(const int cap)
63708 +{
63709 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63710 + return gr_task_chroot_is_capable_nolog(current, cap);
63711 +#endif
63712 + return 1;
63713 +}
63714 +
63715 +int
63716 +gr_handle_chroot_sysctl(const int op)
63717 +{
63718 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
63719 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
63720 + proc_is_chrooted(current))
63721 + return -EACCES;
63722 +#endif
63723 + return 0;
63724 +}
63725 +
63726 +void
63727 +gr_handle_chroot_chdir(const struct path *path)
63728 +{
63729 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
63730 + if (grsec_enable_chroot_chdir)
63731 + set_fs_pwd(current->fs, path);
63732 +#endif
63733 + return;
63734 +}
63735 +
63736 +int
63737 +gr_handle_chroot_chmod(const struct dentry *dentry,
63738 + const struct vfsmount *mnt, const int mode)
63739 +{
63740 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
63741 + /* allow chmod +s on directories, but not files */
63742 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
63743 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
63744 + proc_is_chrooted(current)) {
63745 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
63746 + return -EPERM;
63747 + }
63748 +#endif
63749 + return 0;
63750 +}
63751 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
63752 new file mode 100644
63753 index 0000000..ce65ceb
63754 --- /dev/null
63755 +++ b/grsecurity/grsec_disabled.c
63756 @@ -0,0 +1,434 @@
63757 +#include <linux/kernel.h>
63758 +#include <linux/module.h>
63759 +#include <linux/sched.h>
63760 +#include <linux/file.h>
63761 +#include <linux/fs.h>
63762 +#include <linux/kdev_t.h>
63763 +#include <linux/net.h>
63764 +#include <linux/in.h>
63765 +#include <linux/ip.h>
63766 +#include <linux/skbuff.h>
63767 +#include <linux/sysctl.h>
63768 +
63769 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
63770 +void
63771 +pax_set_initial_flags(struct linux_binprm *bprm)
63772 +{
63773 + return;
63774 +}
63775 +#endif
63776 +
63777 +#ifdef CONFIG_SYSCTL
63778 +__u32
63779 +gr_handle_sysctl(const struct ctl_table * table, const int op)
63780 +{
63781 + return 0;
63782 +}
63783 +#endif
63784 +
63785 +#ifdef CONFIG_TASKSTATS
63786 +int gr_is_taskstats_denied(int pid)
63787 +{
63788 + return 0;
63789 +}
63790 +#endif
63791 +
63792 +int
63793 +gr_acl_is_enabled(void)
63794 +{
63795 + return 0;
63796 +}
63797 +
63798 +void
63799 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
63800 +{
63801 + return;
63802 +}
63803 +
63804 +int
63805 +gr_handle_rawio(const struct inode *inode)
63806 +{
63807 + return 0;
63808 +}
63809 +
63810 +void
63811 +gr_acl_handle_psacct(struct task_struct *task, const long code)
63812 +{
63813 + return;
63814 +}
63815 +
63816 +int
63817 +gr_handle_ptrace(struct task_struct *task, const long request)
63818 +{
63819 + return 0;
63820 +}
63821 +
63822 +int
63823 +gr_handle_proc_ptrace(struct task_struct *task)
63824 +{
63825 + return 0;
63826 +}
63827 +
63828 +int
63829 +gr_set_acls(const int type)
63830 +{
63831 + return 0;
63832 +}
63833 +
63834 +int
63835 +gr_check_hidden_task(const struct task_struct *tsk)
63836 +{
63837 + return 0;
63838 +}
63839 +
63840 +int
63841 +gr_check_protected_task(const struct task_struct *task)
63842 +{
63843 + return 0;
63844 +}
63845 +
63846 +int
63847 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
63848 +{
63849 + return 0;
63850 +}
63851 +
63852 +void
63853 +gr_copy_label(struct task_struct *tsk)
63854 +{
63855 + return;
63856 +}
63857 +
63858 +void
63859 +gr_set_pax_flags(struct task_struct *task)
63860 +{
63861 + return;
63862 +}
63863 +
63864 +int
63865 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
63866 + const int unsafe_share)
63867 +{
63868 + return 0;
63869 +}
63870 +
63871 +void
63872 +gr_handle_delete(const ino_t ino, const dev_t dev)
63873 +{
63874 + return;
63875 +}
63876 +
63877 +void
63878 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
63879 +{
63880 + return;
63881 +}
63882 +
63883 +void
63884 +gr_handle_crash(struct task_struct *task, const int sig)
63885 +{
63886 + return;
63887 +}
63888 +
63889 +int
63890 +gr_check_crash_exec(const struct file *filp)
63891 +{
63892 + return 0;
63893 +}
63894 +
63895 +int
63896 +gr_check_crash_uid(const kuid_t uid)
63897 +{
63898 + return 0;
63899 +}
63900 +
63901 +void
63902 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
63903 + struct dentry *old_dentry,
63904 + struct dentry *new_dentry,
63905 + struct vfsmount *mnt, const __u8 replace)
63906 +{
63907 + return;
63908 +}
63909 +
63910 +int
63911 +gr_search_socket(const int family, const int type, const int protocol)
63912 +{
63913 + return 1;
63914 +}
63915 +
63916 +int
63917 +gr_search_connectbind(const int mode, const struct socket *sock,
63918 + const struct sockaddr_in *addr)
63919 +{
63920 + return 0;
63921 +}
63922 +
63923 +void
63924 +gr_handle_alertkill(struct task_struct *task)
63925 +{
63926 + return;
63927 +}
63928 +
63929 +__u32
63930 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
63931 +{
63932 + return 1;
63933 +}
63934 +
63935 +__u32
63936 +gr_acl_handle_hidden_file(const struct dentry * dentry,
63937 + const struct vfsmount * mnt)
63938 +{
63939 + return 1;
63940 +}
63941 +
63942 +__u32
63943 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
63944 + int acc_mode)
63945 +{
63946 + return 1;
63947 +}
63948 +
63949 +__u32
63950 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
63951 +{
63952 + return 1;
63953 +}
63954 +
63955 +__u32
63956 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
63957 +{
63958 + return 1;
63959 +}
63960 +
63961 +int
63962 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
63963 + unsigned int *vm_flags)
63964 +{
63965 + return 1;
63966 +}
63967 +
63968 +__u32
63969 +gr_acl_handle_truncate(const struct dentry * dentry,
63970 + const struct vfsmount * mnt)
63971 +{
63972 + return 1;
63973 +}
63974 +
63975 +__u32
63976 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
63977 +{
63978 + return 1;
63979 +}
63980 +
63981 +__u32
63982 +gr_acl_handle_access(const struct dentry * dentry,
63983 + const struct vfsmount * mnt, const int fmode)
63984 +{
63985 + return 1;
63986 +}
63987 +
63988 +__u32
63989 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
63990 + umode_t *mode)
63991 +{
63992 + return 1;
63993 +}
63994 +
63995 +__u32
63996 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
63997 +{
63998 + return 1;
63999 +}
64000 +
64001 +__u32
64002 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64003 +{
64004 + return 1;
64005 +}
64006 +
64007 +void
64008 +grsecurity_init(void)
64009 +{
64010 + return;
64011 +}
64012 +
64013 +umode_t gr_acl_umask(void)
64014 +{
64015 + return 0;
64016 +}
64017 +
64018 +__u32
64019 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64020 + const struct dentry * parent_dentry,
64021 + const struct vfsmount * parent_mnt,
64022 + const int mode)
64023 +{
64024 + return 1;
64025 +}
64026 +
64027 +__u32
64028 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64029 + const struct dentry * parent_dentry,
64030 + const struct vfsmount * parent_mnt)
64031 +{
64032 + return 1;
64033 +}
64034 +
64035 +__u32
64036 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64037 + const struct dentry * parent_dentry,
64038 + const struct vfsmount * parent_mnt, const struct filename *from)
64039 +{
64040 + return 1;
64041 +}
64042 +
64043 +__u32
64044 +gr_acl_handle_link(const struct dentry * new_dentry,
64045 + const struct dentry * parent_dentry,
64046 + const struct vfsmount * parent_mnt,
64047 + const struct dentry * old_dentry,
64048 + const struct vfsmount * old_mnt, const struct filename *to)
64049 +{
64050 + return 1;
64051 +}
64052 +
64053 +int
64054 +gr_acl_handle_rename(const struct dentry *new_dentry,
64055 + const struct dentry *parent_dentry,
64056 + const struct vfsmount *parent_mnt,
64057 + const struct dentry *old_dentry,
64058 + const struct inode *old_parent_inode,
64059 + const struct vfsmount *old_mnt, const struct filename *newname)
64060 +{
64061 + return 0;
64062 +}
64063 +
64064 +int
64065 +gr_acl_handle_filldir(const struct file *file, const char *name,
64066 + const int namelen, const ino_t ino)
64067 +{
64068 + return 1;
64069 +}
64070 +
64071 +int
64072 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64073 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64074 +{
64075 + return 1;
64076 +}
64077 +
64078 +int
64079 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64080 +{
64081 + return 0;
64082 +}
64083 +
64084 +int
64085 +gr_search_accept(const struct socket *sock)
64086 +{
64087 + return 0;
64088 +}
64089 +
64090 +int
64091 +gr_search_listen(const struct socket *sock)
64092 +{
64093 + return 0;
64094 +}
64095 +
64096 +int
64097 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64098 +{
64099 + return 0;
64100 +}
64101 +
64102 +__u32
64103 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64104 +{
64105 + return 1;
64106 +}
64107 +
64108 +__u32
64109 +gr_acl_handle_creat(const struct dentry * dentry,
64110 + const struct dentry * p_dentry,
64111 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64112 + const int imode)
64113 +{
64114 + return 1;
64115 +}
64116 +
64117 +void
64118 +gr_acl_handle_exit(void)
64119 +{
64120 + return;
64121 +}
64122 +
64123 +int
64124 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64125 +{
64126 + return 1;
64127 +}
64128 +
64129 +void
64130 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64131 +{
64132 + return;
64133 +}
64134 +
64135 +int
64136 +gr_acl_handle_procpidmem(const struct task_struct *task)
64137 +{
64138 + return 0;
64139 +}
64140 +
64141 +int
64142 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64143 +{
64144 + return 0;
64145 +}
64146 +
64147 +int
64148 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64149 +{
64150 + return 0;
64151 +}
64152 +
64153 +void
64154 +gr_set_kernel_label(struct task_struct *task)
64155 +{
64156 + return;
64157 +}
64158 +
64159 +int
64160 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64161 +{
64162 + return 0;
64163 +}
64164 +
64165 +int
64166 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64167 +{
64168 + return 0;
64169 +}
64170 +
64171 +int gr_acl_enable_at_secure(void)
64172 +{
64173 + return 0;
64174 +}
64175 +
64176 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64177 +{
64178 + return dentry->d_sb->s_dev;
64179 +}
64180 +
64181 +void gr_put_exec_file(struct task_struct *task)
64182 +{
64183 + return;
64184 +}
64185 +
64186 +EXPORT_SYMBOL(gr_set_kernel_label);
64187 +#ifdef CONFIG_SECURITY
64188 +EXPORT_SYMBOL(gr_check_user_change);
64189 +EXPORT_SYMBOL(gr_check_group_change);
64190 +#endif
64191 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64192 new file mode 100644
64193 index 0000000..387032b
64194 --- /dev/null
64195 +++ b/grsecurity/grsec_exec.c
64196 @@ -0,0 +1,187 @@
64197 +#include <linux/kernel.h>
64198 +#include <linux/sched.h>
64199 +#include <linux/file.h>
64200 +#include <linux/binfmts.h>
64201 +#include <linux/fs.h>
64202 +#include <linux/types.h>
64203 +#include <linux/grdefs.h>
64204 +#include <linux/grsecurity.h>
64205 +#include <linux/grinternal.h>
64206 +#include <linux/capability.h>
64207 +#include <linux/module.h>
64208 +#include <linux/compat.h>
64209 +
64210 +#include <asm/uaccess.h>
64211 +
64212 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64213 +static char gr_exec_arg_buf[132];
64214 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64215 +#endif
64216 +
64217 +struct user_arg_ptr {
64218 +#ifdef CONFIG_COMPAT
64219 + bool is_compat;
64220 +#endif
64221 + union {
64222 + const char __user *const __user *native;
64223 +#ifdef CONFIG_COMPAT
64224 + const compat_uptr_t __user *compat;
64225 +#endif
64226 + } ptr;
64227 +};
64228 +
64229 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64230 +
64231 +void
64232 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64233 +{
64234 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64235 + char *grarg = gr_exec_arg_buf;
64236 + unsigned int i, x, execlen = 0;
64237 + char c;
64238 +
64239 + if (!((grsec_enable_execlog && grsec_enable_group &&
64240 + in_group_p(grsec_audit_gid))
64241 + || (grsec_enable_execlog && !grsec_enable_group)))
64242 + return;
64243 +
64244 + mutex_lock(&gr_exec_arg_mutex);
64245 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64246 +
64247 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64248 + const char __user *p;
64249 + unsigned int len;
64250 +
64251 + p = get_user_arg_ptr(argv, i);
64252 + if (IS_ERR(p))
64253 + goto log;
64254 +
64255 + len = strnlen_user(p, 128 - execlen);
64256 + if (len > 128 - execlen)
64257 + len = 128 - execlen;
64258 + else if (len > 0)
64259 + len--;
64260 + if (copy_from_user(grarg + execlen, p, len))
64261 + goto log;
64262 +
64263 + /* rewrite unprintable characters */
64264 + for (x = 0; x < len; x++) {
64265 + c = *(grarg + execlen + x);
64266 + if (c < 32 || c > 126)
64267 + *(grarg + execlen + x) = ' ';
64268 + }
64269 +
64270 + execlen += len;
64271 + *(grarg + execlen) = ' ';
64272 + *(grarg + execlen + 1) = '\0';
64273 + execlen++;
64274 + }
64275 +
64276 + log:
64277 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64278 + bprm->file->f_path.mnt, grarg);
64279 + mutex_unlock(&gr_exec_arg_mutex);
64280 +#endif
64281 + return;
64282 +}
64283 +
64284 +#ifdef CONFIG_GRKERNSEC
64285 +extern int gr_acl_is_capable(const int cap);
64286 +extern int gr_acl_is_capable_nolog(const int cap);
64287 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64288 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64289 +extern int gr_chroot_is_capable(const int cap);
64290 +extern int gr_chroot_is_capable_nolog(const int cap);
64291 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64292 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64293 +#endif
64294 +
64295 +const char *captab_log[] = {
64296 + "CAP_CHOWN",
64297 + "CAP_DAC_OVERRIDE",
64298 + "CAP_DAC_READ_SEARCH",
64299 + "CAP_FOWNER",
64300 + "CAP_FSETID",
64301 + "CAP_KILL",
64302 + "CAP_SETGID",
64303 + "CAP_SETUID",
64304 + "CAP_SETPCAP",
64305 + "CAP_LINUX_IMMUTABLE",
64306 + "CAP_NET_BIND_SERVICE",
64307 + "CAP_NET_BROADCAST",
64308 + "CAP_NET_ADMIN",
64309 + "CAP_NET_RAW",
64310 + "CAP_IPC_LOCK",
64311 + "CAP_IPC_OWNER",
64312 + "CAP_SYS_MODULE",
64313 + "CAP_SYS_RAWIO",
64314 + "CAP_SYS_CHROOT",
64315 + "CAP_SYS_PTRACE",
64316 + "CAP_SYS_PACCT",
64317 + "CAP_SYS_ADMIN",
64318 + "CAP_SYS_BOOT",
64319 + "CAP_SYS_NICE",
64320 + "CAP_SYS_RESOURCE",
64321 + "CAP_SYS_TIME",
64322 + "CAP_SYS_TTY_CONFIG",
64323 + "CAP_MKNOD",
64324 + "CAP_LEASE",
64325 + "CAP_AUDIT_WRITE",
64326 + "CAP_AUDIT_CONTROL",
64327 + "CAP_SETFCAP",
64328 + "CAP_MAC_OVERRIDE",
64329 + "CAP_MAC_ADMIN",
64330 + "CAP_SYSLOG",
64331 + "CAP_WAKE_ALARM"
64332 +};
64333 +
64334 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64335 +
64336 +int gr_is_capable(const int cap)
64337 +{
64338 +#ifdef CONFIG_GRKERNSEC
64339 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64340 + return 1;
64341 + return 0;
64342 +#else
64343 + return 1;
64344 +#endif
64345 +}
64346 +
64347 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64348 +{
64349 +#ifdef CONFIG_GRKERNSEC
64350 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64351 + return 1;
64352 + return 0;
64353 +#else
64354 + return 1;
64355 +#endif
64356 +}
64357 +
64358 +int gr_is_capable_nolog(const int cap)
64359 +{
64360 +#ifdef CONFIG_GRKERNSEC
64361 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64362 + return 1;
64363 + return 0;
64364 +#else
64365 + return 1;
64366 +#endif
64367 +}
64368 +
64369 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64370 +{
64371 +#ifdef CONFIG_GRKERNSEC
64372 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64373 + return 1;
64374 + return 0;
64375 +#else
64376 + return 1;
64377 +#endif
64378 +}
64379 +
64380 +EXPORT_SYMBOL(gr_is_capable);
64381 +EXPORT_SYMBOL(gr_is_capable_nolog);
64382 +EXPORT_SYMBOL(gr_task_is_capable);
64383 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64384 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64385 new file mode 100644
64386 index 0000000..06cc6ea
64387 --- /dev/null
64388 +++ b/grsecurity/grsec_fifo.c
64389 @@ -0,0 +1,24 @@
64390 +#include <linux/kernel.h>
64391 +#include <linux/sched.h>
64392 +#include <linux/fs.h>
64393 +#include <linux/file.h>
64394 +#include <linux/grinternal.h>
64395 +
64396 +int
64397 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
64398 + const struct dentry *dir, const int flag, const int acc_mode)
64399 +{
64400 +#ifdef CONFIG_GRKERNSEC_FIFO
64401 + const struct cred *cred = current_cred();
64402 +
64403 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64404 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64405 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64406 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64407 + if (!inode_permission(dentry->d_inode, acc_mode))
64408 + 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));
64409 + return -EACCES;
64410 + }
64411 +#endif
64412 + return 0;
64413 +}
64414 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64415 new file mode 100644
64416 index 0000000..8ca18bf
64417 --- /dev/null
64418 +++ b/grsecurity/grsec_fork.c
64419 @@ -0,0 +1,23 @@
64420 +#include <linux/kernel.h>
64421 +#include <linux/sched.h>
64422 +#include <linux/grsecurity.h>
64423 +#include <linux/grinternal.h>
64424 +#include <linux/errno.h>
64425 +
64426 +void
64427 +gr_log_forkfail(const int retval)
64428 +{
64429 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64430 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64431 + switch (retval) {
64432 + case -EAGAIN:
64433 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64434 + break;
64435 + case -ENOMEM:
64436 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64437 + break;
64438 + }
64439 + }
64440 +#endif
64441 + return;
64442 +}
64443 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64444 new file mode 100644
64445 index 0000000..a862e9f
64446 --- /dev/null
64447 +++ b/grsecurity/grsec_init.c
64448 @@ -0,0 +1,283 @@
64449 +#include <linux/kernel.h>
64450 +#include <linux/sched.h>
64451 +#include <linux/mm.h>
64452 +#include <linux/gracl.h>
64453 +#include <linux/slab.h>
64454 +#include <linux/vmalloc.h>
64455 +#include <linux/percpu.h>
64456 +#include <linux/module.h>
64457 +
64458 +int grsec_enable_ptrace_readexec;
64459 +int grsec_enable_setxid;
64460 +int grsec_enable_symlinkown;
64461 +kgid_t grsec_symlinkown_gid;
64462 +int grsec_enable_brute;
64463 +int grsec_enable_link;
64464 +int grsec_enable_dmesg;
64465 +int grsec_enable_harden_ptrace;
64466 +int grsec_enable_fifo;
64467 +int grsec_enable_execlog;
64468 +int grsec_enable_signal;
64469 +int grsec_enable_forkfail;
64470 +int grsec_enable_audit_ptrace;
64471 +int grsec_enable_time;
64472 +int grsec_enable_audit_textrel;
64473 +int grsec_enable_group;
64474 +kgid_t grsec_audit_gid;
64475 +int grsec_enable_chdir;
64476 +int grsec_enable_mount;
64477 +int grsec_enable_rofs;
64478 +int grsec_enable_chroot_findtask;
64479 +int grsec_enable_chroot_mount;
64480 +int grsec_enable_chroot_shmat;
64481 +int grsec_enable_chroot_fchdir;
64482 +int grsec_enable_chroot_double;
64483 +int grsec_enable_chroot_pivot;
64484 +int grsec_enable_chroot_chdir;
64485 +int grsec_enable_chroot_chmod;
64486 +int grsec_enable_chroot_mknod;
64487 +int grsec_enable_chroot_nice;
64488 +int grsec_enable_chroot_execlog;
64489 +int grsec_enable_chroot_caps;
64490 +int grsec_enable_chroot_sysctl;
64491 +int grsec_enable_chroot_unix;
64492 +int grsec_enable_tpe;
64493 +kgid_t grsec_tpe_gid;
64494 +int grsec_enable_blackhole;
64495 +#ifdef CONFIG_IPV6_MODULE
64496 +EXPORT_SYMBOL(grsec_enable_blackhole);
64497 +#endif
64498 +int grsec_lastack_retries;
64499 +int grsec_enable_tpe_all;
64500 +int grsec_enable_tpe_invert;
64501 +int grsec_enable_socket_all;
64502 +kgid_t grsec_socket_all_gid;
64503 +int grsec_enable_socket_client;
64504 +kgid_t grsec_socket_client_gid;
64505 +int grsec_enable_socket_server;
64506 +kgid_t grsec_socket_server_gid;
64507 +int grsec_resource_logging;
64508 +int grsec_disable_privio;
64509 +int grsec_enable_log_rwxmaps;
64510 +int grsec_lock;
64511 +
64512 +DEFINE_SPINLOCK(grsec_alert_lock);
64513 +unsigned long grsec_alert_wtime = 0;
64514 +unsigned long grsec_alert_fyet = 0;
64515 +
64516 +DEFINE_SPINLOCK(grsec_audit_lock);
64517 +
64518 +DEFINE_RWLOCK(grsec_exec_file_lock);
64519 +
64520 +char *gr_shared_page[4];
64521 +
64522 +char *gr_alert_log_fmt;
64523 +char *gr_audit_log_fmt;
64524 +char *gr_alert_log_buf;
64525 +char *gr_audit_log_buf;
64526 +
64527 +extern struct gr_arg *gr_usermode;
64528 +extern unsigned char *gr_system_salt;
64529 +extern unsigned char *gr_system_sum;
64530 +
64531 +void __init
64532 +grsecurity_init(void)
64533 +{
64534 + int j;
64535 + /* create the per-cpu shared pages */
64536 +
64537 +#ifdef CONFIG_X86
64538 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
64539 +#endif
64540 +
64541 + for (j = 0; j < 4; j++) {
64542 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
64543 + if (gr_shared_page[j] == NULL) {
64544 + panic("Unable to allocate grsecurity shared page");
64545 + return;
64546 + }
64547 + }
64548 +
64549 + /* allocate log buffers */
64550 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
64551 + if (!gr_alert_log_fmt) {
64552 + panic("Unable to allocate grsecurity alert log format buffer");
64553 + return;
64554 + }
64555 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
64556 + if (!gr_audit_log_fmt) {
64557 + panic("Unable to allocate grsecurity audit log format buffer");
64558 + return;
64559 + }
64560 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64561 + if (!gr_alert_log_buf) {
64562 + panic("Unable to allocate grsecurity alert log buffer");
64563 + return;
64564 + }
64565 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64566 + if (!gr_audit_log_buf) {
64567 + panic("Unable to allocate grsecurity audit log buffer");
64568 + return;
64569 + }
64570 +
64571 + /* allocate memory for authentication structure */
64572 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
64573 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
64574 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
64575 +
64576 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
64577 + panic("Unable to allocate grsecurity authentication structure");
64578 + return;
64579 + }
64580 +
64581 +
64582 +#ifdef CONFIG_GRKERNSEC_IO
64583 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
64584 + grsec_disable_privio = 1;
64585 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64586 + grsec_disable_privio = 1;
64587 +#else
64588 + grsec_disable_privio = 0;
64589 +#endif
64590 +#endif
64591 +
64592 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
64593 + /* for backward compatibility, tpe_invert always defaults to on if
64594 + enabled in the kernel
64595 + */
64596 + grsec_enable_tpe_invert = 1;
64597 +#endif
64598 +
64599 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64600 +#ifndef CONFIG_GRKERNSEC_SYSCTL
64601 + grsec_lock = 1;
64602 +#endif
64603 +
64604 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64605 + grsec_enable_audit_textrel = 1;
64606 +#endif
64607 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64608 + grsec_enable_log_rwxmaps = 1;
64609 +#endif
64610 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
64611 + grsec_enable_group = 1;
64612 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
64613 +#endif
64614 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64615 + grsec_enable_ptrace_readexec = 1;
64616 +#endif
64617 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64618 + grsec_enable_chdir = 1;
64619 +#endif
64620 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64621 + grsec_enable_harden_ptrace = 1;
64622 +#endif
64623 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64624 + grsec_enable_mount = 1;
64625 +#endif
64626 +#ifdef CONFIG_GRKERNSEC_LINK
64627 + grsec_enable_link = 1;
64628 +#endif
64629 +#ifdef CONFIG_GRKERNSEC_BRUTE
64630 + grsec_enable_brute = 1;
64631 +#endif
64632 +#ifdef CONFIG_GRKERNSEC_DMESG
64633 + grsec_enable_dmesg = 1;
64634 +#endif
64635 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
64636 + grsec_enable_blackhole = 1;
64637 + grsec_lastack_retries = 4;
64638 +#endif
64639 +#ifdef CONFIG_GRKERNSEC_FIFO
64640 + grsec_enable_fifo = 1;
64641 +#endif
64642 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64643 + grsec_enable_execlog = 1;
64644 +#endif
64645 +#ifdef CONFIG_GRKERNSEC_SETXID
64646 + grsec_enable_setxid = 1;
64647 +#endif
64648 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64649 + grsec_enable_signal = 1;
64650 +#endif
64651 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64652 + grsec_enable_forkfail = 1;
64653 +#endif
64654 +#ifdef CONFIG_GRKERNSEC_TIME
64655 + grsec_enable_time = 1;
64656 +#endif
64657 +#ifdef CONFIG_GRKERNSEC_RESLOG
64658 + grsec_resource_logging = 1;
64659 +#endif
64660 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64661 + grsec_enable_chroot_findtask = 1;
64662 +#endif
64663 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64664 + grsec_enable_chroot_unix = 1;
64665 +#endif
64666 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64667 + grsec_enable_chroot_mount = 1;
64668 +#endif
64669 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64670 + grsec_enable_chroot_fchdir = 1;
64671 +#endif
64672 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64673 + grsec_enable_chroot_shmat = 1;
64674 +#endif
64675 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64676 + grsec_enable_audit_ptrace = 1;
64677 +#endif
64678 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64679 + grsec_enable_chroot_double = 1;
64680 +#endif
64681 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64682 + grsec_enable_chroot_pivot = 1;
64683 +#endif
64684 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64685 + grsec_enable_chroot_chdir = 1;
64686 +#endif
64687 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64688 + grsec_enable_chroot_chmod = 1;
64689 +#endif
64690 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64691 + grsec_enable_chroot_mknod = 1;
64692 +#endif
64693 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64694 + grsec_enable_chroot_nice = 1;
64695 +#endif
64696 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64697 + grsec_enable_chroot_execlog = 1;
64698 +#endif
64699 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64700 + grsec_enable_chroot_caps = 1;
64701 +#endif
64702 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64703 + grsec_enable_chroot_sysctl = 1;
64704 +#endif
64705 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64706 + grsec_enable_symlinkown = 1;
64707 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
64708 +#endif
64709 +#ifdef CONFIG_GRKERNSEC_TPE
64710 + grsec_enable_tpe = 1;
64711 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
64712 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
64713 + grsec_enable_tpe_all = 1;
64714 +#endif
64715 +#endif
64716 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
64717 + grsec_enable_socket_all = 1;
64718 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
64719 +#endif
64720 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
64721 + grsec_enable_socket_client = 1;
64722 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
64723 +#endif
64724 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
64725 + grsec_enable_socket_server = 1;
64726 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
64727 +#endif
64728 +#endif
64729 +
64730 + return;
64731 +}
64732 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
64733 new file mode 100644
64734 index 0000000..5e05e20
64735 --- /dev/null
64736 +++ b/grsecurity/grsec_link.c
64737 @@ -0,0 +1,58 @@
64738 +#include <linux/kernel.h>
64739 +#include <linux/sched.h>
64740 +#include <linux/fs.h>
64741 +#include <linux/file.h>
64742 +#include <linux/grinternal.h>
64743 +
64744 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
64745 +{
64746 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64747 + const struct inode *link_inode = link->dentry->d_inode;
64748 +
64749 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
64750 + /* ignore root-owned links, e.g. /proc/self */
64751 + gr_is_global_nonroot(link_inode->i_uid) && target &&
64752 + !uid_eq(link_inode->i_uid, target->i_uid)) {
64753 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
64754 + return 1;
64755 + }
64756 +#endif
64757 + return 0;
64758 +}
64759 +
64760 +int
64761 +gr_handle_follow_link(const struct inode *parent,
64762 + const struct inode *inode,
64763 + const struct dentry *dentry, const struct vfsmount *mnt)
64764 +{
64765 +#ifdef CONFIG_GRKERNSEC_LINK
64766 + const struct cred *cred = current_cred();
64767 +
64768 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
64769 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
64770 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
64771 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
64772 + return -EACCES;
64773 + }
64774 +#endif
64775 + return 0;
64776 +}
64777 +
64778 +int
64779 +gr_handle_hardlink(const struct dentry *dentry,
64780 + const struct vfsmount *mnt,
64781 + struct inode *inode, const int mode, const struct filename *to)
64782 +{
64783 +#ifdef CONFIG_GRKERNSEC_LINK
64784 + const struct cred *cred = current_cred();
64785 +
64786 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
64787 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
64788 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
64789 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
64790 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
64791 + return -EPERM;
64792 + }
64793 +#endif
64794 + return 0;
64795 +}
64796 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
64797 new file mode 100644
64798 index 0000000..7c06085
64799 --- /dev/null
64800 +++ b/grsecurity/grsec_log.c
64801 @@ -0,0 +1,326 @@
64802 +#include <linux/kernel.h>
64803 +#include <linux/sched.h>
64804 +#include <linux/file.h>
64805 +#include <linux/tty.h>
64806 +#include <linux/fs.h>
64807 +#include <linux/grinternal.h>
64808 +
64809 +#ifdef CONFIG_TREE_PREEMPT_RCU
64810 +#define DISABLE_PREEMPT() preempt_disable()
64811 +#define ENABLE_PREEMPT() preempt_enable()
64812 +#else
64813 +#define DISABLE_PREEMPT()
64814 +#define ENABLE_PREEMPT()
64815 +#endif
64816 +
64817 +#define BEGIN_LOCKS(x) \
64818 + DISABLE_PREEMPT(); \
64819 + rcu_read_lock(); \
64820 + read_lock(&tasklist_lock); \
64821 + read_lock(&grsec_exec_file_lock); \
64822 + if (x != GR_DO_AUDIT) \
64823 + spin_lock(&grsec_alert_lock); \
64824 + else \
64825 + spin_lock(&grsec_audit_lock)
64826 +
64827 +#define END_LOCKS(x) \
64828 + if (x != GR_DO_AUDIT) \
64829 + spin_unlock(&grsec_alert_lock); \
64830 + else \
64831 + spin_unlock(&grsec_audit_lock); \
64832 + read_unlock(&grsec_exec_file_lock); \
64833 + read_unlock(&tasklist_lock); \
64834 + rcu_read_unlock(); \
64835 + ENABLE_PREEMPT(); \
64836 + if (x == GR_DONT_AUDIT) \
64837 + gr_handle_alertkill(current)
64838 +
64839 +enum {
64840 + FLOODING,
64841 + NO_FLOODING
64842 +};
64843 +
64844 +extern char *gr_alert_log_fmt;
64845 +extern char *gr_audit_log_fmt;
64846 +extern char *gr_alert_log_buf;
64847 +extern char *gr_audit_log_buf;
64848 +
64849 +static int gr_log_start(int audit)
64850 +{
64851 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
64852 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
64853 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64854 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
64855 + unsigned long curr_secs = get_seconds();
64856 +
64857 + if (audit == GR_DO_AUDIT)
64858 + goto set_fmt;
64859 +
64860 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
64861 + grsec_alert_wtime = curr_secs;
64862 + grsec_alert_fyet = 0;
64863 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
64864 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
64865 + grsec_alert_fyet++;
64866 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
64867 + grsec_alert_wtime = curr_secs;
64868 + grsec_alert_fyet++;
64869 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
64870 + return FLOODING;
64871 + }
64872 + else return FLOODING;
64873 +
64874 +set_fmt:
64875 +#endif
64876 + memset(buf, 0, PAGE_SIZE);
64877 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
64878 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
64879 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64880 + } else if (current->signal->curr_ip) {
64881 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
64882 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
64883 + } else if (gr_acl_is_enabled()) {
64884 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
64885 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64886 + } else {
64887 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
64888 + strcpy(buf, fmt);
64889 + }
64890 +
64891 + return NO_FLOODING;
64892 +}
64893 +
64894 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64895 + __attribute__ ((format (printf, 2, 0)));
64896 +
64897 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64898 +{
64899 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64900 + unsigned int len = strlen(buf);
64901 +
64902 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64903 +
64904 + return;
64905 +}
64906 +
64907 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64908 + __attribute__ ((format (printf, 2, 3)));
64909 +
64910 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64911 +{
64912 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64913 + unsigned int len = strlen(buf);
64914 + va_list ap;
64915 +
64916 + va_start(ap, msg);
64917 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64918 + va_end(ap);
64919 +
64920 + return;
64921 +}
64922 +
64923 +static void gr_log_end(int audit, int append_default)
64924 +{
64925 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64926 + if (append_default) {
64927 + struct task_struct *task = current;
64928 + struct task_struct *parent = task->real_parent;
64929 + const struct cred *cred = __task_cred(task);
64930 + const struct cred *pcred = __task_cred(parent);
64931 + unsigned int len = strlen(buf);
64932 +
64933 + 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));
64934 + }
64935 +
64936 + printk("%s\n", buf);
64937 +
64938 + return;
64939 +}
64940 +
64941 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
64942 +{
64943 + int logtype;
64944 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
64945 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
64946 + void *voidptr = NULL;
64947 + int num1 = 0, num2 = 0;
64948 + unsigned long ulong1 = 0, ulong2 = 0;
64949 + struct dentry *dentry = NULL;
64950 + struct vfsmount *mnt = NULL;
64951 + struct file *file = NULL;
64952 + struct task_struct *task = NULL;
64953 + const struct cred *cred, *pcred;
64954 + va_list ap;
64955 +
64956 + BEGIN_LOCKS(audit);
64957 + logtype = gr_log_start(audit);
64958 + if (logtype == FLOODING) {
64959 + END_LOCKS(audit);
64960 + return;
64961 + }
64962 + va_start(ap, argtypes);
64963 + switch (argtypes) {
64964 + case GR_TTYSNIFF:
64965 + task = va_arg(ap, struct task_struct *);
64966 + 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));
64967 + break;
64968 + case GR_SYSCTL_HIDDEN:
64969 + str1 = va_arg(ap, char *);
64970 + gr_log_middle_varargs(audit, msg, result, str1);
64971 + break;
64972 + case GR_RBAC:
64973 + dentry = va_arg(ap, struct dentry *);
64974 + mnt = va_arg(ap, struct vfsmount *);
64975 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
64976 + break;
64977 + case GR_RBAC_STR:
64978 + dentry = va_arg(ap, struct dentry *);
64979 + mnt = va_arg(ap, struct vfsmount *);
64980 + str1 = va_arg(ap, char *);
64981 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
64982 + break;
64983 + case GR_STR_RBAC:
64984 + str1 = va_arg(ap, char *);
64985 + dentry = va_arg(ap, struct dentry *);
64986 + mnt = va_arg(ap, struct vfsmount *);
64987 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
64988 + break;
64989 + case GR_RBAC_MODE2:
64990 + dentry = va_arg(ap, struct dentry *);
64991 + mnt = va_arg(ap, struct vfsmount *);
64992 + str1 = va_arg(ap, char *);
64993 + str2 = va_arg(ap, char *);
64994 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
64995 + break;
64996 + case GR_RBAC_MODE3:
64997 + dentry = va_arg(ap, struct dentry *);
64998 + mnt = va_arg(ap, struct vfsmount *);
64999 + str1 = va_arg(ap, char *);
65000 + str2 = va_arg(ap, char *);
65001 + str3 = va_arg(ap, char *);
65002 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65003 + break;
65004 + case GR_FILENAME:
65005 + dentry = va_arg(ap, struct dentry *);
65006 + mnt = va_arg(ap, struct vfsmount *);
65007 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65008 + break;
65009 + case GR_STR_FILENAME:
65010 + str1 = va_arg(ap, char *);
65011 + dentry = va_arg(ap, struct dentry *);
65012 + mnt = va_arg(ap, struct vfsmount *);
65013 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65014 + break;
65015 + case GR_FILENAME_STR:
65016 + dentry = va_arg(ap, struct dentry *);
65017 + mnt = va_arg(ap, struct vfsmount *);
65018 + str1 = va_arg(ap, char *);
65019 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65020 + break;
65021 + case GR_FILENAME_TWO_INT:
65022 + dentry = va_arg(ap, struct dentry *);
65023 + mnt = va_arg(ap, struct vfsmount *);
65024 + num1 = va_arg(ap, int);
65025 + num2 = va_arg(ap, int);
65026 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65027 + break;
65028 + case GR_FILENAME_TWO_INT_STR:
65029 + dentry = va_arg(ap, struct dentry *);
65030 + mnt = va_arg(ap, struct vfsmount *);
65031 + num1 = va_arg(ap, int);
65032 + num2 = va_arg(ap, int);
65033 + str1 = va_arg(ap, char *);
65034 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65035 + break;
65036 + case GR_TEXTREL:
65037 + file = va_arg(ap, struct file *);
65038 + ulong1 = va_arg(ap, unsigned long);
65039 + ulong2 = va_arg(ap, unsigned long);
65040 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65041 + break;
65042 + case GR_PTRACE:
65043 + task = va_arg(ap, struct task_struct *);
65044 + 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));
65045 + break;
65046 + case GR_RESOURCE:
65047 + task = va_arg(ap, struct task_struct *);
65048 + cred = __task_cred(task);
65049 + pcred = __task_cred(task->real_parent);
65050 + ulong1 = va_arg(ap, unsigned long);
65051 + str1 = va_arg(ap, char *);
65052 + ulong2 = va_arg(ap, unsigned long);
65053 + 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));
65054 + break;
65055 + case GR_CAP:
65056 + task = va_arg(ap, struct task_struct *);
65057 + cred = __task_cred(task);
65058 + pcred = __task_cred(task->real_parent);
65059 + str1 = va_arg(ap, char *);
65060 + 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));
65061 + break;
65062 + case GR_SIG:
65063 + str1 = va_arg(ap, char *);
65064 + voidptr = va_arg(ap, void *);
65065 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65066 + break;
65067 + case GR_SIG2:
65068 + task = va_arg(ap, struct task_struct *);
65069 + cred = __task_cred(task);
65070 + pcred = __task_cred(task->real_parent);
65071 + num1 = va_arg(ap, int);
65072 + 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));
65073 + break;
65074 + case GR_CRASH1:
65075 + task = va_arg(ap, struct task_struct *);
65076 + cred = __task_cred(task);
65077 + pcred = __task_cred(task->real_parent);
65078 + ulong1 = va_arg(ap, unsigned long);
65079 + 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);
65080 + break;
65081 + case GR_CRASH2:
65082 + task = va_arg(ap, struct task_struct *);
65083 + cred = __task_cred(task);
65084 + pcred = __task_cred(task->real_parent);
65085 + ulong1 = va_arg(ap, unsigned long);
65086 + 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);
65087 + break;
65088 + case GR_RWXMAP:
65089 + file = va_arg(ap, struct file *);
65090 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65091 + break;
65092 + case GR_PSACCT:
65093 + {
65094 + unsigned int wday, cday;
65095 + __u8 whr, chr;
65096 + __u8 wmin, cmin;
65097 + __u8 wsec, csec;
65098 + char cur_tty[64] = { 0 };
65099 + char parent_tty[64] = { 0 };
65100 +
65101 + task = va_arg(ap, struct task_struct *);
65102 + wday = va_arg(ap, unsigned int);
65103 + cday = va_arg(ap, unsigned int);
65104 + whr = va_arg(ap, int);
65105 + chr = va_arg(ap, int);
65106 + wmin = va_arg(ap, int);
65107 + cmin = va_arg(ap, int);
65108 + wsec = va_arg(ap, int);
65109 + csec = va_arg(ap, int);
65110 + ulong1 = va_arg(ap, unsigned long);
65111 + cred = __task_cred(task);
65112 + pcred = __task_cred(task->real_parent);
65113 +
65114 + 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));
65115 + }
65116 + break;
65117 + default:
65118 + gr_log_middle(audit, msg, ap);
65119 + }
65120 + va_end(ap);
65121 + // these don't need DEFAULTSECARGS printed on the end
65122 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65123 + gr_log_end(audit, 0);
65124 + else
65125 + gr_log_end(audit, 1);
65126 + END_LOCKS(audit);
65127 +}
65128 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65129 new file mode 100644
65130 index 0000000..f536303
65131 --- /dev/null
65132 +++ b/grsecurity/grsec_mem.c
65133 @@ -0,0 +1,40 @@
65134 +#include <linux/kernel.h>
65135 +#include <linux/sched.h>
65136 +#include <linux/mm.h>
65137 +#include <linux/mman.h>
65138 +#include <linux/grinternal.h>
65139 +
65140 +void
65141 +gr_handle_ioperm(void)
65142 +{
65143 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65144 + return;
65145 +}
65146 +
65147 +void
65148 +gr_handle_iopl(void)
65149 +{
65150 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65151 + return;
65152 +}
65153 +
65154 +void
65155 +gr_handle_mem_readwrite(u64 from, u64 to)
65156 +{
65157 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65158 + return;
65159 +}
65160 +
65161 +void
65162 +gr_handle_vm86(void)
65163 +{
65164 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65165 + return;
65166 +}
65167 +
65168 +void
65169 +gr_log_badprocpid(const char *entry)
65170 +{
65171 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65172 + return;
65173 +}
65174 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65175 new file mode 100644
65176 index 0000000..2131422
65177 --- /dev/null
65178 +++ b/grsecurity/grsec_mount.c
65179 @@ -0,0 +1,62 @@
65180 +#include <linux/kernel.h>
65181 +#include <linux/sched.h>
65182 +#include <linux/mount.h>
65183 +#include <linux/grsecurity.h>
65184 +#include <linux/grinternal.h>
65185 +
65186 +void
65187 +gr_log_remount(const char *devname, const int retval)
65188 +{
65189 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65190 + if (grsec_enable_mount && (retval >= 0))
65191 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65192 +#endif
65193 + return;
65194 +}
65195 +
65196 +void
65197 +gr_log_unmount(const char *devname, const int retval)
65198 +{
65199 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65200 + if (grsec_enable_mount && (retval >= 0))
65201 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65202 +#endif
65203 + return;
65204 +}
65205 +
65206 +void
65207 +gr_log_mount(const char *from, const char *to, const int retval)
65208 +{
65209 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65210 + if (grsec_enable_mount && (retval >= 0))
65211 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65212 +#endif
65213 + return;
65214 +}
65215 +
65216 +int
65217 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65218 +{
65219 +#ifdef CONFIG_GRKERNSEC_ROFS
65220 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65221 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65222 + return -EPERM;
65223 + } else
65224 + return 0;
65225 +#endif
65226 + return 0;
65227 +}
65228 +
65229 +int
65230 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65231 +{
65232 +#ifdef CONFIG_GRKERNSEC_ROFS
65233 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65234 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65235 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65236 + return -EPERM;
65237 + } else
65238 + return 0;
65239 +#endif
65240 + return 0;
65241 +}
65242 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65243 new file mode 100644
65244 index 0000000..a3b12a0
65245 --- /dev/null
65246 +++ b/grsecurity/grsec_pax.c
65247 @@ -0,0 +1,36 @@
65248 +#include <linux/kernel.h>
65249 +#include <linux/sched.h>
65250 +#include <linux/mm.h>
65251 +#include <linux/file.h>
65252 +#include <linux/grinternal.h>
65253 +#include <linux/grsecurity.h>
65254 +
65255 +void
65256 +gr_log_textrel(struct vm_area_struct * vma)
65257 +{
65258 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65259 + if (grsec_enable_audit_textrel)
65260 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65261 +#endif
65262 + return;
65263 +}
65264 +
65265 +void
65266 +gr_log_rwxmmap(struct file *file)
65267 +{
65268 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65269 + if (grsec_enable_log_rwxmaps)
65270 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65271 +#endif
65272 + return;
65273 +}
65274 +
65275 +void
65276 +gr_log_rwxmprotect(struct file *file)
65277 +{
65278 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65279 + if (grsec_enable_log_rwxmaps)
65280 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65281 +#endif
65282 + return;
65283 +}
65284 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65285 new file mode 100644
65286 index 0000000..f7f29aa
65287 --- /dev/null
65288 +++ b/grsecurity/grsec_ptrace.c
65289 @@ -0,0 +1,30 @@
65290 +#include <linux/kernel.h>
65291 +#include <linux/sched.h>
65292 +#include <linux/grinternal.h>
65293 +#include <linux/security.h>
65294 +
65295 +void
65296 +gr_audit_ptrace(struct task_struct *task)
65297 +{
65298 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65299 + if (grsec_enable_audit_ptrace)
65300 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65301 +#endif
65302 + return;
65303 +}
65304 +
65305 +int
65306 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65307 +{
65308 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65309 + const struct dentry *dentry = file->f_path.dentry;
65310 + const struct vfsmount *mnt = file->f_path.mnt;
65311 +
65312 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65313 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65314 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65315 + return -EACCES;
65316 + }
65317 +#endif
65318 + return 0;
65319 +}
65320 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65321 new file mode 100644
65322 index 0000000..e09715a
65323 --- /dev/null
65324 +++ b/grsecurity/grsec_sig.c
65325 @@ -0,0 +1,222 @@
65326 +#include <linux/kernel.h>
65327 +#include <linux/sched.h>
65328 +#include <linux/delay.h>
65329 +#include <linux/grsecurity.h>
65330 +#include <linux/grinternal.h>
65331 +#include <linux/hardirq.h>
65332 +
65333 +char *signames[] = {
65334 + [SIGSEGV] = "Segmentation fault",
65335 + [SIGILL] = "Illegal instruction",
65336 + [SIGABRT] = "Abort",
65337 + [SIGBUS] = "Invalid alignment/Bus error"
65338 +};
65339 +
65340 +void
65341 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65342 +{
65343 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65344 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65345 + (sig == SIGABRT) || (sig == SIGBUS))) {
65346 + if (task_pid_nr(t) == task_pid_nr(current)) {
65347 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65348 + } else {
65349 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65350 + }
65351 + }
65352 +#endif
65353 + return;
65354 +}
65355 +
65356 +int
65357 +gr_handle_signal(const struct task_struct *p, const int sig)
65358 +{
65359 +#ifdef CONFIG_GRKERNSEC
65360 + /* ignore the 0 signal for protected task checks */
65361 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65362 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65363 + return -EPERM;
65364 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65365 + return -EPERM;
65366 + }
65367 +#endif
65368 + return 0;
65369 +}
65370 +
65371 +#ifdef CONFIG_GRKERNSEC
65372 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65373 +
65374 +int gr_fake_force_sig(int sig, struct task_struct *t)
65375 +{
65376 + unsigned long int flags;
65377 + int ret, blocked, ignored;
65378 + struct k_sigaction *action;
65379 +
65380 + spin_lock_irqsave(&t->sighand->siglock, flags);
65381 + action = &t->sighand->action[sig-1];
65382 + ignored = action->sa.sa_handler == SIG_IGN;
65383 + blocked = sigismember(&t->blocked, sig);
65384 + if (blocked || ignored) {
65385 + action->sa.sa_handler = SIG_DFL;
65386 + if (blocked) {
65387 + sigdelset(&t->blocked, sig);
65388 + recalc_sigpending_and_wake(t);
65389 + }
65390 + }
65391 + if (action->sa.sa_handler == SIG_DFL)
65392 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65393 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65394 +
65395 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65396 +
65397 + return ret;
65398 +}
65399 +#endif
65400 +
65401 +#ifdef CONFIG_GRKERNSEC_BRUTE
65402 +#define GR_USER_BAN_TIME (15 * 60)
65403 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65404 +
65405 +static int __get_dumpable(unsigned long mm_flags)
65406 +{
65407 + int ret;
65408 +
65409 + ret = mm_flags & MMF_DUMPABLE_MASK;
65410 + return (ret >= 2) ? 2 : ret;
65411 +}
65412 +#endif
65413 +
65414 +void gr_handle_brute_attach(unsigned long mm_flags)
65415 +{
65416 +#ifdef CONFIG_GRKERNSEC_BRUTE
65417 + struct task_struct *p = current;
65418 + kuid_t uid = GLOBAL_ROOT_UID;
65419 + int daemon = 0;
65420 +
65421 + if (!grsec_enable_brute)
65422 + return;
65423 +
65424 + rcu_read_lock();
65425 + read_lock(&tasklist_lock);
65426 + read_lock(&grsec_exec_file_lock);
65427 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65428 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65429 + p->real_parent->brute = 1;
65430 + daemon = 1;
65431 + } else {
65432 + const struct cred *cred = __task_cred(p), *cred2;
65433 + struct task_struct *tsk, *tsk2;
65434 +
65435 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65436 + struct user_struct *user;
65437 +
65438 + uid = cred->uid;
65439 +
65440 + /* this is put upon execution past expiration */
65441 + user = find_user(uid);
65442 + if (user == NULL)
65443 + goto unlock;
65444 + user->banned = 1;
65445 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65446 + if (user->ban_expires == ~0UL)
65447 + user->ban_expires--;
65448 +
65449 + do_each_thread(tsk2, tsk) {
65450 + cred2 = __task_cred(tsk);
65451 + if (tsk != p && uid_eq(cred2->uid, uid))
65452 + gr_fake_force_sig(SIGKILL, tsk);
65453 + } while_each_thread(tsk2, tsk);
65454 + }
65455 + }
65456 +unlock:
65457 + read_unlock(&grsec_exec_file_lock);
65458 + read_unlock(&tasklist_lock);
65459 + rcu_read_unlock();
65460 +
65461 + if (gr_is_global_nonroot(uid))
65462 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65463 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65464 + else if (daemon)
65465 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65466 +
65467 +#endif
65468 + return;
65469 +}
65470 +
65471 +void gr_handle_brute_check(void)
65472 +{
65473 +#ifdef CONFIG_GRKERNSEC_BRUTE
65474 + struct task_struct *p = current;
65475 +
65476 + if (unlikely(p->brute)) {
65477 + if (!grsec_enable_brute)
65478 + p->brute = 0;
65479 + else if (time_before(get_seconds(), p->brute_expires))
65480 + msleep(30 * 1000);
65481 + }
65482 +#endif
65483 + return;
65484 +}
65485 +
65486 +void gr_handle_kernel_exploit(void)
65487 +{
65488 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65489 + const struct cred *cred;
65490 + struct task_struct *tsk, *tsk2;
65491 + struct user_struct *user;
65492 + kuid_t uid;
65493 +
65494 + if (in_irq() || in_serving_softirq() || in_nmi())
65495 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
65496 +
65497 + uid = current_uid();
65498 +
65499 + if (gr_is_global_root(uid))
65500 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
65501 + else {
65502 + /* kill all the processes of this user, hold a reference
65503 + to their creds struct, and prevent them from creating
65504 + another process until system reset
65505 + */
65506 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
65507 + GR_GLOBAL_UID(uid));
65508 + /* we intentionally leak this ref */
65509 + user = get_uid(current->cred->user);
65510 + if (user) {
65511 + user->banned = 1;
65512 + user->ban_expires = ~0UL;
65513 + }
65514 +
65515 + read_lock(&tasklist_lock);
65516 + do_each_thread(tsk2, tsk) {
65517 + cred = __task_cred(tsk);
65518 + if (uid_eq(cred->uid, uid))
65519 + gr_fake_force_sig(SIGKILL, tsk);
65520 + } while_each_thread(tsk2, tsk);
65521 + read_unlock(&tasklist_lock);
65522 + }
65523 +#endif
65524 +}
65525 +
65526 +int __gr_process_user_ban(struct user_struct *user)
65527 +{
65528 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65529 + if (unlikely(user->banned)) {
65530 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
65531 + user->banned = 0;
65532 + user->ban_expires = 0;
65533 + free_uid(user);
65534 + } else
65535 + return -EPERM;
65536 + }
65537 +#endif
65538 + return 0;
65539 +}
65540 +
65541 +int gr_process_user_ban(void)
65542 +{
65543 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65544 + return __gr_process_user_ban(current->cred->user);
65545 +#endif
65546 + return 0;
65547 +}
65548 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
65549 new file mode 100644
65550 index 0000000..4030d57
65551 --- /dev/null
65552 +++ b/grsecurity/grsec_sock.c
65553 @@ -0,0 +1,244 @@
65554 +#include <linux/kernel.h>
65555 +#include <linux/module.h>
65556 +#include <linux/sched.h>
65557 +#include <linux/file.h>
65558 +#include <linux/net.h>
65559 +#include <linux/in.h>
65560 +#include <linux/ip.h>
65561 +#include <net/sock.h>
65562 +#include <net/inet_sock.h>
65563 +#include <linux/grsecurity.h>
65564 +#include <linux/grinternal.h>
65565 +#include <linux/gracl.h>
65566 +
65567 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
65568 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
65569 +
65570 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
65571 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
65572 +
65573 +#ifdef CONFIG_UNIX_MODULE
65574 +EXPORT_SYMBOL(gr_acl_handle_unix);
65575 +EXPORT_SYMBOL(gr_acl_handle_mknod);
65576 +EXPORT_SYMBOL(gr_handle_chroot_unix);
65577 +EXPORT_SYMBOL(gr_handle_create);
65578 +#endif
65579 +
65580 +#ifdef CONFIG_GRKERNSEC
65581 +#define gr_conn_table_size 32749
65582 +struct conn_table_entry {
65583 + struct conn_table_entry *next;
65584 + struct signal_struct *sig;
65585 +};
65586 +
65587 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
65588 +DEFINE_SPINLOCK(gr_conn_table_lock);
65589 +
65590 +extern const char * gr_socktype_to_name(unsigned char type);
65591 +extern const char * gr_proto_to_name(unsigned char proto);
65592 +extern const char * gr_sockfamily_to_name(unsigned char family);
65593 +
65594 +static __inline__ int
65595 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
65596 +{
65597 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
65598 +}
65599 +
65600 +static __inline__ int
65601 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
65602 + __u16 sport, __u16 dport)
65603 +{
65604 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
65605 + sig->gr_sport == sport && sig->gr_dport == dport))
65606 + return 1;
65607 + else
65608 + return 0;
65609 +}
65610 +
65611 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
65612 +{
65613 + struct conn_table_entry **match;
65614 + unsigned int index;
65615 +
65616 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65617 + sig->gr_sport, sig->gr_dport,
65618 + gr_conn_table_size);
65619 +
65620 + newent->sig = sig;
65621 +
65622 + match = &gr_conn_table[index];
65623 + newent->next = *match;
65624 + *match = newent;
65625 +
65626 + return;
65627 +}
65628 +
65629 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
65630 +{
65631 + struct conn_table_entry *match, *last = NULL;
65632 + unsigned int index;
65633 +
65634 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65635 + sig->gr_sport, sig->gr_dport,
65636 + gr_conn_table_size);
65637 +
65638 + match = gr_conn_table[index];
65639 + while (match && !conn_match(match->sig,
65640 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
65641 + sig->gr_dport)) {
65642 + last = match;
65643 + match = match->next;
65644 + }
65645 +
65646 + if (match) {
65647 + if (last)
65648 + last->next = match->next;
65649 + else
65650 + gr_conn_table[index] = NULL;
65651 + kfree(match);
65652 + }
65653 +
65654 + return;
65655 +}
65656 +
65657 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
65658 + __u16 sport, __u16 dport)
65659 +{
65660 + struct conn_table_entry *match;
65661 + unsigned int index;
65662 +
65663 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
65664 +
65665 + match = gr_conn_table[index];
65666 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
65667 + match = match->next;
65668 +
65669 + if (match)
65670 + return match->sig;
65671 + else
65672 + return NULL;
65673 +}
65674 +
65675 +#endif
65676 +
65677 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
65678 +{
65679 +#ifdef CONFIG_GRKERNSEC
65680 + struct signal_struct *sig = task->signal;
65681 + struct conn_table_entry *newent;
65682 +
65683 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
65684 + if (newent == NULL)
65685 + return;
65686 + /* no bh lock needed since we are called with bh disabled */
65687 + spin_lock(&gr_conn_table_lock);
65688 + gr_del_task_from_ip_table_nolock(sig);
65689 + sig->gr_saddr = inet->inet_rcv_saddr;
65690 + sig->gr_daddr = inet->inet_daddr;
65691 + sig->gr_sport = inet->inet_sport;
65692 + sig->gr_dport = inet->inet_dport;
65693 + gr_add_to_task_ip_table_nolock(sig, newent);
65694 + spin_unlock(&gr_conn_table_lock);
65695 +#endif
65696 + return;
65697 +}
65698 +
65699 +void gr_del_task_from_ip_table(struct task_struct *task)
65700 +{
65701 +#ifdef CONFIG_GRKERNSEC
65702 + spin_lock_bh(&gr_conn_table_lock);
65703 + gr_del_task_from_ip_table_nolock(task->signal);
65704 + spin_unlock_bh(&gr_conn_table_lock);
65705 +#endif
65706 + return;
65707 +}
65708 +
65709 +void
65710 +gr_attach_curr_ip(const struct sock *sk)
65711 +{
65712 +#ifdef CONFIG_GRKERNSEC
65713 + struct signal_struct *p, *set;
65714 + const struct inet_sock *inet = inet_sk(sk);
65715 +
65716 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
65717 + return;
65718 +
65719 + set = current->signal;
65720 +
65721 + spin_lock_bh(&gr_conn_table_lock);
65722 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
65723 + inet->inet_dport, inet->inet_sport);
65724 + if (unlikely(p != NULL)) {
65725 + set->curr_ip = p->curr_ip;
65726 + set->used_accept = 1;
65727 + gr_del_task_from_ip_table_nolock(p);
65728 + spin_unlock_bh(&gr_conn_table_lock);
65729 + return;
65730 + }
65731 + spin_unlock_bh(&gr_conn_table_lock);
65732 +
65733 + set->curr_ip = inet->inet_daddr;
65734 + set->used_accept = 1;
65735 +#endif
65736 + return;
65737 +}
65738 +
65739 +int
65740 +gr_handle_sock_all(const int family, const int type, const int protocol)
65741 +{
65742 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65743 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
65744 + (family != AF_UNIX)) {
65745 + if (family == AF_INET)
65746 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
65747 + else
65748 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
65749 + return -EACCES;
65750 + }
65751 +#endif
65752 + return 0;
65753 +}
65754 +
65755 +int
65756 +gr_handle_sock_server(const struct sockaddr *sck)
65757 +{
65758 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65759 + if (grsec_enable_socket_server &&
65760 + in_group_p(grsec_socket_server_gid) &&
65761 + sck && (sck->sa_family != AF_UNIX) &&
65762 + (sck->sa_family != AF_LOCAL)) {
65763 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65764 + return -EACCES;
65765 + }
65766 +#endif
65767 + return 0;
65768 +}
65769 +
65770 +int
65771 +gr_handle_sock_server_other(const struct sock *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->sk_family != AF_UNIX) &&
65777 + (sck->sk_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_client(const struct sockaddr *sck)
65787 +{
65788 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65789 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
65790 + sck && (sck->sa_family != AF_UNIX) &&
65791 + (sck->sa_family != AF_LOCAL)) {
65792 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
65793 + return -EACCES;
65794 + }
65795 +#endif
65796 + return 0;
65797 +}
65798 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
65799 new file mode 100644
65800 index 0000000..f55ef0f
65801 --- /dev/null
65802 +++ b/grsecurity/grsec_sysctl.c
65803 @@ -0,0 +1,469 @@
65804 +#include <linux/kernel.h>
65805 +#include <linux/sched.h>
65806 +#include <linux/sysctl.h>
65807 +#include <linux/grsecurity.h>
65808 +#include <linux/grinternal.h>
65809 +
65810 +int
65811 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
65812 +{
65813 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65814 + if (dirname == NULL || name == NULL)
65815 + return 0;
65816 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
65817 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
65818 + return -EACCES;
65819 + }
65820 +#endif
65821 + return 0;
65822 +}
65823 +
65824 +#ifdef CONFIG_GRKERNSEC_ROFS
65825 +static int __maybe_unused one = 1;
65826 +#endif
65827 +
65828 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
65829 +struct ctl_table grsecurity_table[] = {
65830 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65831 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
65832 +#ifdef CONFIG_GRKERNSEC_IO
65833 + {
65834 + .procname = "disable_priv_io",
65835 + .data = &grsec_disable_privio,
65836 + .maxlen = sizeof(int),
65837 + .mode = 0600,
65838 + .proc_handler = &proc_dointvec,
65839 + },
65840 +#endif
65841 +#endif
65842 +#ifdef CONFIG_GRKERNSEC_LINK
65843 + {
65844 + .procname = "linking_restrictions",
65845 + .data = &grsec_enable_link,
65846 + .maxlen = sizeof(int),
65847 + .mode = 0600,
65848 + .proc_handler = &proc_dointvec,
65849 + },
65850 +#endif
65851 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65852 + {
65853 + .procname = "enforce_symlinksifowner",
65854 + .data = &grsec_enable_symlinkown,
65855 + .maxlen = sizeof(int),
65856 + .mode = 0600,
65857 + .proc_handler = &proc_dointvec,
65858 + },
65859 + {
65860 + .procname = "symlinkown_gid",
65861 + .data = &grsec_symlinkown_gid,
65862 + .maxlen = sizeof(int),
65863 + .mode = 0600,
65864 + .proc_handler = &proc_dointvec,
65865 + },
65866 +#endif
65867 +#ifdef CONFIG_GRKERNSEC_BRUTE
65868 + {
65869 + .procname = "deter_bruteforce",
65870 + .data = &grsec_enable_brute,
65871 + .maxlen = sizeof(int),
65872 + .mode = 0600,
65873 + .proc_handler = &proc_dointvec,
65874 + },
65875 +#endif
65876 +#ifdef CONFIG_GRKERNSEC_FIFO
65877 + {
65878 + .procname = "fifo_restrictions",
65879 + .data = &grsec_enable_fifo,
65880 + .maxlen = sizeof(int),
65881 + .mode = 0600,
65882 + .proc_handler = &proc_dointvec,
65883 + },
65884 +#endif
65885 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65886 + {
65887 + .procname = "ptrace_readexec",
65888 + .data = &grsec_enable_ptrace_readexec,
65889 + .maxlen = sizeof(int),
65890 + .mode = 0600,
65891 + .proc_handler = &proc_dointvec,
65892 + },
65893 +#endif
65894 +#ifdef CONFIG_GRKERNSEC_SETXID
65895 + {
65896 + .procname = "consistent_setxid",
65897 + .data = &grsec_enable_setxid,
65898 + .maxlen = sizeof(int),
65899 + .mode = 0600,
65900 + .proc_handler = &proc_dointvec,
65901 + },
65902 +#endif
65903 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65904 + {
65905 + .procname = "ip_blackhole",
65906 + .data = &grsec_enable_blackhole,
65907 + .maxlen = sizeof(int),
65908 + .mode = 0600,
65909 + .proc_handler = &proc_dointvec,
65910 + },
65911 + {
65912 + .procname = "lastack_retries",
65913 + .data = &grsec_lastack_retries,
65914 + .maxlen = sizeof(int),
65915 + .mode = 0600,
65916 + .proc_handler = &proc_dointvec,
65917 + },
65918 +#endif
65919 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65920 + {
65921 + .procname = "exec_logging",
65922 + .data = &grsec_enable_execlog,
65923 + .maxlen = sizeof(int),
65924 + .mode = 0600,
65925 + .proc_handler = &proc_dointvec,
65926 + },
65927 +#endif
65928 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65929 + {
65930 + .procname = "rwxmap_logging",
65931 + .data = &grsec_enable_log_rwxmaps,
65932 + .maxlen = sizeof(int),
65933 + .mode = 0600,
65934 + .proc_handler = &proc_dointvec,
65935 + },
65936 +#endif
65937 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65938 + {
65939 + .procname = "signal_logging",
65940 + .data = &grsec_enable_signal,
65941 + .maxlen = sizeof(int),
65942 + .mode = 0600,
65943 + .proc_handler = &proc_dointvec,
65944 + },
65945 +#endif
65946 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65947 + {
65948 + .procname = "forkfail_logging",
65949 + .data = &grsec_enable_forkfail,
65950 + .maxlen = sizeof(int),
65951 + .mode = 0600,
65952 + .proc_handler = &proc_dointvec,
65953 + },
65954 +#endif
65955 +#ifdef CONFIG_GRKERNSEC_TIME
65956 + {
65957 + .procname = "timechange_logging",
65958 + .data = &grsec_enable_time,
65959 + .maxlen = sizeof(int),
65960 + .mode = 0600,
65961 + .proc_handler = &proc_dointvec,
65962 + },
65963 +#endif
65964 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65965 + {
65966 + .procname = "chroot_deny_shmat",
65967 + .data = &grsec_enable_chroot_shmat,
65968 + .maxlen = sizeof(int),
65969 + .mode = 0600,
65970 + .proc_handler = &proc_dointvec,
65971 + },
65972 +#endif
65973 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65974 + {
65975 + .procname = "chroot_deny_unix",
65976 + .data = &grsec_enable_chroot_unix,
65977 + .maxlen = sizeof(int),
65978 + .mode = 0600,
65979 + .proc_handler = &proc_dointvec,
65980 + },
65981 +#endif
65982 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65983 + {
65984 + .procname = "chroot_deny_mount",
65985 + .data = &grsec_enable_chroot_mount,
65986 + .maxlen = sizeof(int),
65987 + .mode = 0600,
65988 + .proc_handler = &proc_dointvec,
65989 + },
65990 +#endif
65991 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65992 + {
65993 + .procname = "chroot_deny_fchdir",
65994 + .data = &grsec_enable_chroot_fchdir,
65995 + .maxlen = sizeof(int),
65996 + .mode = 0600,
65997 + .proc_handler = &proc_dointvec,
65998 + },
65999 +#endif
66000 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66001 + {
66002 + .procname = "chroot_deny_chroot",
66003 + .data = &grsec_enable_chroot_double,
66004 + .maxlen = sizeof(int),
66005 + .mode = 0600,
66006 + .proc_handler = &proc_dointvec,
66007 + },
66008 +#endif
66009 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66010 + {
66011 + .procname = "chroot_deny_pivot",
66012 + .data = &grsec_enable_chroot_pivot,
66013 + .maxlen = sizeof(int),
66014 + .mode = 0600,
66015 + .proc_handler = &proc_dointvec,
66016 + },
66017 +#endif
66018 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66019 + {
66020 + .procname = "chroot_enforce_chdir",
66021 + .data = &grsec_enable_chroot_chdir,
66022 + .maxlen = sizeof(int),
66023 + .mode = 0600,
66024 + .proc_handler = &proc_dointvec,
66025 + },
66026 +#endif
66027 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66028 + {
66029 + .procname = "chroot_deny_chmod",
66030 + .data = &grsec_enable_chroot_chmod,
66031 + .maxlen = sizeof(int),
66032 + .mode = 0600,
66033 + .proc_handler = &proc_dointvec,
66034 + },
66035 +#endif
66036 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66037 + {
66038 + .procname = "chroot_deny_mknod",
66039 + .data = &grsec_enable_chroot_mknod,
66040 + .maxlen = sizeof(int),
66041 + .mode = 0600,
66042 + .proc_handler = &proc_dointvec,
66043 + },
66044 +#endif
66045 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66046 + {
66047 + .procname = "chroot_restrict_nice",
66048 + .data = &grsec_enable_chroot_nice,
66049 + .maxlen = sizeof(int),
66050 + .mode = 0600,
66051 + .proc_handler = &proc_dointvec,
66052 + },
66053 +#endif
66054 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66055 + {
66056 + .procname = "chroot_execlog",
66057 + .data = &grsec_enable_chroot_execlog,
66058 + .maxlen = sizeof(int),
66059 + .mode = 0600,
66060 + .proc_handler = &proc_dointvec,
66061 + },
66062 +#endif
66063 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66064 + {
66065 + .procname = "chroot_caps",
66066 + .data = &grsec_enable_chroot_caps,
66067 + .maxlen = sizeof(int),
66068 + .mode = 0600,
66069 + .proc_handler = &proc_dointvec,
66070 + },
66071 +#endif
66072 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66073 + {
66074 + .procname = "chroot_deny_sysctl",
66075 + .data = &grsec_enable_chroot_sysctl,
66076 + .maxlen = sizeof(int),
66077 + .mode = 0600,
66078 + .proc_handler = &proc_dointvec,
66079 + },
66080 +#endif
66081 +#ifdef CONFIG_GRKERNSEC_TPE
66082 + {
66083 + .procname = "tpe",
66084 + .data = &grsec_enable_tpe,
66085 + .maxlen = sizeof(int),
66086 + .mode = 0600,
66087 + .proc_handler = &proc_dointvec,
66088 + },
66089 + {
66090 + .procname = "tpe_gid",
66091 + .data = &grsec_tpe_gid,
66092 + .maxlen = sizeof(int),
66093 + .mode = 0600,
66094 + .proc_handler = &proc_dointvec,
66095 + },
66096 +#endif
66097 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66098 + {
66099 + .procname = "tpe_invert",
66100 + .data = &grsec_enable_tpe_invert,
66101 + .maxlen = sizeof(int),
66102 + .mode = 0600,
66103 + .proc_handler = &proc_dointvec,
66104 + },
66105 +#endif
66106 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66107 + {
66108 + .procname = "tpe_restrict_all",
66109 + .data = &grsec_enable_tpe_all,
66110 + .maxlen = sizeof(int),
66111 + .mode = 0600,
66112 + .proc_handler = &proc_dointvec,
66113 + },
66114 +#endif
66115 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66116 + {
66117 + .procname = "socket_all",
66118 + .data = &grsec_enable_socket_all,
66119 + .maxlen = sizeof(int),
66120 + .mode = 0600,
66121 + .proc_handler = &proc_dointvec,
66122 + },
66123 + {
66124 + .procname = "socket_all_gid",
66125 + .data = &grsec_socket_all_gid,
66126 + .maxlen = sizeof(int),
66127 + .mode = 0600,
66128 + .proc_handler = &proc_dointvec,
66129 + },
66130 +#endif
66131 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66132 + {
66133 + .procname = "socket_client",
66134 + .data = &grsec_enable_socket_client,
66135 + .maxlen = sizeof(int),
66136 + .mode = 0600,
66137 + .proc_handler = &proc_dointvec,
66138 + },
66139 + {
66140 + .procname = "socket_client_gid",
66141 + .data = &grsec_socket_client_gid,
66142 + .maxlen = sizeof(int),
66143 + .mode = 0600,
66144 + .proc_handler = &proc_dointvec,
66145 + },
66146 +#endif
66147 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66148 + {
66149 + .procname = "socket_server",
66150 + .data = &grsec_enable_socket_server,
66151 + .maxlen = sizeof(int),
66152 + .mode = 0600,
66153 + .proc_handler = &proc_dointvec,
66154 + },
66155 + {
66156 + .procname = "socket_server_gid",
66157 + .data = &grsec_socket_server_gid,
66158 + .maxlen = sizeof(int),
66159 + .mode = 0600,
66160 + .proc_handler = &proc_dointvec,
66161 + },
66162 +#endif
66163 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66164 + {
66165 + .procname = "audit_group",
66166 + .data = &grsec_enable_group,
66167 + .maxlen = sizeof(int),
66168 + .mode = 0600,
66169 + .proc_handler = &proc_dointvec,
66170 + },
66171 + {
66172 + .procname = "audit_gid",
66173 + .data = &grsec_audit_gid,
66174 + .maxlen = sizeof(int),
66175 + .mode = 0600,
66176 + .proc_handler = &proc_dointvec,
66177 + },
66178 +#endif
66179 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66180 + {
66181 + .procname = "audit_chdir",
66182 + .data = &grsec_enable_chdir,
66183 + .maxlen = sizeof(int),
66184 + .mode = 0600,
66185 + .proc_handler = &proc_dointvec,
66186 + },
66187 +#endif
66188 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66189 + {
66190 + .procname = "audit_mount",
66191 + .data = &grsec_enable_mount,
66192 + .maxlen = sizeof(int),
66193 + .mode = 0600,
66194 + .proc_handler = &proc_dointvec,
66195 + },
66196 +#endif
66197 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66198 + {
66199 + .procname = "audit_textrel",
66200 + .data = &grsec_enable_audit_textrel,
66201 + .maxlen = sizeof(int),
66202 + .mode = 0600,
66203 + .proc_handler = &proc_dointvec,
66204 + },
66205 +#endif
66206 +#ifdef CONFIG_GRKERNSEC_DMESG
66207 + {
66208 + .procname = "dmesg",
66209 + .data = &grsec_enable_dmesg,
66210 + .maxlen = sizeof(int),
66211 + .mode = 0600,
66212 + .proc_handler = &proc_dointvec,
66213 + },
66214 +#endif
66215 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66216 + {
66217 + .procname = "chroot_findtask",
66218 + .data = &grsec_enable_chroot_findtask,
66219 + .maxlen = sizeof(int),
66220 + .mode = 0600,
66221 + .proc_handler = &proc_dointvec,
66222 + },
66223 +#endif
66224 +#ifdef CONFIG_GRKERNSEC_RESLOG
66225 + {
66226 + .procname = "resource_logging",
66227 + .data = &grsec_resource_logging,
66228 + .maxlen = sizeof(int),
66229 + .mode = 0600,
66230 + .proc_handler = &proc_dointvec,
66231 + },
66232 +#endif
66233 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66234 + {
66235 + .procname = "audit_ptrace",
66236 + .data = &grsec_enable_audit_ptrace,
66237 + .maxlen = sizeof(int),
66238 + .mode = 0600,
66239 + .proc_handler = &proc_dointvec,
66240 + },
66241 +#endif
66242 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66243 + {
66244 + .procname = "harden_ptrace",
66245 + .data = &grsec_enable_harden_ptrace,
66246 + .maxlen = sizeof(int),
66247 + .mode = 0600,
66248 + .proc_handler = &proc_dointvec,
66249 + },
66250 +#endif
66251 + {
66252 + .procname = "grsec_lock",
66253 + .data = &grsec_lock,
66254 + .maxlen = sizeof(int),
66255 + .mode = 0600,
66256 + .proc_handler = &proc_dointvec,
66257 + },
66258 +#endif
66259 +#ifdef CONFIG_GRKERNSEC_ROFS
66260 + {
66261 + .procname = "romount_protect",
66262 + .data = &grsec_enable_rofs,
66263 + .maxlen = sizeof(int),
66264 + .mode = 0600,
66265 + .proc_handler = &proc_dointvec_minmax,
66266 + .extra1 = &one,
66267 + .extra2 = &one,
66268 + },
66269 +#endif
66270 + { }
66271 +};
66272 +#endif
66273 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66274 new file mode 100644
66275 index 0000000..0dc13c3
66276 --- /dev/null
66277 +++ b/grsecurity/grsec_time.c
66278 @@ -0,0 +1,16 @@
66279 +#include <linux/kernel.h>
66280 +#include <linux/sched.h>
66281 +#include <linux/grinternal.h>
66282 +#include <linux/module.h>
66283 +
66284 +void
66285 +gr_log_timechange(void)
66286 +{
66287 +#ifdef CONFIG_GRKERNSEC_TIME
66288 + if (grsec_enable_time)
66289 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66290 +#endif
66291 + return;
66292 +}
66293 +
66294 +EXPORT_SYMBOL(gr_log_timechange);
66295 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66296 new file mode 100644
66297 index 0000000..ee57dcf
66298 --- /dev/null
66299 +++ b/grsecurity/grsec_tpe.c
66300 @@ -0,0 +1,73 @@
66301 +#include <linux/kernel.h>
66302 +#include <linux/sched.h>
66303 +#include <linux/file.h>
66304 +#include <linux/fs.h>
66305 +#include <linux/grinternal.h>
66306 +
66307 +extern int gr_acl_tpe_check(void);
66308 +
66309 +int
66310 +gr_tpe_allow(const struct file *file)
66311 +{
66312 +#ifdef CONFIG_GRKERNSEC
66313 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66314 + const struct cred *cred = current_cred();
66315 + char *msg = NULL;
66316 + char *msg2 = NULL;
66317 +
66318 + // never restrict root
66319 + if (gr_is_global_root(cred->uid))
66320 + return 1;
66321 +
66322 + if (grsec_enable_tpe) {
66323 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66324 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66325 + msg = "not being in trusted group";
66326 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66327 + msg = "being in untrusted group";
66328 +#else
66329 + if (in_group_p(grsec_tpe_gid))
66330 + msg = "being in untrusted group";
66331 +#endif
66332 + }
66333 + if (!msg && gr_acl_tpe_check())
66334 + msg = "being in untrusted role";
66335 +
66336 + // not in any affected group/role
66337 + if (!msg)
66338 + goto next_check;
66339 +
66340 + if (gr_is_global_nonroot(inode->i_uid))
66341 + msg2 = "file in non-root-owned directory";
66342 + else if (inode->i_mode & S_IWOTH)
66343 + msg2 = "file in world-writable directory";
66344 + else if (inode->i_mode & S_IWGRP)
66345 + msg2 = "file in group-writable directory";
66346 +
66347 + if (msg && msg2) {
66348 + char fullmsg[70] = {0};
66349 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66350 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66351 + return 0;
66352 + }
66353 + msg = NULL;
66354 +next_check:
66355 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66356 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66357 + return 1;
66358 +
66359 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66360 + msg = "directory not owned by user";
66361 + else if (inode->i_mode & S_IWOTH)
66362 + msg = "file in world-writable directory";
66363 + else if (inode->i_mode & S_IWGRP)
66364 + msg = "file in group-writable directory";
66365 +
66366 + if (msg) {
66367 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66368 + return 0;
66369 + }
66370 +#endif
66371 +#endif
66372 + return 1;
66373 +}
66374 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66375 new file mode 100644
66376 index 0000000..9f7b1ac
66377 --- /dev/null
66378 +++ b/grsecurity/grsum.c
66379 @@ -0,0 +1,61 @@
66380 +#include <linux/err.h>
66381 +#include <linux/kernel.h>
66382 +#include <linux/sched.h>
66383 +#include <linux/mm.h>
66384 +#include <linux/scatterlist.h>
66385 +#include <linux/crypto.h>
66386 +#include <linux/gracl.h>
66387 +
66388 +
66389 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66390 +#error "crypto and sha256 must be built into the kernel"
66391 +#endif
66392 +
66393 +int
66394 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66395 +{
66396 + char *p;
66397 + struct crypto_hash *tfm;
66398 + struct hash_desc desc;
66399 + struct scatterlist sg;
66400 + unsigned char temp_sum[GR_SHA_LEN];
66401 + volatile int retval = 0;
66402 + volatile int dummy = 0;
66403 + unsigned int i;
66404 +
66405 + sg_init_table(&sg, 1);
66406 +
66407 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66408 + if (IS_ERR(tfm)) {
66409 + /* should never happen, since sha256 should be built in */
66410 + return 1;
66411 + }
66412 +
66413 + desc.tfm = tfm;
66414 + desc.flags = 0;
66415 +
66416 + crypto_hash_init(&desc);
66417 +
66418 + p = salt;
66419 + sg_set_buf(&sg, p, GR_SALT_LEN);
66420 + crypto_hash_update(&desc, &sg, sg.length);
66421 +
66422 + p = entry->pw;
66423 + sg_set_buf(&sg, p, strlen(p));
66424 +
66425 + crypto_hash_update(&desc, &sg, sg.length);
66426 +
66427 + crypto_hash_final(&desc, temp_sum);
66428 +
66429 + memset(entry->pw, 0, GR_PW_LEN);
66430 +
66431 + for (i = 0; i < GR_SHA_LEN; i++)
66432 + if (sum[i] != temp_sum[i])
66433 + retval = 1;
66434 + else
66435 + dummy = 1; // waste a cycle
66436 +
66437 + crypto_free_hash(tfm);
66438 +
66439 + return retval;
66440 +}
66441 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66442 index 77ff547..181834f 100644
66443 --- a/include/asm-generic/4level-fixup.h
66444 +++ b/include/asm-generic/4level-fixup.h
66445 @@ -13,8 +13,10 @@
66446 #define pmd_alloc(mm, pud, address) \
66447 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66448 NULL: pmd_offset(pud, address))
66449 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66450
66451 #define pud_alloc(mm, pgd, address) (pgd)
66452 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66453 #define pud_offset(pgd, start) (pgd)
66454 #define pud_none(pud) 0
66455 #define pud_bad(pud) 0
66456 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66457 index b7babf0..04ad282 100644
66458 --- a/include/asm-generic/atomic-long.h
66459 +++ b/include/asm-generic/atomic-long.h
66460 @@ -22,6 +22,12 @@
66461
66462 typedef atomic64_t atomic_long_t;
66463
66464 +#ifdef CONFIG_PAX_REFCOUNT
66465 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66466 +#else
66467 +typedef atomic64_t atomic_long_unchecked_t;
66468 +#endif
66469 +
66470 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66471
66472 static inline long atomic_long_read(atomic_long_t *l)
66473 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66474 return (long)atomic64_read(v);
66475 }
66476
66477 +#ifdef CONFIG_PAX_REFCOUNT
66478 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66479 +{
66480 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66481 +
66482 + return (long)atomic64_read_unchecked(v);
66483 +}
66484 +#endif
66485 +
66486 static inline void atomic_long_set(atomic_long_t *l, long i)
66487 {
66488 atomic64_t *v = (atomic64_t *)l;
66489 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66490 atomic64_set(v, i);
66491 }
66492
66493 +#ifdef CONFIG_PAX_REFCOUNT
66494 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66495 +{
66496 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66497 +
66498 + atomic64_set_unchecked(v, i);
66499 +}
66500 +#endif
66501 +
66502 static inline void atomic_long_inc(atomic_long_t *l)
66503 {
66504 atomic64_t *v = (atomic64_t *)l;
66505 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66506 atomic64_inc(v);
66507 }
66508
66509 +#ifdef CONFIG_PAX_REFCOUNT
66510 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66511 +{
66512 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66513 +
66514 + atomic64_inc_unchecked(v);
66515 +}
66516 +#endif
66517 +
66518 static inline void atomic_long_dec(atomic_long_t *l)
66519 {
66520 atomic64_t *v = (atomic64_t *)l;
66521 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66522 atomic64_dec(v);
66523 }
66524
66525 +#ifdef CONFIG_PAX_REFCOUNT
66526 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66527 +{
66528 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66529 +
66530 + atomic64_dec_unchecked(v);
66531 +}
66532 +#endif
66533 +
66534 static inline void atomic_long_add(long i, atomic_long_t *l)
66535 {
66536 atomic64_t *v = (atomic64_t *)l;
66537 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66538 atomic64_add(i, v);
66539 }
66540
66541 +#ifdef CONFIG_PAX_REFCOUNT
66542 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66543 +{
66544 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66545 +
66546 + atomic64_add_unchecked(i, v);
66547 +}
66548 +#endif
66549 +
66550 static inline void atomic_long_sub(long i, atomic_long_t *l)
66551 {
66552 atomic64_t *v = (atomic64_t *)l;
66553 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66554 atomic64_sub(i, v);
66555 }
66556
66557 +#ifdef CONFIG_PAX_REFCOUNT
66558 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66559 +{
66560 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66561 +
66562 + atomic64_sub_unchecked(i, v);
66563 +}
66564 +#endif
66565 +
66566 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66567 {
66568 atomic64_t *v = (atomic64_t *)l;
66569 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66570 return (long)atomic64_add_return(i, v);
66571 }
66572
66573 +#ifdef CONFIG_PAX_REFCOUNT
66574 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66575 +{
66576 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66577 +
66578 + return (long)atomic64_add_return_unchecked(i, v);
66579 +}
66580 +#endif
66581 +
66582 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66583 {
66584 atomic64_t *v = (atomic64_t *)l;
66585 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66586 return (long)atomic64_inc_return(v);
66587 }
66588
66589 +#ifdef CONFIG_PAX_REFCOUNT
66590 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66591 +{
66592 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66593 +
66594 + return (long)atomic64_inc_return_unchecked(v);
66595 +}
66596 +#endif
66597 +
66598 static inline long atomic_long_dec_return(atomic_long_t *l)
66599 {
66600 atomic64_t *v = (atomic64_t *)l;
66601 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66602
66603 typedef atomic_t atomic_long_t;
66604
66605 +#ifdef CONFIG_PAX_REFCOUNT
66606 +typedef atomic_unchecked_t atomic_long_unchecked_t;
66607 +#else
66608 +typedef atomic_t atomic_long_unchecked_t;
66609 +#endif
66610 +
66611 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
66612 static inline long atomic_long_read(atomic_long_t *l)
66613 {
66614 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66615 return (long)atomic_read(v);
66616 }
66617
66618 +#ifdef CONFIG_PAX_REFCOUNT
66619 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66620 +{
66621 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66622 +
66623 + return (long)atomic_read_unchecked(v);
66624 +}
66625 +#endif
66626 +
66627 static inline void atomic_long_set(atomic_long_t *l, long i)
66628 {
66629 atomic_t *v = (atomic_t *)l;
66630 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66631 atomic_set(v, i);
66632 }
66633
66634 +#ifdef CONFIG_PAX_REFCOUNT
66635 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66636 +{
66637 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66638 +
66639 + atomic_set_unchecked(v, i);
66640 +}
66641 +#endif
66642 +
66643 static inline void atomic_long_inc(atomic_long_t *l)
66644 {
66645 atomic_t *v = (atomic_t *)l;
66646 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66647 atomic_inc(v);
66648 }
66649
66650 +#ifdef CONFIG_PAX_REFCOUNT
66651 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66652 +{
66653 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66654 +
66655 + atomic_inc_unchecked(v);
66656 +}
66657 +#endif
66658 +
66659 static inline void atomic_long_dec(atomic_long_t *l)
66660 {
66661 atomic_t *v = (atomic_t *)l;
66662 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66663 atomic_dec(v);
66664 }
66665
66666 +#ifdef CONFIG_PAX_REFCOUNT
66667 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66668 +{
66669 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66670 +
66671 + atomic_dec_unchecked(v);
66672 +}
66673 +#endif
66674 +
66675 static inline void atomic_long_add(long i, atomic_long_t *l)
66676 {
66677 atomic_t *v = (atomic_t *)l;
66678 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66679 atomic_add(i, v);
66680 }
66681
66682 +#ifdef CONFIG_PAX_REFCOUNT
66683 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66684 +{
66685 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66686 +
66687 + atomic_add_unchecked(i, v);
66688 +}
66689 +#endif
66690 +
66691 static inline void atomic_long_sub(long i, atomic_long_t *l)
66692 {
66693 atomic_t *v = (atomic_t *)l;
66694 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66695 atomic_sub(i, v);
66696 }
66697
66698 +#ifdef CONFIG_PAX_REFCOUNT
66699 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66700 +{
66701 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66702 +
66703 + atomic_sub_unchecked(i, v);
66704 +}
66705 +#endif
66706 +
66707 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66708 {
66709 atomic_t *v = (atomic_t *)l;
66710 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66711 return (long)atomic_add_return(i, v);
66712 }
66713
66714 +#ifdef CONFIG_PAX_REFCOUNT
66715 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66716 +{
66717 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66718 +
66719 + return (long)atomic_add_return_unchecked(i, v);
66720 +}
66721 +
66722 +#endif
66723 +
66724 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66725 {
66726 atomic_t *v = (atomic_t *)l;
66727 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66728 return (long)atomic_inc_return(v);
66729 }
66730
66731 +#ifdef CONFIG_PAX_REFCOUNT
66732 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66733 +{
66734 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66735 +
66736 + return (long)atomic_inc_return_unchecked(v);
66737 +}
66738 +#endif
66739 +
66740 static inline long atomic_long_dec_return(atomic_long_t *l)
66741 {
66742 atomic_t *v = (atomic_t *)l;
66743 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66744
66745 #endif /* BITS_PER_LONG == 64 */
66746
66747 +#ifdef CONFIG_PAX_REFCOUNT
66748 +static inline void pax_refcount_needs_these_functions(void)
66749 +{
66750 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
66751 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
66752 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
66753 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
66754 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
66755 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
66756 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
66757 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
66758 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
66759 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
66760 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
66761 +#ifdef CONFIG_X86
66762 + atomic_clear_mask_unchecked(0, NULL);
66763 + atomic_set_mask_unchecked(0, NULL);
66764 +#endif
66765 +
66766 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
66767 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
66768 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
66769 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
66770 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
66771 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
66772 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
66773 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
66774 +}
66775 +#else
66776 +#define atomic_read_unchecked(v) atomic_read(v)
66777 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
66778 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
66779 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
66780 +#define atomic_inc_unchecked(v) atomic_inc(v)
66781 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
66782 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
66783 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
66784 +#define atomic_dec_unchecked(v) atomic_dec(v)
66785 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
66786 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
66787 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
66788 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
66789 +
66790 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
66791 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
66792 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
66793 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
66794 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
66795 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
66796 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
66797 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
66798 +#endif
66799 +
66800 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
66801 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
66802 index 33bd2de..f31bff97 100644
66803 --- a/include/asm-generic/atomic.h
66804 +++ b/include/asm-generic/atomic.h
66805 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
66806 * Atomically clears the bits set in @mask from @v
66807 */
66808 #ifndef atomic_clear_mask
66809 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
66810 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
66811 {
66812 unsigned long flags;
66813
66814 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
66815 index b18ce4f..2ee2843 100644
66816 --- a/include/asm-generic/atomic64.h
66817 +++ b/include/asm-generic/atomic64.h
66818 @@ -16,6 +16,8 @@ typedef struct {
66819 long long counter;
66820 } atomic64_t;
66821
66822 +typedef atomic64_t atomic64_unchecked_t;
66823 +
66824 #define ATOMIC64_INIT(i) { (i) }
66825
66826 extern long long atomic64_read(const atomic64_t *v);
66827 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
66828 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
66829 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
66830
66831 +#define atomic64_read_unchecked(v) atomic64_read(v)
66832 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
66833 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
66834 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
66835 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
66836 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
66837 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
66838 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
66839 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
66840 +
66841 #endif /* _ASM_GENERIC_ATOMIC64_H */
66842 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
66843 index 1bfcfe5..e04c5c9 100644
66844 --- a/include/asm-generic/cache.h
66845 +++ b/include/asm-generic/cache.h
66846 @@ -6,7 +6,7 @@
66847 * cache lines need to provide their own cache.h.
66848 */
66849
66850 -#define L1_CACHE_SHIFT 5
66851 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
66852 +#define L1_CACHE_SHIFT 5UL
66853 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
66854
66855 #endif /* __ASM_GENERIC_CACHE_H */
66856 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
66857 index 0d68a1e..b74a761 100644
66858 --- a/include/asm-generic/emergency-restart.h
66859 +++ b/include/asm-generic/emergency-restart.h
66860 @@ -1,7 +1,7 @@
66861 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
66862 #define _ASM_GENERIC_EMERGENCY_RESTART_H
66863
66864 -static inline void machine_emergency_restart(void)
66865 +static inline __noreturn void machine_emergency_restart(void)
66866 {
66867 machine_restart(NULL);
66868 }
66869 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
66870 index 90f99c7..00ce236 100644
66871 --- a/include/asm-generic/kmap_types.h
66872 +++ b/include/asm-generic/kmap_types.h
66873 @@ -2,9 +2,9 @@
66874 #define _ASM_GENERIC_KMAP_TYPES_H
66875
66876 #ifdef __WITH_KM_FENCE
66877 -# define KM_TYPE_NR 41
66878 +# define KM_TYPE_NR 42
66879 #else
66880 -# define KM_TYPE_NR 20
66881 +# define KM_TYPE_NR 21
66882 #endif
66883
66884 #endif
66885 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
66886 index 9ceb03b..62b0b8f 100644
66887 --- a/include/asm-generic/local.h
66888 +++ b/include/asm-generic/local.h
66889 @@ -23,24 +23,37 @@ typedef struct
66890 atomic_long_t a;
66891 } local_t;
66892
66893 +typedef struct {
66894 + atomic_long_unchecked_t a;
66895 +} local_unchecked_t;
66896 +
66897 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
66898
66899 #define local_read(l) atomic_long_read(&(l)->a)
66900 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
66901 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
66902 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
66903 #define local_inc(l) atomic_long_inc(&(l)->a)
66904 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
66905 #define local_dec(l) atomic_long_dec(&(l)->a)
66906 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
66907 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
66908 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
66909 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
66910 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
66911
66912 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
66913 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
66914 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
66915 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
66916 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
66917 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
66918 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
66919 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
66920 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
66921
66922 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66923 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66924 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
66925 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
66926 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
66927 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
66928 index 725612b..9cc513a 100644
66929 --- a/include/asm-generic/pgtable-nopmd.h
66930 +++ b/include/asm-generic/pgtable-nopmd.h
66931 @@ -1,14 +1,19 @@
66932 #ifndef _PGTABLE_NOPMD_H
66933 #define _PGTABLE_NOPMD_H
66934
66935 -#ifndef __ASSEMBLY__
66936 -
66937 #include <asm-generic/pgtable-nopud.h>
66938
66939 -struct mm_struct;
66940 -
66941 #define __PAGETABLE_PMD_FOLDED
66942
66943 +#define PMD_SHIFT PUD_SHIFT
66944 +#define PTRS_PER_PMD 1
66945 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
66946 +#define PMD_MASK (~(PMD_SIZE-1))
66947 +
66948 +#ifndef __ASSEMBLY__
66949 +
66950 +struct mm_struct;
66951 +
66952 /*
66953 * Having the pmd type consist of a pud gets the size right, and allows
66954 * us to conceptually access the pud entry that this pmd is folded into
66955 @@ -16,11 +21,6 @@ struct mm_struct;
66956 */
66957 typedef struct { pud_t pud; } pmd_t;
66958
66959 -#define PMD_SHIFT PUD_SHIFT
66960 -#define PTRS_PER_PMD 1
66961 -#define PMD_SIZE (1UL << PMD_SHIFT)
66962 -#define PMD_MASK (~(PMD_SIZE-1))
66963 -
66964 /*
66965 * The "pud_xxx()" functions here are trivial for a folded two-level
66966 * setup: the pmd is never bad, and a pmd always exists (as it's folded
66967 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
66968 index 810431d..0ec4804f 100644
66969 --- a/include/asm-generic/pgtable-nopud.h
66970 +++ b/include/asm-generic/pgtable-nopud.h
66971 @@ -1,10 +1,15 @@
66972 #ifndef _PGTABLE_NOPUD_H
66973 #define _PGTABLE_NOPUD_H
66974
66975 -#ifndef __ASSEMBLY__
66976 -
66977 #define __PAGETABLE_PUD_FOLDED
66978
66979 +#define PUD_SHIFT PGDIR_SHIFT
66980 +#define PTRS_PER_PUD 1
66981 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
66982 +#define PUD_MASK (~(PUD_SIZE-1))
66983 +
66984 +#ifndef __ASSEMBLY__
66985 +
66986 /*
66987 * Having the pud type consist of a pgd gets the size right, and allows
66988 * us to conceptually access the pgd entry that this pud is folded into
66989 @@ -12,11 +17,6 @@
66990 */
66991 typedef struct { pgd_t pgd; } pud_t;
66992
66993 -#define PUD_SHIFT PGDIR_SHIFT
66994 -#define PTRS_PER_PUD 1
66995 -#define PUD_SIZE (1UL << PUD_SHIFT)
66996 -#define PUD_MASK (~(PUD_SIZE-1))
66997 -
66998 /*
66999 * The "pgd_xxx()" functions here are trivial for a folded two-level
67000 * setup: the pud is never bad, and a pud always exists (as it's folded
67001 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67002 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67003
67004 #define pgd_populate(mm, pgd, pud) do { } while (0)
67005 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67006 /*
67007 * (puds are folded into pgds so this doesn't get actually called,
67008 * but the define is needed for a generic inline function.)
67009 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67010 index a59ff51..2594a70 100644
67011 --- a/include/asm-generic/pgtable.h
67012 +++ b/include/asm-generic/pgtable.h
67013 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67014 }
67015 #endif /* CONFIG_NUMA_BALANCING */
67016
67017 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67018 +static inline unsigned long pax_open_kernel(void) { return 0; }
67019 +#endif
67020 +
67021 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67022 +static inline unsigned long pax_close_kernel(void) { return 0; }
67023 +#endif
67024 +
67025 #endif /* CONFIG_MMU */
67026
67027 #endif /* !__ASSEMBLY__ */
67028 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67029 index afa12c7..99d4da0 100644
67030 --- a/include/asm-generic/vmlinux.lds.h
67031 +++ b/include/asm-generic/vmlinux.lds.h
67032 @@ -245,6 +245,7 @@
67033 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67034 VMLINUX_SYMBOL(__start_rodata) = .; \
67035 *(.rodata) *(.rodata.*) \
67036 + *(.data..read_only) \
67037 *(__vermagic) /* Kernel version magic */ \
67038 . = ALIGN(8); \
67039 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67040 @@ -755,17 +756,18 @@
67041 * section in the linker script will go there too. @phdr should have
67042 * a leading colon.
67043 *
67044 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67045 + * Note that this macros defines per_cpu_load as an absolute symbol.
67046 * If there is no need to put the percpu section at a predetermined
67047 * address, use PERCPU_SECTION.
67048 */
67049 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67050 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67051 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67052 + per_cpu_load = .; \
67053 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67054 - LOAD_OFFSET) { \
67055 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67056 PERCPU_INPUT(cacheline) \
67057 } phdr \
67058 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67059 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67060
67061 /**
67062 * PERCPU_SECTION - define output section for percpu area, simple version
67063 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67064 index 418d270..bfd2794 100644
67065 --- a/include/crypto/algapi.h
67066 +++ b/include/crypto/algapi.h
67067 @@ -34,7 +34,7 @@ struct crypto_type {
67068 unsigned int maskclear;
67069 unsigned int maskset;
67070 unsigned int tfmsize;
67071 -};
67072 +} __do_const;
67073
67074 struct crypto_instance {
67075 struct crypto_alg alg;
67076 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67077 index f1ce786..086a7a5 100644
67078 --- a/include/drm/drmP.h
67079 +++ b/include/drm/drmP.h
67080 @@ -72,6 +72,7 @@
67081 #include <linux/workqueue.h>
67082 #include <linux/poll.h>
67083 #include <asm/pgalloc.h>
67084 +#include <asm/local.h>
67085 #include <drm/drm.h>
67086 #include <drm/drm_sarea.h>
67087
67088 @@ -296,10 +297,12 @@ do { \
67089 * \param cmd command.
67090 * \param arg argument.
67091 */
67092 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67093 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67094 + struct drm_file *file_priv);
67095 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67096 struct drm_file *file_priv);
67097
67098 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67099 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67100 unsigned long arg);
67101
67102 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67103 @@ -314,9 +317,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67104 struct drm_ioctl_desc {
67105 unsigned int cmd;
67106 int flags;
67107 - drm_ioctl_t *func;
67108 + drm_ioctl_t func;
67109 unsigned int cmd_drv;
67110 -};
67111 +} __do_const;
67112
67113 /**
67114 * Creates a driver or general drm_ioctl_desc array entry for the given
67115 @@ -1014,7 +1017,7 @@ struct drm_info_list {
67116 int (*show)(struct seq_file*, void*); /** show callback */
67117 u32 driver_features; /**< Required driver features for this entry */
67118 void *data;
67119 -};
67120 +} __do_const;
67121
67122 /**
67123 * debugfs node structure. This structure represents a debugfs file.
67124 @@ -1087,7 +1090,7 @@ struct drm_device {
67125
67126 /** \name Usage Counters */
67127 /*@{ */
67128 - int open_count; /**< Outstanding files open */
67129 + local_t open_count; /**< Outstanding files open */
67130 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67131 atomic_t vma_count; /**< Outstanding vma areas open */
67132 int buf_use; /**< Buffers in use -- cannot alloc */
67133 @@ -1098,7 +1101,7 @@ struct drm_device {
67134 /*@{ */
67135 unsigned long counters;
67136 enum drm_stat_type types[15];
67137 - atomic_t counts[15];
67138 + atomic_unchecked_t counts[15];
67139 /*@} */
67140
67141 struct list_head filelist;
67142 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67143 index f43d556..94d9343 100644
67144 --- a/include/drm/drm_crtc_helper.h
67145 +++ b/include/drm/drm_crtc_helper.h
67146 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67147 struct drm_connector *connector);
67148 /* disable encoder when not in use - more explicit than dpms off */
67149 void (*disable)(struct drm_encoder *encoder);
67150 -};
67151 +} __no_const;
67152
67153 /**
67154 * drm_connector_helper_funcs - helper operations for connectors
67155 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67156 index 72dcbe8..8db58d7 100644
67157 --- a/include/drm/ttm/ttm_memory.h
67158 +++ b/include/drm/ttm/ttm_memory.h
67159 @@ -48,7 +48,7 @@
67160
67161 struct ttm_mem_shrink {
67162 int (*do_shrink) (struct ttm_mem_shrink *);
67163 -};
67164 +} __no_const;
67165
67166 /**
67167 * struct ttm_mem_global - Global memory accounting structure.
67168 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67169 index 4b840e8..155d235 100644
67170 --- a/include/keys/asymmetric-subtype.h
67171 +++ b/include/keys/asymmetric-subtype.h
67172 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67173 /* Verify the signature on a key of this subtype (optional) */
67174 int (*verify_signature)(const struct key *key,
67175 const struct public_key_signature *sig);
67176 -};
67177 +} __do_const;
67178
67179 /**
67180 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67181 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67182 index c1da539..1dcec55 100644
67183 --- a/include/linux/atmdev.h
67184 +++ b/include/linux/atmdev.h
67185 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67186 #endif
67187
67188 struct k_atm_aal_stats {
67189 -#define __HANDLE_ITEM(i) atomic_t i
67190 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67191 __AAL_STAT_ITEMS
67192 #undef __HANDLE_ITEM
67193 };
67194 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67195 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67196 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67197 struct module *owner;
67198 -};
67199 +} __do_const ;
67200
67201 struct atmphy_ops {
67202 int (*start)(struct atm_dev *dev);
67203 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67204 index c3a0914..ec5d48a 100644
67205 --- a/include/linux/binfmts.h
67206 +++ b/include/linux/binfmts.h
67207 @@ -73,8 +73,9 @@ struct linux_binfmt {
67208 int (*load_binary)(struct linux_binprm *);
67209 int (*load_shlib)(struct file *);
67210 int (*core_dump)(struct coredump_params *cprm);
67211 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67212 unsigned long min_coredump; /* minimal dump size */
67213 -};
67214 +} __do_const;
67215
67216 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67217
67218 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67219 index 33f358f..7f2c27f 100644
67220 --- a/include/linux/blkdev.h
67221 +++ b/include/linux/blkdev.h
67222 @@ -1499,7 +1499,7 @@ struct block_device_operations {
67223 /* this callback is with swap_lock and sometimes page table lock held */
67224 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67225 struct module *owner;
67226 -};
67227 +} __do_const;
67228
67229 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67230 unsigned long);
67231 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67232 index 7c2e030..b72475d 100644
67233 --- a/include/linux/blktrace_api.h
67234 +++ b/include/linux/blktrace_api.h
67235 @@ -23,7 +23,7 @@ struct blk_trace {
67236 struct dentry *dir;
67237 struct dentry *dropped_file;
67238 struct dentry *msg_file;
67239 - atomic_t dropped;
67240 + atomic_unchecked_t dropped;
67241 };
67242
67243 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67244 diff --git a/include/linux/cache.h b/include/linux/cache.h
67245 index 4c57065..4307975 100644
67246 --- a/include/linux/cache.h
67247 +++ b/include/linux/cache.h
67248 @@ -16,6 +16,10 @@
67249 #define __read_mostly
67250 #endif
67251
67252 +#ifndef __read_only
67253 +#define __read_only __read_mostly
67254 +#endif
67255 +
67256 #ifndef ____cacheline_aligned
67257 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67258 #endif
67259 diff --git a/include/linux/capability.h b/include/linux/capability.h
67260 index d9a4f7f4..19f77d6 100644
67261 --- a/include/linux/capability.h
67262 +++ b/include/linux/capability.h
67263 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
67264 extern bool nsown_capable(int cap);
67265 extern bool inode_capable(const struct inode *inode, int cap);
67266 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
67267 +extern bool capable_nolog(int cap);
67268 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67269 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67270
67271 /* audit system wants to get cap info from files as well */
67272 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67273
67274 +extern int is_privileged_binary(const struct dentry *dentry);
67275 +
67276 #endif /* !_LINUX_CAPABILITY_H */
67277 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67278 index 8609d57..86e4d79 100644
67279 --- a/include/linux/cdrom.h
67280 +++ b/include/linux/cdrom.h
67281 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67282
67283 /* driver specifications */
67284 const int capability; /* capability flags */
67285 - int n_minors; /* number of active minor devices */
67286 /* handle uniform packets for scsi type devices (scsi,atapi) */
67287 int (*generic_packet) (struct cdrom_device_info *,
67288 struct packet_command *);
67289 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67290 index 42e55de..1cd0e66 100644
67291 --- a/include/linux/cleancache.h
67292 +++ b/include/linux/cleancache.h
67293 @@ -31,7 +31,7 @@ struct cleancache_ops {
67294 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67295 void (*invalidate_inode)(int, struct cleancache_filekey);
67296 void (*invalidate_fs)(int);
67297 -};
67298 +} __no_const;
67299
67300 extern struct cleancache_ops
67301 cleancache_register_ops(struct cleancache_ops *ops);
67302 diff --git a/include/linux/compat.h b/include/linux/compat.h
67303 index 377cd8c..2479845 100644
67304 --- a/include/linux/compat.h
67305 +++ b/include/linux/compat.h
67306 @@ -332,14 +332,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67307 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67308 int version, void __user *uptr);
67309 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67310 - void __user *uptr);
67311 + void __user *uptr) __intentional_overflow(0);
67312 #else
67313 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67314 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67315 compat_ssize_t msgsz, int msgflg);
67316 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67317 compat_ssize_t msgsz, long msgtyp, int msgflg);
67318 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67319 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67320 #endif
67321 long compat_sys_msgctl(int first, int second, void __user *uptr);
67322 long compat_sys_shmctl(int first, int second, void __user *uptr);
67323 @@ -442,7 +442,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67324 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67325 compat_ulong_t addr, compat_ulong_t data);
67326 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67327 - compat_long_t addr, compat_long_t data);
67328 + compat_ulong_t addr, compat_ulong_t data);
67329
67330 /*
67331 * epoll (fs/eventpoll.c) compat bits follow ...
67332 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67333 index 68b162d..660f5f0 100644
67334 --- a/include/linux/compiler-gcc4.h
67335 +++ b/include/linux/compiler-gcc4.h
67336 @@ -39,9 +39,29 @@
67337 # define __compiletime_warning(message) __attribute__((warning(message)))
67338 # define __compiletime_error(message) __attribute__((error(message)))
67339 #endif /* __CHECKER__ */
67340 +
67341 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67342 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67343 +#define __bos0(ptr) __bos((ptr), 0)
67344 +#define __bos1(ptr) __bos((ptr), 1)
67345 #endif /* GCC_VERSION >= 40300 */
67346
67347 #if GCC_VERSION >= 40500
67348 +
67349 +#ifdef CONSTIFY_PLUGIN
67350 +#define __no_const __attribute__((no_const))
67351 +#define __do_const __attribute__((do_const))
67352 +#endif
67353 +
67354 +#ifdef SIZE_OVERFLOW_PLUGIN
67355 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67356 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67357 +#endif
67358 +
67359 +#ifdef LATENT_ENTROPY_PLUGIN
67360 +#define __latent_entropy __attribute__((latent_entropy))
67361 +#endif
67362 +
67363 /*
67364 * Mark a position in code as unreachable. This can be used to
67365 * suppress control flow warnings after asm blocks that transfer
67366 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67367 index 10b8f23..5e0b083 100644
67368 --- a/include/linux/compiler.h
67369 +++ b/include/linux/compiler.h
67370 @@ -5,11 +5,14 @@
67371
67372 #ifdef __CHECKER__
67373 # define __user __attribute__((noderef, address_space(1)))
67374 +# define __force_user __force __user
67375 # define __kernel __attribute__((address_space(0)))
67376 +# define __force_kernel __force __kernel
67377 # define __safe __attribute__((safe))
67378 # define __force __attribute__((force))
67379 # define __nocast __attribute__((nocast))
67380 # define __iomem __attribute__((noderef, address_space(2)))
67381 +# define __force_iomem __force __iomem
67382 # define __must_hold(x) __attribute__((context(x,1,1)))
67383 # define __acquires(x) __attribute__((context(x,0,1)))
67384 # define __releases(x) __attribute__((context(x,1,0)))
67385 @@ -17,20 +20,37 @@
67386 # define __release(x) __context__(x,-1)
67387 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67388 # define __percpu __attribute__((noderef, address_space(3)))
67389 +# define __force_percpu __force __percpu
67390 #ifdef CONFIG_SPARSE_RCU_POINTER
67391 # define __rcu __attribute__((noderef, address_space(4)))
67392 +# define __force_rcu __force __rcu
67393 #else
67394 # define __rcu
67395 +# define __force_rcu
67396 #endif
67397 extern void __chk_user_ptr(const volatile void __user *);
67398 extern void __chk_io_ptr(const volatile void __iomem *);
67399 #else
67400 -# define __user
67401 -# define __kernel
67402 +# ifdef CHECKER_PLUGIN
67403 +//# define __user
67404 +//# define __force_user
67405 +//# define __kernel
67406 +//# define __force_kernel
67407 +# else
67408 +# ifdef STRUCTLEAK_PLUGIN
67409 +# define __user __attribute__((user))
67410 +# else
67411 +# define __user
67412 +# endif
67413 +# define __force_user
67414 +# define __kernel
67415 +# define __force_kernel
67416 +# endif
67417 # define __safe
67418 # define __force
67419 # define __nocast
67420 # define __iomem
67421 +# define __force_iomem
67422 # define __chk_user_ptr(x) (void)0
67423 # define __chk_io_ptr(x) (void)0
67424 # define __builtin_warning(x, y...) (1)
67425 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67426 # define __release(x) (void)0
67427 # define __cond_lock(x,c) (c)
67428 # define __percpu
67429 +# define __force_percpu
67430 # define __rcu
67431 +# define __force_rcu
67432 #endif
67433
67434 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67435 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67436 # define __attribute_const__ /* unimplemented */
67437 #endif
67438
67439 +#ifndef __no_const
67440 +# define __no_const
67441 +#endif
67442 +
67443 +#ifndef __do_const
67444 +# define __do_const
67445 +#endif
67446 +
67447 +#ifndef __size_overflow
67448 +# define __size_overflow(...)
67449 +#endif
67450 +
67451 +#ifndef __intentional_overflow
67452 +# define __intentional_overflow(...)
67453 +#endif
67454 +
67455 +#ifndef __latent_entropy
67456 +# define __latent_entropy
67457 +#endif
67458 +
67459 /*
67460 * Tell gcc if a function is cold. The compiler will assume any path
67461 * directly leading to the call is unlikely.
67462 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67463 #define __cold
67464 #endif
67465
67466 +#ifndef __alloc_size
67467 +#define __alloc_size(...)
67468 +#endif
67469 +
67470 +#ifndef __bos
67471 +#define __bos(ptr, arg)
67472 +#endif
67473 +
67474 +#ifndef __bos0
67475 +#define __bos0(ptr)
67476 +#endif
67477 +
67478 +#ifndef __bos1
67479 +#define __bos1(ptr)
67480 +#endif
67481 +
67482 /* Simple shorthand for a section definition */
67483 #ifndef __section
67484 # define __section(S) __attribute__ ((__section__(#S)))
67485 @@ -349,6 +407,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67486 * use is to mediate communication between process-level code and irq/NMI
67487 * handlers, all running on the same CPU.
67488 */
67489 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
67490 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
67491 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
67492
67493 #endif /* __LINUX_COMPILER_H */
67494 diff --git a/include/linux/completion.h b/include/linux/completion.h
67495 index 33f0280..35c6568 100644
67496 --- a/include/linux/completion.h
67497 +++ b/include/linux/completion.h
67498 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
67499 extern void wait_for_completion(struct completion *);
67500 extern void wait_for_completion_io(struct completion *);
67501 extern int wait_for_completion_interruptible(struct completion *x);
67502 -extern int wait_for_completion_killable(struct completion *x);
67503 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
67504 extern unsigned long wait_for_completion_timeout(struct completion *x,
67505 unsigned long timeout);
67506 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
67507 unsigned long timeout);
67508 extern long wait_for_completion_interruptible_timeout(
67509 - struct completion *x, unsigned long timeout);
67510 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67511 extern long wait_for_completion_killable_timeout(
67512 - struct completion *x, unsigned long timeout);
67513 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67514 extern bool try_wait_for_completion(struct completion *x);
67515 extern bool completion_done(struct completion *x);
67516
67517 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
67518 index 34025df..d94bbbc 100644
67519 --- a/include/linux/configfs.h
67520 +++ b/include/linux/configfs.h
67521 @@ -125,7 +125,7 @@ struct configfs_attribute {
67522 const char *ca_name;
67523 struct module *ca_owner;
67524 umode_t ca_mode;
67525 -};
67526 +} __do_const;
67527
67528 /*
67529 * Users often need to create attribute structures for their configurable
67530 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
67531 index ce7a074..01ab8ac 100644
67532 --- a/include/linux/cpu.h
67533 +++ b/include/linux/cpu.h
67534 @@ -115,7 +115,7 @@ enum {
67535 /* Need to know about CPUs going up/down? */
67536 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
67537 #define cpu_notifier(fn, pri) { \
67538 - static struct notifier_block fn##_nb __cpuinitdata = \
67539 + static struct notifier_block fn##_nb = \
67540 { .notifier_call = fn, .priority = pri }; \
67541 register_cpu_notifier(&fn##_nb); \
67542 }
67543 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
67544 index a22944c..4e695fe 100644
67545 --- a/include/linux/cpufreq.h
67546 +++ b/include/linux/cpufreq.h
67547 @@ -252,7 +252,7 @@ struct cpufreq_driver {
67548 int (*suspend) (struct cpufreq_policy *policy);
67549 int (*resume) (struct cpufreq_policy *policy);
67550 struct freq_attr **attr;
67551 -};
67552 +} __do_const;
67553
67554 /* flags */
67555
67556 @@ -311,6 +311,7 @@ struct global_attr {
67557 ssize_t (*store)(struct kobject *a, struct attribute *b,
67558 const char *c, size_t count);
67559 };
67560 +typedef struct global_attr __no_const global_attr_no_const;
67561
67562 #define define_one_global_ro(_name) \
67563 static struct global_attr _name = \
67564 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
67565 index 480c14d..552896f 100644
67566 --- a/include/linux/cpuidle.h
67567 +++ b/include/linux/cpuidle.h
67568 @@ -52,7 +52,8 @@ struct cpuidle_state {
67569 int index);
67570
67571 int (*enter_dead) (struct cpuidle_device *dev, int index);
67572 -};
67573 +} __do_const;
67574 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
67575
67576 /* Idle State Flags */
67577 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
67578 @@ -194,7 +195,7 @@ struct cpuidle_governor {
67579 void (*reflect) (struct cpuidle_device *dev, int index);
67580
67581 struct module *owner;
67582 -};
67583 +} __do_const;
67584
67585 #ifdef CONFIG_CPU_IDLE
67586
67587 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
67588 index 0325602..5e9feff 100644
67589 --- a/include/linux/cpumask.h
67590 +++ b/include/linux/cpumask.h
67591 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67592 }
67593
67594 /* Valid inputs for n are -1 and 0. */
67595 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67596 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67597 {
67598 return n+1;
67599 }
67600
67601 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67602 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67603 {
67604 return n+1;
67605 }
67606
67607 -static inline unsigned int cpumask_next_and(int n,
67608 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
67609 const struct cpumask *srcp,
67610 const struct cpumask *andp)
67611 {
67612 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67613 *
67614 * Returns >= nr_cpu_ids if no further cpus set.
67615 */
67616 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67617 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67618 {
67619 /* -1 is a legal arg here. */
67620 if (n != -1)
67621 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67622 *
67623 * Returns >= nr_cpu_ids if no further cpus unset.
67624 */
67625 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67626 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67627 {
67628 /* -1 is a legal arg here. */
67629 if (n != -1)
67630 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67631 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
67632 }
67633
67634 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
67635 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
67636 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
67637
67638 /**
67639 diff --git a/include/linux/cred.h b/include/linux/cred.h
67640 index 04421e8..6bce4ef 100644
67641 --- a/include/linux/cred.h
67642 +++ b/include/linux/cred.h
67643 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
67644 static inline void validate_process_creds(void)
67645 {
67646 }
67647 +static inline void validate_task_creds(struct task_struct *task)
67648 +{
67649 +}
67650 #endif
67651
67652 /**
67653 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
67654 index b92eadf..b4ecdc1 100644
67655 --- a/include/linux/crypto.h
67656 +++ b/include/linux/crypto.h
67657 @@ -373,7 +373,7 @@ struct cipher_tfm {
67658 const u8 *key, unsigned int keylen);
67659 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67660 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67661 -};
67662 +} __no_const;
67663
67664 struct hash_tfm {
67665 int (*init)(struct hash_desc *desc);
67666 @@ -394,13 +394,13 @@ struct compress_tfm {
67667 int (*cot_decompress)(struct crypto_tfm *tfm,
67668 const u8 *src, unsigned int slen,
67669 u8 *dst, unsigned int *dlen);
67670 -};
67671 +} __no_const;
67672
67673 struct rng_tfm {
67674 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
67675 unsigned int dlen);
67676 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
67677 -};
67678 +} __no_const;
67679
67680 #define crt_ablkcipher crt_u.ablkcipher
67681 #define crt_aead crt_u.aead
67682 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
67683 index 8acfe31..6ffccd63 100644
67684 --- a/include/linux/ctype.h
67685 +++ b/include/linux/ctype.h
67686 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
67687 * Fast implementation of tolower() for internal usage. Do not use in your
67688 * code.
67689 */
67690 -static inline char _tolower(const char c)
67691 +static inline unsigned char _tolower(const unsigned char c)
67692 {
67693 return c | 0x20;
67694 }
67695 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
67696 index 7925bf0..d5143d2 100644
67697 --- a/include/linux/decompress/mm.h
67698 +++ b/include/linux/decompress/mm.h
67699 @@ -77,7 +77,7 @@ static void free(void *where)
67700 * warnings when not needed (indeed large_malloc / large_free are not
67701 * needed by inflate */
67702
67703 -#define malloc(a) kmalloc(a, GFP_KERNEL)
67704 +#define malloc(a) kmalloc((a), GFP_KERNEL)
67705 #define free(a) kfree(a)
67706
67707 #define large_malloc(a) vmalloc(a)
67708 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
67709 index fe8c447..bdc1f33 100644
67710 --- a/include/linux/devfreq.h
67711 +++ b/include/linux/devfreq.h
67712 @@ -114,7 +114,7 @@ struct devfreq_governor {
67713 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
67714 int (*event_handler)(struct devfreq *devfreq,
67715 unsigned int event, void *data);
67716 -};
67717 +} __do_const;
67718
67719 /**
67720 * struct devfreq - Device devfreq structure
67721 diff --git a/include/linux/device.h b/include/linux/device.h
67722 index 9d6464e..8a5cc92 100644
67723 --- a/include/linux/device.h
67724 +++ b/include/linux/device.h
67725 @@ -295,7 +295,7 @@ struct subsys_interface {
67726 struct list_head node;
67727 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
67728 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
67729 -};
67730 +} __do_const;
67731
67732 int subsys_interface_register(struct subsys_interface *sif);
67733 void subsys_interface_unregister(struct subsys_interface *sif);
67734 @@ -475,7 +475,7 @@ struct device_type {
67735 void (*release)(struct device *dev);
67736
67737 const struct dev_pm_ops *pm;
67738 -};
67739 +} __do_const;
67740
67741 /* interface for exporting device attributes */
67742 struct device_attribute {
67743 @@ -485,11 +485,12 @@ struct device_attribute {
67744 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
67745 const char *buf, size_t count);
67746 };
67747 +typedef struct device_attribute __no_const device_attribute_no_const;
67748
67749 struct dev_ext_attribute {
67750 struct device_attribute attr;
67751 void *var;
67752 -};
67753 +} __do_const;
67754
67755 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
67756 char *buf);
67757 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
67758 index 94af418..b1ca7a2 100644
67759 --- a/include/linux/dma-mapping.h
67760 +++ b/include/linux/dma-mapping.h
67761 @@ -54,7 +54,7 @@ struct dma_map_ops {
67762 u64 (*get_required_mask)(struct device *dev);
67763 #endif
67764 int is_phys;
67765 -};
67766 +} __do_const;
67767
67768 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
67769
67770 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
67771 index 91ac8da..a841318 100644
67772 --- a/include/linux/dmaengine.h
67773 +++ b/include/linux/dmaengine.h
67774 @@ -1034,9 +1034,9 @@ struct dma_pinned_list {
67775 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
67776 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
67777
67778 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67779 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67780 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
67781 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67782 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67783 struct dma_pinned_list *pinned_list, struct page *page,
67784 unsigned int offset, size_t len);
67785
67786 diff --git a/include/linux/efi.h b/include/linux/efi.h
67787 index 3d7df3d..301f024 100644
67788 --- a/include/linux/efi.h
67789 +++ b/include/linux/efi.h
67790 @@ -740,6 +740,7 @@ struct efivar_operations {
67791 efi_set_variable_t *set_variable;
67792 efi_query_variable_store_t *query_variable_store;
67793 };
67794 +typedef struct efivar_operations __no_const efivar_operations_no_const;
67795
67796 struct efivars {
67797 /*
67798 diff --git a/include/linux/elf.h b/include/linux/elf.h
67799 index 40a3c0e..4c45a38 100644
67800 --- a/include/linux/elf.h
67801 +++ b/include/linux/elf.h
67802 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
67803 #define elf_note elf32_note
67804 #define elf_addr_t Elf32_Off
67805 #define Elf_Half Elf32_Half
67806 +#define elf_dyn Elf32_Dyn
67807
67808 #else
67809
67810 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
67811 #define elf_note elf64_note
67812 #define elf_addr_t Elf64_Off
67813 #define Elf_Half Elf64_Half
67814 +#define elf_dyn Elf64_Dyn
67815
67816 #endif
67817
67818 diff --git a/include/linux/err.h b/include/linux/err.h
67819 index f2edce2..cc2082c 100644
67820 --- a/include/linux/err.h
67821 +++ b/include/linux/err.h
67822 @@ -19,12 +19,12 @@
67823
67824 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
67825
67826 -static inline void * __must_check ERR_PTR(long error)
67827 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
67828 {
67829 return (void *) error;
67830 }
67831
67832 -static inline long __must_check PTR_ERR(const void *ptr)
67833 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
67834 {
67835 return (long) ptr;
67836 }
67837 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
67838 index fcb51c8..bdafcf6 100644
67839 --- a/include/linux/extcon.h
67840 +++ b/include/linux/extcon.h
67841 @@ -134,7 +134,7 @@ struct extcon_dev {
67842 /* /sys/class/extcon/.../mutually_exclusive/... */
67843 struct attribute_group attr_g_muex;
67844 struct attribute **attrs_muex;
67845 - struct device_attribute *d_attrs_muex;
67846 + device_attribute_no_const *d_attrs_muex;
67847 };
67848
67849 /**
67850 diff --git a/include/linux/fb.h b/include/linux/fb.h
67851 index 58b9860..58e5516 100644
67852 --- a/include/linux/fb.h
67853 +++ b/include/linux/fb.h
67854 @@ -304,7 +304,7 @@ struct fb_ops {
67855 /* called at KDB enter and leave time to prepare the console */
67856 int (*fb_debug_enter)(struct fb_info *info);
67857 int (*fb_debug_leave)(struct fb_info *info);
67858 -};
67859 +} __do_const;
67860
67861 #ifdef CONFIG_FB_TILEBLITTING
67862 #define FB_TILE_CURSOR_NONE 0
67863 diff --git a/include/linux/filter.h b/include/linux/filter.h
67864 index c45eabc..baa0be5 100644
67865 --- a/include/linux/filter.h
67866 +++ b/include/linux/filter.h
67867 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
67868
67869 struct sk_buff;
67870 struct sock;
67871 +struct bpf_jit_work;
67872
67873 struct sk_filter
67874 {
67875 @@ -27,6 +28,9 @@ struct sk_filter
67876 unsigned int len; /* Number of filter blocks */
67877 unsigned int (*bpf_func)(const struct sk_buff *skb,
67878 const struct sock_filter *filter);
67879 +#ifdef CONFIG_BPF_JIT
67880 + struct bpf_jit_work *work;
67881 +#endif
67882 struct rcu_head rcu;
67883 struct sock_filter insns[0];
67884 };
67885 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
67886 index 3044254..9767f41 100644
67887 --- a/include/linux/frontswap.h
67888 +++ b/include/linux/frontswap.h
67889 @@ -11,7 +11,7 @@ struct frontswap_ops {
67890 int (*load)(unsigned, pgoff_t, struct page *);
67891 void (*invalidate_page)(unsigned, pgoff_t);
67892 void (*invalidate_area)(unsigned);
67893 -};
67894 +} __no_const;
67895
67896 extern bool frontswap_enabled;
67897 extern struct frontswap_ops
67898 diff --git a/include/linux/fs.h b/include/linux/fs.h
67899 index 2c28271..8d3d74c 100644
67900 --- a/include/linux/fs.h
67901 +++ b/include/linux/fs.h
67902 @@ -1541,7 +1541,8 @@ struct file_operations {
67903 long (*fallocate)(struct file *file, int mode, loff_t offset,
67904 loff_t len);
67905 int (*show_fdinfo)(struct seq_file *m, struct file *f);
67906 -};
67907 +} __do_const;
67908 +typedef struct file_operations __no_const file_operations_no_const;
67909
67910 struct inode_operations {
67911 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
67912 @@ -2672,4 +2673,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
67913 inode->i_flags |= S_NOSEC;
67914 }
67915
67916 +static inline bool is_sidechannel_device(const struct inode *inode)
67917 +{
67918 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
67919 + umode_t mode = inode->i_mode;
67920 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
67921 +#else
67922 + return false;
67923 +#endif
67924 +}
67925 +
67926 #endif /* _LINUX_FS_H */
67927 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
67928 index 2b93a9a..855d94a 100644
67929 --- a/include/linux/fs_struct.h
67930 +++ b/include/linux/fs_struct.h
67931 @@ -6,7 +6,7 @@
67932 #include <linux/seqlock.h>
67933
67934 struct fs_struct {
67935 - int users;
67936 + atomic_t users;
67937 spinlock_t lock;
67938 seqcount_t seq;
67939 int umask;
67940 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
67941 index 5dfa0aa..6acf322 100644
67942 --- a/include/linux/fscache-cache.h
67943 +++ b/include/linux/fscache-cache.h
67944 @@ -112,7 +112,7 @@ struct fscache_operation {
67945 fscache_operation_release_t release;
67946 };
67947
67948 -extern atomic_t fscache_op_debug_id;
67949 +extern atomic_unchecked_t fscache_op_debug_id;
67950 extern void fscache_op_work_func(struct work_struct *work);
67951
67952 extern void fscache_enqueue_operation(struct fscache_operation *);
67953 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
67954 INIT_WORK(&op->work, fscache_op_work_func);
67955 atomic_set(&op->usage, 1);
67956 op->state = FSCACHE_OP_ST_INITIALISED;
67957 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
67958 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
67959 op->processor = processor;
67960 op->release = release;
67961 INIT_LIST_HEAD(&op->pend_link);
67962 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
67963 index 7a08623..4c07b0f 100644
67964 --- a/include/linux/fscache.h
67965 +++ b/include/linux/fscache.h
67966 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
67967 * - this is mandatory for any object that may have data
67968 */
67969 void (*now_uncached)(void *cookie_netfs_data);
67970 -};
67971 +} __do_const;
67972
67973 /*
67974 * fscache cached network filesystem type
67975 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
67976 index a78680a..87bd73e 100644
67977 --- a/include/linux/fsnotify.h
67978 +++ b/include/linux/fsnotify.h
67979 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
67980 struct inode *inode = path->dentry->d_inode;
67981 __u32 mask = FS_ACCESS;
67982
67983 + if (is_sidechannel_device(inode))
67984 + return;
67985 +
67986 if (S_ISDIR(inode->i_mode))
67987 mask |= FS_ISDIR;
67988
67989 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
67990 struct inode *inode = path->dentry->d_inode;
67991 __u32 mask = FS_MODIFY;
67992
67993 + if (is_sidechannel_device(inode))
67994 + return;
67995 +
67996 if (S_ISDIR(inode->i_mode))
67997 mask |= FS_ISDIR;
67998
67999 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68000 */
68001 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68002 {
68003 - return kstrdup(name, GFP_KERNEL);
68004 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68005 }
68006
68007 /*
68008 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68009 index 13a54d0..c6ce2a7 100644
68010 --- a/include/linux/ftrace_event.h
68011 +++ b/include/linux/ftrace_event.h
68012 @@ -274,7 +274,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68013 extern int trace_add_event_call(struct ftrace_event_call *call);
68014 extern void trace_remove_event_call(struct ftrace_event_call *call);
68015
68016 -#define is_signed_type(type) (((type)(-1)) < (type)0)
68017 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68018
68019 int trace_set_clr_event(const char *system, const char *event, int set);
68020
68021 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68022 index 9f3c275..911b591 100644
68023 --- a/include/linux/genhd.h
68024 +++ b/include/linux/genhd.h
68025 @@ -194,7 +194,7 @@ struct gendisk {
68026 struct kobject *slave_dir;
68027
68028 struct timer_rand_state *random;
68029 - atomic_t sync_io; /* RAID */
68030 + atomic_unchecked_t sync_io; /* RAID */
68031 struct disk_events *ev;
68032 #ifdef CONFIG_BLK_DEV_INTEGRITY
68033 struct blk_integrity *integrity;
68034 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68035 index 023bc34..b02b46a 100644
68036 --- a/include/linux/genl_magic_func.h
68037 +++ b/include/linux/genl_magic_func.h
68038 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68039 },
68040
68041 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68042 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68043 +static struct genl_ops ZZZ_genl_ops[] = {
68044 #include GENL_MAGIC_INCLUDE_FILE
68045 };
68046
68047 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68048 index 0f615eb..5c3832f 100644
68049 --- a/include/linux/gfp.h
68050 +++ b/include/linux/gfp.h
68051 @@ -35,6 +35,13 @@ struct vm_area_struct;
68052 #define ___GFP_NO_KSWAPD 0x400000u
68053 #define ___GFP_OTHER_NODE 0x800000u
68054 #define ___GFP_WRITE 0x1000000u
68055 +
68056 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68057 +#define ___GFP_USERCOPY 0x2000000u
68058 +#else
68059 +#define ___GFP_USERCOPY 0
68060 +#endif
68061 +
68062 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68063
68064 /*
68065 @@ -92,6 +99,7 @@ struct vm_area_struct;
68066 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68067 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68068 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68069 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68070
68071 /*
68072 * This may seem redundant, but it's a way of annotating false positives vs.
68073 @@ -99,7 +107,7 @@ struct vm_area_struct;
68074 */
68075 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68076
68077 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68078 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68079 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68080
68081 /* This equals 0, but use constants in case they ever change */
68082 @@ -153,6 +161,8 @@ struct vm_area_struct;
68083 /* 4GB DMA on some platforms */
68084 #define GFP_DMA32 __GFP_DMA32
68085
68086 +#define GFP_USERCOPY __GFP_USERCOPY
68087 +
68088 /* Convert GFP flags to their corresponding migrate type */
68089 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68090 {
68091 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68092 new file mode 100644
68093 index 0000000..ebe6d72
68094 --- /dev/null
68095 +++ b/include/linux/gracl.h
68096 @@ -0,0 +1,319 @@
68097 +#ifndef GR_ACL_H
68098 +#define GR_ACL_H
68099 +
68100 +#include <linux/grdefs.h>
68101 +#include <linux/resource.h>
68102 +#include <linux/capability.h>
68103 +#include <linux/dcache.h>
68104 +#include <asm/resource.h>
68105 +
68106 +/* Major status information */
68107 +
68108 +#define GR_VERSION "grsecurity 2.9.1"
68109 +#define GRSECURITY_VERSION 0x2901
68110 +
68111 +enum {
68112 + GR_SHUTDOWN = 0,
68113 + GR_ENABLE = 1,
68114 + GR_SPROLE = 2,
68115 + GR_RELOAD = 3,
68116 + GR_SEGVMOD = 4,
68117 + GR_STATUS = 5,
68118 + GR_UNSPROLE = 6,
68119 + GR_PASSSET = 7,
68120 + GR_SPROLEPAM = 8,
68121 +};
68122 +
68123 +/* Password setup definitions
68124 + * kernel/grhash.c */
68125 +enum {
68126 + GR_PW_LEN = 128,
68127 + GR_SALT_LEN = 16,
68128 + GR_SHA_LEN = 32,
68129 +};
68130 +
68131 +enum {
68132 + GR_SPROLE_LEN = 64,
68133 +};
68134 +
68135 +enum {
68136 + GR_NO_GLOB = 0,
68137 + GR_REG_GLOB,
68138 + GR_CREATE_GLOB
68139 +};
68140 +
68141 +#define GR_NLIMITS 32
68142 +
68143 +/* Begin Data Structures */
68144 +
68145 +struct sprole_pw {
68146 + unsigned char *rolename;
68147 + unsigned char salt[GR_SALT_LEN];
68148 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68149 +};
68150 +
68151 +struct name_entry {
68152 + __u32 key;
68153 + ino_t inode;
68154 + dev_t device;
68155 + char *name;
68156 + __u16 len;
68157 + __u8 deleted;
68158 + struct name_entry *prev;
68159 + struct name_entry *next;
68160 +};
68161 +
68162 +struct inodev_entry {
68163 + struct name_entry *nentry;
68164 + struct inodev_entry *prev;
68165 + struct inodev_entry *next;
68166 +};
68167 +
68168 +struct acl_role_db {
68169 + struct acl_role_label **r_hash;
68170 + __u32 r_size;
68171 +};
68172 +
68173 +struct inodev_db {
68174 + struct inodev_entry **i_hash;
68175 + __u32 i_size;
68176 +};
68177 +
68178 +struct name_db {
68179 + struct name_entry **n_hash;
68180 + __u32 n_size;
68181 +};
68182 +
68183 +struct crash_uid {
68184 + uid_t uid;
68185 + unsigned long expires;
68186 +};
68187 +
68188 +struct gr_hash_struct {
68189 + void **table;
68190 + void **nametable;
68191 + void *first;
68192 + __u32 table_size;
68193 + __u32 used_size;
68194 + int type;
68195 +};
68196 +
68197 +/* Userspace Grsecurity ACL data structures */
68198 +
68199 +struct acl_subject_label {
68200 + char *filename;
68201 + ino_t inode;
68202 + dev_t device;
68203 + __u32 mode;
68204 + kernel_cap_t cap_mask;
68205 + kernel_cap_t cap_lower;
68206 + kernel_cap_t cap_invert_audit;
68207 +
68208 + struct rlimit res[GR_NLIMITS];
68209 + __u32 resmask;
68210 +
68211 + __u8 user_trans_type;
68212 + __u8 group_trans_type;
68213 + uid_t *user_transitions;
68214 + gid_t *group_transitions;
68215 + __u16 user_trans_num;
68216 + __u16 group_trans_num;
68217 +
68218 + __u32 sock_families[2];
68219 + __u32 ip_proto[8];
68220 + __u32 ip_type;
68221 + struct acl_ip_label **ips;
68222 + __u32 ip_num;
68223 + __u32 inaddr_any_override;
68224 +
68225 + __u32 crashes;
68226 + unsigned long expires;
68227 +
68228 + struct acl_subject_label *parent_subject;
68229 + struct gr_hash_struct *hash;
68230 + struct acl_subject_label *prev;
68231 + struct acl_subject_label *next;
68232 +
68233 + struct acl_object_label **obj_hash;
68234 + __u32 obj_hash_size;
68235 + __u16 pax_flags;
68236 +};
68237 +
68238 +struct role_allowed_ip {
68239 + __u32 addr;
68240 + __u32 netmask;
68241 +
68242 + struct role_allowed_ip *prev;
68243 + struct role_allowed_ip *next;
68244 +};
68245 +
68246 +struct role_transition {
68247 + char *rolename;
68248 +
68249 + struct role_transition *prev;
68250 + struct role_transition *next;
68251 +};
68252 +
68253 +struct acl_role_label {
68254 + char *rolename;
68255 + uid_t uidgid;
68256 + __u16 roletype;
68257 +
68258 + __u16 auth_attempts;
68259 + unsigned long expires;
68260 +
68261 + struct acl_subject_label *root_label;
68262 + struct gr_hash_struct *hash;
68263 +
68264 + struct acl_role_label *prev;
68265 + struct acl_role_label *next;
68266 +
68267 + struct role_transition *transitions;
68268 + struct role_allowed_ip *allowed_ips;
68269 + uid_t *domain_children;
68270 + __u16 domain_child_num;
68271 +
68272 + umode_t umask;
68273 +
68274 + struct acl_subject_label **subj_hash;
68275 + __u32 subj_hash_size;
68276 +};
68277 +
68278 +struct user_acl_role_db {
68279 + struct acl_role_label **r_table;
68280 + __u32 num_pointers; /* Number of allocations to track */
68281 + __u32 num_roles; /* Number of roles */
68282 + __u32 num_domain_children; /* Number of domain children */
68283 + __u32 num_subjects; /* Number of subjects */
68284 + __u32 num_objects; /* Number of objects */
68285 +};
68286 +
68287 +struct acl_object_label {
68288 + char *filename;
68289 + ino_t inode;
68290 + dev_t device;
68291 + __u32 mode;
68292 +
68293 + struct acl_subject_label *nested;
68294 + struct acl_object_label *globbed;
68295 +
68296 + /* next two structures not used */
68297 +
68298 + struct acl_object_label *prev;
68299 + struct acl_object_label *next;
68300 +};
68301 +
68302 +struct acl_ip_label {
68303 + char *iface;
68304 + __u32 addr;
68305 + __u32 netmask;
68306 + __u16 low, high;
68307 + __u8 mode;
68308 + __u32 type;
68309 + __u32 proto[8];
68310 +
68311 + /* next two structures not used */
68312 +
68313 + struct acl_ip_label *prev;
68314 + struct acl_ip_label *next;
68315 +};
68316 +
68317 +struct gr_arg {
68318 + struct user_acl_role_db role_db;
68319 + unsigned char pw[GR_PW_LEN];
68320 + unsigned char salt[GR_SALT_LEN];
68321 + unsigned char sum[GR_SHA_LEN];
68322 + unsigned char sp_role[GR_SPROLE_LEN];
68323 + struct sprole_pw *sprole_pws;
68324 + dev_t segv_device;
68325 + ino_t segv_inode;
68326 + uid_t segv_uid;
68327 + __u16 num_sprole_pws;
68328 + __u16 mode;
68329 +};
68330 +
68331 +struct gr_arg_wrapper {
68332 + struct gr_arg *arg;
68333 + __u32 version;
68334 + __u32 size;
68335 +};
68336 +
68337 +struct subject_map {
68338 + struct acl_subject_label *user;
68339 + struct acl_subject_label *kernel;
68340 + struct subject_map *prev;
68341 + struct subject_map *next;
68342 +};
68343 +
68344 +struct acl_subj_map_db {
68345 + struct subject_map **s_hash;
68346 + __u32 s_size;
68347 +};
68348 +
68349 +/* End Data Structures Section */
68350 +
68351 +/* Hash functions generated by empirical testing by Brad Spengler
68352 + Makes good use of the low bits of the inode. Generally 0-1 times
68353 + in loop for successful match. 0-3 for unsuccessful match.
68354 + Shift/add algorithm with modulus of table size and an XOR*/
68355 +
68356 +static __inline__ unsigned int
68357 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68358 +{
68359 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68360 +}
68361 +
68362 + static __inline__ unsigned int
68363 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68364 +{
68365 + return ((const unsigned long)userp % sz);
68366 +}
68367 +
68368 +static __inline__ unsigned int
68369 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68370 +{
68371 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68372 +}
68373 +
68374 +static __inline__ unsigned int
68375 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68376 +{
68377 + return full_name_hash((const unsigned char *)name, len) % sz;
68378 +}
68379 +
68380 +#define FOR_EACH_ROLE_START(role) \
68381 + role = role_list; \
68382 + while (role) {
68383 +
68384 +#define FOR_EACH_ROLE_END(role) \
68385 + role = role->prev; \
68386 + }
68387 +
68388 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68389 + subj = NULL; \
68390 + iter = 0; \
68391 + while (iter < role->subj_hash_size) { \
68392 + if (subj == NULL) \
68393 + subj = role->subj_hash[iter]; \
68394 + if (subj == NULL) { \
68395 + iter++; \
68396 + continue; \
68397 + }
68398 +
68399 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68400 + subj = subj->next; \
68401 + if (subj == NULL) \
68402 + iter++; \
68403 + }
68404 +
68405 +
68406 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68407 + subj = role->hash->first; \
68408 + while (subj != NULL) {
68409 +
68410 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68411 + subj = subj->next; \
68412 + }
68413 +
68414 +#endif
68415 +
68416 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68417 new file mode 100644
68418 index 0000000..323ecf2
68419 --- /dev/null
68420 +++ b/include/linux/gralloc.h
68421 @@ -0,0 +1,9 @@
68422 +#ifndef __GRALLOC_H
68423 +#define __GRALLOC_H
68424 +
68425 +void acl_free_all(void);
68426 +int acl_alloc_stack_init(unsigned long size);
68427 +void *acl_alloc(unsigned long len);
68428 +void *acl_alloc_num(unsigned long num, unsigned long len);
68429 +
68430 +#endif
68431 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68432 new file mode 100644
68433 index 0000000..be66033
68434 --- /dev/null
68435 +++ b/include/linux/grdefs.h
68436 @@ -0,0 +1,140 @@
68437 +#ifndef GRDEFS_H
68438 +#define GRDEFS_H
68439 +
68440 +/* Begin grsecurity status declarations */
68441 +
68442 +enum {
68443 + GR_READY = 0x01,
68444 + GR_STATUS_INIT = 0x00 // disabled state
68445 +};
68446 +
68447 +/* Begin ACL declarations */
68448 +
68449 +/* Role flags */
68450 +
68451 +enum {
68452 + GR_ROLE_USER = 0x0001,
68453 + GR_ROLE_GROUP = 0x0002,
68454 + GR_ROLE_DEFAULT = 0x0004,
68455 + GR_ROLE_SPECIAL = 0x0008,
68456 + GR_ROLE_AUTH = 0x0010,
68457 + GR_ROLE_NOPW = 0x0020,
68458 + GR_ROLE_GOD = 0x0040,
68459 + GR_ROLE_LEARN = 0x0080,
68460 + GR_ROLE_TPE = 0x0100,
68461 + GR_ROLE_DOMAIN = 0x0200,
68462 + GR_ROLE_PAM = 0x0400,
68463 + GR_ROLE_PERSIST = 0x0800
68464 +};
68465 +
68466 +/* ACL Subject and Object mode flags */
68467 +enum {
68468 + GR_DELETED = 0x80000000
68469 +};
68470 +
68471 +/* ACL Object-only mode flags */
68472 +enum {
68473 + GR_READ = 0x00000001,
68474 + GR_APPEND = 0x00000002,
68475 + GR_WRITE = 0x00000004,
68476 + GR_EXEC = 0x00000008,
68477 + GR_FIND = 0x00000010,
68478 + GR_INHERIT = 0x00000020,
68479 + GR_SETID = 0x00000040,
68480 + GR_CREATE = 0x00000080,
68481 + GR_DELETE = 0x00000100,
68482 + GR_LINK = 0x00000200,
68483 + GR_AUDIT_READ = 0x00000400,
68484 + GR_AUDIT_APPEND = 0x00000800,
68485 + GR_AUDIT_WRITE = 0x00001000,
68486 + GR_AUDIT_EXEC = 0x00002000,
68487 + GR_AUDIT_FIND = 0x00004000,
68488 + GR_AUDIT_INHERIT= 0x00008000,
68489 + GR_AUDIT_SETID = 0x00010000,
68490 + GR_AUDIT_CREATE = 0x00020000,
68491 + GR_AUDIT_DELETE = 0x00040000,
68492 + GR_AUDIT_LINK = 0x00080000,
68493 + GR_PTRACERD = 0x00100000,
68494 + GR_NOPTRACE = 0x00200000,
68495 + GR_SUPPRESS = 0x00400000,
68496 + GR_NOLEARN = 0x00800000,
68497 + GR_INIT_TRANSFER= 0x01000000
68498 +};
68499 +
68500 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
68501 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
68502 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
68503 +
68504 +/* ACL subject-only mode flags */
68505 +enum {
68506 + GR_KILL = 0x00000001,
68507 + GR_VIEW = 0x00000002,
68508 + GR_PROTECTED = 0x00000004,
68509 + GR_LEARN = 0x00000008,
68510 + GR_OVERRIDE = 0x00000010,
68511 + /* just a placeholder, this mode is only used in userspace */
68512 + GR_DUMMY = 0x00000020,
68513 + GR_PROTSHM = 0x00000040,
68514 + GR_KILLPROC = 0x00000080,
68515 + GR_KILLIPPROC = 0x00000100,
68516 + /* just a placeholder, this mode is only used in userspace */
68517 + GR_NOTROJAN = 0x00000200,
68518 + GR_PROTPROCFD = 0x00000400,
68519 + GR_PROCACCT = 0x00000800,
68520 + GR_RELAXPTRACE = 0x00001000,
68521 + //GR_NESTED = 0x00002000,
68522 + GR_INHERITLEARN = 0x00004000,
68523 + GR_PROCFIND = 0x00008000,
68524 + GR_POVERRIDE = 0x00010000,
68525 + GR_KERNELAUTH = 0x00020000,
68526 + GR_ATSECURE = 0x00040000,
68527 + GR_SHMEXEC = 0x00080000
68528 +};
68529 +
68530 +enum {
68531 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
68532 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
68533 + GR_PAX_ENABLE_MPROTECT = 0x0004,
68534 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
68535 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
68536 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
68537 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
68538 + GR_PAX_DISABLE_MPROTECT = 0x0400,
68539 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
68540 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
68541 +};
68542 +
68543 +enum {
68544 + GR_ID_USER = 0x01,
68545 + GR_ID_GROUP = 0x02,
68546 +};
68547 +
68548 +enum {
68549 + GR_ID_ALLOW = 0x01,
68550 + GR_ID_DENY = 0x02,
68551 +};
68552 +
68553 +#define GR_CRASH_RES 31
68554 +#define GR_UIDTABLE_MAX 500
68555 +
68556 +/* begin resource learning section */
68557 +enum {
68558 + GR_RLIM_CPU_BUMP = 60,
68559 + GR_RLIM_FSIZE_BUMP = 50000,
68560 + GR_RLIM_DATA_BUMP = 10000,
68561 + GR_RLIM_STACK_BUMP = 1000,
68562 + GR_RLIM_CORE_BUMP = 10000,
68563 + GR_RLIM_RSS_BUMP = 500000,
68564 + GR_RLIM_NPROC_BUMP = 1,
68565 + GR_RLIM_NOFILE_BUMP = 5,
68566 + GR_RLIM_MEMLOCK_BUMP = 50000,
68567 + GR_RLIM_AS_BUMP = 500000,
68568 + GR_RLIM_LOCKS_BUMP = 2,
68569 + GR_RLIM_SIGPENDING_BUMP = 5,
68570 + GR_RLIM_MSGQUEUE_BUMP = 10000,
68571 + GR_RLIM_NICE_BUMP = 1,
68572 + GR_RLIM_RTPRIO_BUMP = 1,
68573 + GR_RLIM_RTTIME_BUMP = 1000000
68574 +};
68575 +
68576 +#endif
68577 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
68578 new file mode 100644
68579 index 0000000..5402bce
68580 --- /dev/null
68581 +++ b/include/linux/grinternal.h
68582 @@ -0,0 +1,215 @@
68583 +#ifndef __GRINTERNAL_H
68584 +#define __GRINTERNAL_H
68585 +
68586 +#ifdef CONFIG_GRKERNSEC
68587 +
68588 +#include <linux/fs.h>
68589 +#include <linux/mnt_namespace.h>
68590 +#include <linux/nsproxy.h>
68591 +#include <linux/gracl.h>
68592 +#include <linux/grdefs.h>
68593 +#include <linux/grmsg.h>
68594 +
68595 +void gr_add_learn_entry(const char *fmt, ...)
68596 + __attribute__ ((format (printf, 1, 2)));
68597 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
68598 + const struct vfsmount *mnt);
68599 +__u32 gr_check_create(const struct dentry *new_dentry,
68600 + const struct dentry *parent,
68601 + const struct vfsmount *mnt, const __u32 mode);
68602 +int gr_check_protected_task(const struct task_struct *task);
68603 +__u32 to_gr_audit(const __u32 reqmode);
68604 +int gr_set_acls(const int type);
68605 +int gr_apply_subject_to_task(struct task_struct *task);
68606 +int gr_acl_is_enabled(void);
68607 +char gr_roletype_to_char(void);
68608 +
68609 +void gr_handle_alertkill(struct task_struct *task);
68610 +char *gr_to_filename(const struct dentry *dentry,
68611 + const struct vfsmount *mnt);
68612 +char *gr_to_filename1(const struct dentry *dentry,
68613 + const struct vfsmount *mnt);
68614 +char *gr_to_filename2(const struct dentry *dentry,
68615 + const struct vfsmount *mnt);
68616 +char *gr_to_filename3(const struct dentry *dentry,
68617 + const struct vfsmount *mnt);
68618 +
68619 +extern int grsec_enable_ptrace_readexec;
68620 +extern int grsec_enable_harden_ptrace;
68621 +extern int grsec_enable_link;
68622 +extern int grsec_enable_fifo;
68623 +extern int grsec_enable_execve;
68624 +extern int grsec_enable_shm;
68625 +extern int grsec_enable_execlog;
68626 +extern int grsec_enable_signal;
68627 +extern int grsec_enable_audit_ptrace;
68628 +extern int grsec_enable_forkfail;
68629 +extern int grsec_enable_time;
68630 +extern int grsec_enable_rofs;
68631 +extern int grsec_enable_chroot_shmat;
68632 +extern int grsec_enable_chroot_mount;
68633 +extern int grsec_enable_chroot_double;
68634 +extern int grsec_enable_chroot_pivot;
68635 +extern int grsec_enable_chroot_chdir;
68636 +extern int grsec_enable_chroot_chmod;
68637 +extern int grsec_enable_chroot_mknod;
68638 +extern int grsec_enable_chroot_fchdir;
68639 +extern int grsec_enable_chroot_nice;
68640 +extern int grsec_enable_chroot_execlog;
68641 +extern int grsec_enable_chroot_caps;
68642 +extern int grsec_enable_chroot_sysctl;
68643 +extern int grsec_enable_chroot_unix;
68644 +extern int grsec_enable_symlinkown;
68645 +extern kgid_t grsec_symlinkown_gid;
68646 +extern int grsec_enable_tpe;
68647 +extern kgid_t grsec_tpe_gid;
68648 +extern int grsec_enable_tpe_all;
68649 +extern int grsec_enable_tpe_invert;
68650 +extern int grsec_enable_socket_all;
68651 +extern kgid_t grsec_socket_all_gid;
68652 +extern int grsec_enable_socket_client;
68653 +extern kgid_t grsec_socket_client_gid;
68654 +extern int grsec_enable_socket_server;
68655 +extern kgid_t grsec_socket_server_gid;
68656 +extern kgid_t grsec_audit_gid;
68657 +extern int grsec_enable_group;
68658 +extern int grsec_enable_audit_textrel;
68659 +extern int grsec_enable_log_rwxmaps;
68660 +extern int grsec_enable_mount;
68661 +extern int grsec_enable_chdir;
68662 +extern int grsec_resource_logging;
68663 +extern int grsec_enable_blackhole;
68664 +extern int grsec_lastack_retries;
68665 +extern int grsec_enable_brute;
68666 +extern int grsec_lock;
68667 +
68668 +extern spinlock_t grsec_alert_lock;
68669 +extern unsigned long grsec_alert_wtime;
68670 +extern unsigned long grsec_alert_fyet;
68671 +
68672 +extern spinlock_t grsec_audit_lock;
68673 +
68674 +extern rwlock_t grsec_exec_file_lock;
68675 +
68676 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
68677 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
68678 + (tsk)->exec_file->f_path.mnt) : "/")
68679 +
68680 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
68681 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
68682 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
68683 +
68684 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
68685 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
68686 + (tsk)->exec_file->f_path.mnt) : "/")
68687 +
68688 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
68689 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
68690 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
68691 +
68692 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
68693 +
68694 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
68695 +
68696 +#define GR_CHROOT_CAPS {{ \
68697 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
68698 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
68699 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
68700 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
68701 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
68702 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
68703 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
68704 +
68705 +#define security_learn(normal_msg,args...) \
68706 +({ \
68707 + read_lock(&grsec_exec_file_lock); \
68708 + gr_add_learn_entry(normal_msg "\n", ## args); \
68709 + read_unlock(&grsec_exec_file_lock); \
68710 +})
68711 +
68712 +enum {
68713 + GR_DO_AUDIT,
68714 + GR_DONT_AUDIT,
68715 + /* used for non-audit messages that we shouldn't kill the task on */
68716 + GR_DONT_AUDIT_GOOD
68717 +};
68718 +
68719 +enum {
68720 + GR_TTYSNIFF,
68721 + GR_RBAC,
68722 + GR_RBAC_STR,
68723 + GR_STR_RBAC,
68724 + GR_RBAC_MODE2,
68725 + GR_RBAC_MODE3,
68726 + GR_FILENAME,
68727 + GR_SYSCTL_HIDDEN,
68728 + GR_NOARGS,
68729 + GR_ONE_INT,
68730 + GR_ONE_INT_TWO_STR,
68731 + GR_ONE_STR,
68732 + GR_STR_INT,
68733 + GR_TWO_STR_INT,
68734 + GR_TWO_INT,
68735 + GR_TWO_U64,
68736 + GR_THREE_INT,
68737 + GR_FIVE_INT_TWO_STR,
68738 + GR_TWO_STR,
68739 + GR_THREE_STR,
68740 + GR_FOUR_STR,
68741 + GR_STR_FILENAME,
68742 + GR_FILENAME_STR,
68743 + GR_FILENAME_TWO_INT,
68744 + GR_FILENAME_TWO_INT_STR,
68745 + GR_TEXTREL,
68746 + GR_PTRACE,
68747 + GR_RESOURCE,
68748 + GR_CAP,
68749 + GR_SIG,
68750 + GR_SIG2,
68751 + GR_CRASH1,
68752 + GR_CRASH2,
68753 + GR_PSACCT,
68754 + GR_RWXMAP
68755 +};
68756 +
68757 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
68758 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
68759 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
68760 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
68761 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
68762 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
68763 +#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)
68764 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
68765 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
68766 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
68767 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
68768 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
68769 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
68770 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
68771 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
68772 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
68773 +#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)
68774 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
68775 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
68776 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
68777 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
68778 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
68779 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
68780 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
68781 +#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)
68782 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
68783 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
68784 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
68785 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
68786 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
68787 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
68788 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
68789 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
68790 +#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)
68791 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
68792 +
68793 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
68794 +
68795 +#endif
68796 +
68797 +#endif
68798 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
68799 new file mode 100644
68800 index 0000000..2bd4c8d
68801 --- /dev/null
68802 +++ b/include/linux/grmsg.h
68803 @@ -0,0 +1,111 @@
68804 +#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"
68805 +#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"
68806 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
68807 +#define GR_STOPMOD_MSG "denied modification of module state by "
68808 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
68809 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
68810 +#define GR_IOPERM_MSG "denied use of ioperm() by "
68811 +#define GR_IOPL_MSG "denied use of iopl() by "
68812 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
68813 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
68814 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
68815 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
68816 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
68817 +#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"
68818 +#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"
68819 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
68820 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
68821 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
68822 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
68823 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
68824 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
68825 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
68826 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
68827 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
68828 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
68829 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
68830 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
68831 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
68832 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
68833 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
68834 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
68835 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
68836 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
68837 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
68838 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
68839 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
68840 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
68841 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
68842 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
68843 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
68844 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
68845 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
68846 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
68847 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
68848 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
68849 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
68850 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
68851 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
68852 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
68853 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
68854 +#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"
68855 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
68856 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
68857 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
68858 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
68859 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
68860 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
68861 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
68862 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
68863 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
68864 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
68865 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
68866 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
68867 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
68868 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
68869 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
68870 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
68871 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
68872 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
68873 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
68874 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
68875 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
68876 +#define GR_NICE_CHROOT_MSG "denied priority change by "
68877 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
68878 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
68879 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
68880 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
68881 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
68882 +#define GR_TIME_MSG "time set by "
68883 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
68884 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
68885 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
68886 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
68887 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
68888 +#define GR_BIND_MSG "denied bind() by "
68889 +#define GR_CONNECT_MSG "denied connect() by "
68890 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
68891 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
68892 +#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"
68893 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
68894 +#define GR_CAP_ACL_MSG "use of %s denied for "
68895 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
68896 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
68897 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
68898 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
68899 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
68900 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
68901 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
68902 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
68903 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
68904 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
68905 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
68906 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
68907 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
68908 +#define GR_VM86_MSG "denied use of vm86 by "
68909 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
68910 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
68911 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
68912 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
68913 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
68914 +#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 "
68915 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
68916 new file mode 100644
68917 index 0000000..d7ef0ac
68918 --- /dev/null
68919 +++ b/include/linux/grsecurity.h
68920 @@ -0,0 +1,242 @@
68921 +#ifndef GR_SECURITY_H
68922 +#define GR_SECURITY_H
68923 +#include <linux/fs.h>
68924 +#include <linux/fs_struct.h>
68925 +#include <linux/binfmts.h>
68926 +#include <linux/gracl.h>
68927 +
68928 +/* notify of brain-dead configs */
68929 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
68930 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
68931 +#endif
68932 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
68933 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
68934 +#endif
68935 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
68936 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
68937 +#endif
68938 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
68939 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
68940 +#endif
68941 +
68942 +void gr_handle_brute_attach(unsigned long mm_flags);
68943 +void gr_handle_brute_check(void);
68944 +void gr_handle_kernel_exploit(void);
68945 +int gr_process_user_ban(void);
68946 +
68947 +char gr_roletype_to_char(void);
68948 +
68949 +int gr_acl_enable_at_secure(void);
68950 +
68951 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
68952 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
68953 +
68954 +void gr_del_task_from_ip_table(struct task_struct *p);
68955 +
68956 +int gr_pid_is_chrooted(struct task_struct *p);
68957 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
68958 +int gr_handle_chroot_nice(void);
68959 +int gr_handle_chroot_sysctl(const int op);
68960 +int gr_handle_chroot_setpriority(struct task_struct *p,
68961 + const int niceval);
68962 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
68963 +int gr_handle_chroot_chroot(const struct dentry *dentry,
68964 + const struct vfsmount *mnt);
68965 +void gr_handle_chroot_chdir(const struct path *path);
68966 +int gr_handle_chroot_chmod(const struct dentry *dentry,
68967 + const struct vfsmount *mnt, const int mode);
68968 +int gr_handle_chroot_mknod(const struct dentry *dentry,
68969 + const struct vfsmount *mnt, const int mode);
68970 +int gr_handle_chroot_mount(const struct dentry *dentry,
68971 + const struct vfsmount *mnt,
68972 + const char *dev_name);
68973 +int gr_handle_chroot_pivot(void);
68974 +int gr_handle_chroot_unix(const pid_t pid);
68975 +
68976 +int gr_handle_rawio(const struct inode *inode);
68977 +
68978 +void gr_handle_ioperm(void);
68979 +void gr_handle_iopl(void);
68980 +
68981 +umode_t gr_acl_umask(void);
68982 +
68983 +int gr_tpe_allow(const struct file *file);
68984 +
68985 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
68986 +void gr_clear_chroot_entries(struct task_struct *task);
68987 +
68988 +void gr_log_forkfail(const int retval);
68989 +void gr_log_timechange(void);
68990 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
68991 +void gr_log_chdir(const struct dentry *dentry,
68992 + const struct vfsmount *mnt);
68993 +void gr_log_chroot_exec(const struct dentry *dentry,
68994 + const struct vfsmount *mnt);
68995 +void gr_log_remount(const char *devname, const int retval);
68996 +void gr_log_unmount(const char *devname, const int retval);
68997 +void gr_log_mount(const char *from, const char *to, const int retval);
68998 +void gr_log_textrel(struct vm_area_struct *vma);
68999 +void gr_log_rwxmmap(struct file *file);
69000 +void gr_log_rwxmprotect(struct file *file);
69001 +
69002 +int gr_handle_follow_link(const struct inode *parent,
69003 + const struct inode *inode,
69004 + const struct dentry *dentry,
69005 + const struct vfsmount *mnt);
69006 +int gr_handle_fifo(const struct dentry *dentry,
69007 + const struct vfsmount *mnt,
69008 + const struct dentry *dir, const int flag,
69009 + const int acc_mode);
69010 +int gr_handle_hardlink(const struct dentry *dentry,
69011 + const struct vfsmount *mnt,
69012 + struct inode *inode,
69013 + const int mode, const struct filename *to);
69014 +
69015 +int gr_is_capable(const int cap);
69016 +int gr_is_capable_nolog(const int cap);
69017 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69018 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69019 +
69020 +void gr_copy_label(struct task_struct *tsk);
69021 +void gr_handle_crash(struct task_struct *task, const int sig);
69022 +int gr_handle_signal(const struct task_struct *p, const int sig);
69023 +int gr_check_crash_uid(const kuid_t uid);
69024 +int gr_check_protected_task(const struct task_struct *task);
69025 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69026 +int gr_acl_handle_mmap(const struct file *file,
69027 + const unsigned long prot);
69028 +int gr_acl_handle_mprotect(const struct file *file,
69029 + const unsigned long prot);
69030 +int gr_check_hidden_task(const struct task_struct *tsk);
69031 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69032 + const struct vfsmount *mnt);
69033 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69034 + const struct vfsmount *mnt);
69035 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69036 + const struct vfsmount *mnt, const int fmode);
69037 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69038 + const struct vfsmount *mnt, umode_t *mode);
69039 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69040 + const struct vfsmount *mnt);
69041 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69042 + const struct vfsmount *mnt);
69043 +int gr_handle_ptrace(struct task_struct *task, const long request);
69044 +int gr_handle_proc_ptrace(struct task_struct *task);
69045 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69046 + const struct vfsmount *mnt);
69047 +int gr_check_crash_exec(const struct file *filp);
69048 +int gr_acl_is_enabled(void);
69049 +void gr_set_kernel_label(struct task_struct *task);
69050 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69051 + const kgid_t gid);
69052 +int gr_set_proc_label(const struct dentry *dentry,
69053 + const struct vfsmount *mnt,
69054 + const int unsafe_flags);
69055 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69056 + const struct vfsmount *mnt);
69057 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69058 + const struct vfsmount *mnt, int acc_mode);
69059 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69060 + const struct dentry *p_dentry,
69061 + const struct vfsmount *p_mnt,
69062 + int open_flags, int acc_mode, const int imode);
69063 +void gr_handle_create(const struct dentry *dentry,
69064 + const struct vfsmount *mnt);
69065 +void gr_handle_proc_create(const struct dentry *dentry,
69066 + const struct inode *inode);
69067 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69068 + const struct dentry *parent_dentry,
69069 + const struct vfsmount *parent_mnt,
69070 + const int mode);
69071 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69072 + const struct dentry *parent_dentry,
69073 + const struct vfsmount *parent_mnt);
69074 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69075 + const struct vfsmount *mnt);
69076 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69077 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69078 + const struct vfsmount *mnt);
69079 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69080 + const struct dentry *parent_dentry,
69081 + const struct vfsmount *parent_mnt,
69082 + const struct filename *from);
69083 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69084 + const struct dentry *parent_dentry,
69085 + const struct vfsmount *parent_mnt,
69086 + const struct dentry *old_dentry,
69087 + const struct vfsmount *old_mnt, const struct filename *to);
69088 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69089 +int gr_acl_handle_rename(struct dentry *new_dentry,
69090 + struct dentry *parent_dentry,
69091 + const struct vfsmount *parent_mnt,
69092 + struct dentry *old_dentry,
69093 + struct inode *old_parent_inode,
69094 + struct vfsmount *old_mnt, const struct filename *newname);
69095 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69096 + struct dentry *old_dentry,
69097 + struct dentry *new_dentry,
69098 + struct vfsmount *mnt, const __u8 replace);
69099 +__u32 gr_check_link(const struct dentry *new_dentry,
69100 + const struct dentry *parent_dentry,
69101 + const struct vfsmount *parent_mnt,
69102 + const struct dentry *old_dentry,
69103 + const struct vfsmount *old_mnt);
69104 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69105 + const unsigned int namelen, const ino_t ino);
69106 +
69107 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69108 + const struct vfsmount *mnt);
69109 +void gr_acl_handle_exit(void);
69110 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69111 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69112 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69113 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69114 +void gr_audit_ptrace(struct task_struct *task);
69115 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69116 +void gr_put_exec_file(struct task_struct *task);
69117 +
69118 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69119 +
69120 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69121 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69122 + const unsigned long wanted, const int gt);
69123 +#else
69124 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69125 + const unsigned long wanted, const int gt)
69126 +{
69127 +}
69128 +#endif
69129 +
69130 +#ifdef CONFIG_GRKERNSEC_RESLOG
69131 +extern void gr_log_resource(const struct task_struct *task, const int res,
69132 + const unsigned long wanted, const int gt);
69133 +#else
69134 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69135 + const unsigned long wanted, const int gt)
69136 +{
69137 +}
69138 +#endif
69139 +
69140 +#ifdef CONFIG_GRKERNSEC
69141 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69142 +void gr_handle_vm86(void);
69143 +void gr_handle_mem_readwrite(u64 from, u64 to);
69144 +
69145 +void gr_log_badprocpid(const char *entry);
69146 +
69147 +extern int grsec_enable_dmesg;
69148 +extern int grsec_disable_privio;
69149 +
69150 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69151 +extern kgid_t grsec_proc_gid;
69152 +#endif
69153 +
69154 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69155 +extern int grsec_enable_chroot_findtask;
69156 +#endif
69157 +#ifdef CONFIG_GRKERNSEC_SETXID
69158 +extern int grsec_enable_setxid;
69159 +#endif
69160 +#endif
69161 +
69162 +#endif
69163 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69164 new file mode 100644
69165 index 0000000..e7ffaaf
69166 --- /dev/null
69167 +++ b/include/linux/grsock.h
69168 @@ -0,0 +1,19 @@
69169 +#ifndef __GRSOCK_H
69170 +#define __GRSOCK_H
69171 +
69172 +extern void gr_attach_curr_ip(const struct sock *sk);
69173 +extern int gr_handle_sock_all(const int family, const int type,
69174 + const int protocol);
69175 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69176 +extern int gr_handle_sock_server_other(const struct sock *sck);
69177 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69178 +extern int gr_search_connect(struct socket * sock,
69179 + struct sockaddr_in * addr);
69180 +extern int gr_search_bind(struct socket * sock,
69181 + struct sockaddr_in * addr);
69182 +extern int gr_search_listen(struct socket * sock);
69183 +extern int gr_search_accept(struct socket * sock);
69184 +extern int gr_search_socket(const int domain, const int type,
69185 + const int protocol);
69186 +
69187 +#endif
69188 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69189 index 7fb31da..08b5114 100644
69190 --- a/include/linux/highmem.h
69191 +++ b/include/linux/highmem.h
69192 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69193 kunmap_atomic(kaddr);
69194 }
69195
69196 +static inline void sanitize_highpage(struct page *page)
69197 +{
69198 + void *kaddr;
69199 + unsigned long flags;
69200 +
69201 + local_irq_save(flags);
69202 + kaddr = kmap_atomic(page);
69203 + clear_page(kaddr);
69204 + kunmap_atomic(kaddr);
69205 + local_irq_restore(flags);
69206 +}
69207 +
69208 static inline void zero_user_segments(struct page *page,
69209 unsigned start1, unsigned end1,
69210 unsigned start2, unsigned end2)
69211 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69212 index 1c7b89a..7f52502 100644
69213 --- a/include/linux/hwmon-sysfs.h
69214 +++ b/include/linux/hwmon-sysfs.h
69215 @@ -25,7 +25,8 @@
69216 struct sensor_device_attribute{
69217 struct device_attribute dev_attr;
69218 int index;
69219 -};
69220 +} __do_const;
69221 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69222 #define to_sensor_dev_attr(_dev_attr) \
69223 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69224
69225 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69226 struct device_attribute dev_attr;
69227 u8 index;
69228 u8 nr;
69229 -};
69230 +} __do_const;
69231 #define to_sensor_dev_attr_2(_dev_attr) \
69232 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69233
69234 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69235 index d0c4db7..61b3577 100644
69236 --- a/include/linux/i2c.h
69237 +++ b/include/linux/i2c.h
69238 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69239 /* To determine what the adapter supports */
69240 u32 (*functionality) (struct i2c_adapter *);
69241 };
69242 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69243
69244 /*
69245 * i2c_adapter is the structure used to identify a physical i2c bus along
69246 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69247 index d23c3c2..eb63c81 100644
69248 --- a/include/linux/i2o.h
69249 +++ b/include/linux/i2o.h
69250 @@ -565,7 +565,7 @@ struct i2o_controller {
69251 struct i2o_device *exec; /* Executive */
69252 #if BITS_PER_LONG == 64
69253 spinlock_t context_list_lock; /* lock for context_list */
69254 - atomic_t context_list_counter; /* needed for unique contexts */
69255 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69256 struct list_head context_list; /* list of context id's
69257 and pointers */
69258 #endif
69259 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69260 index aff7ad8..3942bbd 100644
69261 --- a/include/linux/if_pppox.h
69262 +++ b/include/linux/if_pppox.h
69263 @@ -76,7 +76,7 @@ struct pppox_proto {
69264 int (*ioctl)(struct socket *sock, unsigned int cmd,
69265 unsigned long arg);
69266 struct module *owner;
69267 -};
69268 +} __do_const;
69269
69270 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69271 extern void unregister_pppox_proto(int proto_num);
69272 diff --git a/include/linux/init.h b/include/linux/init.h
69273 index 8618147..0821126 100644
69274 --- a/include/linux/init.h
69275 +++ b/include/linux/init.h
69276 @@ -39,9 +39,36 @@
69277 * Also note, that this data cannot be "const".
69278 */
69279
69280 +#ifdef MODULE
69281 +#define add_init_latent_entropy
69282 +#define add_devinit_latent_entropy
69283 +#define add_cpuinit_latent_entropy
69284 +#define add_meminit_latent_entropy
69285 +#else
69286 +#define add_init_latent_entropy __latent_entropy
69287 +
69288 +#ifdef CONFIG_HOTPLUG
69289 +#define add_devinit_latent_entropy
69290 +#else
69291 +#define add_devinit_latent_entropy __latent_entropy
69292 +#endif
69293 +
69294 +#ifdef CONFIG_HOTPLUG_CPU
69295 +#define add_cpuinit_latent_entropy
69296 +#else
69297 +#define add_cpuinit_latent_entropy __latent_entropy
69298 +#endif
69299 +
69300 +#ifdef CONFIG_MEMORY_HOTPLUG
69301 +#define add_meminit_latent_entropy
69302 +#else
69303 +#define add_meminit_latent_entropy __latent_entropy
69304 +#endif
69305 +#endif
69306 +
69307 /* These are for everybody (although not all archs will actually
69308 discard it in modules) */
69309 -#define __init __section(.init.text) __cold notrace
69310 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69311 #define __initdata __section(.init.data)
69312 #define __initconst __constsection(.init.rodata)
69313 #define __exitdata __section(.exit.data)
69314 @@ -94,7 +121,7 @@
69315 #define __exit __section(.exit.text) __exitused __cold notrace
69316
69317 /* Used for HOTPLUG_CPU */
69318 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69319 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69320 #define __cpuinitdata __section(.cpuinit.data)
69321 #define __cpuinitconst __constsection(.cpuinit.rodata)
69322 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69323 @@ -102,7 +129,7 @@
69324 #define __cpuexitconst __constsection(.cpuexit.rodata)
69325
69326 /* Used for MEMORY_HOTPLUG */
69327 -#define __meminit __section(.meminit.text) __cold notrace
69328 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69329 #define __meminitdata __section(.meminit.data)
69330 #define __meminitconst __constsection(.meminit.rodata)
69331 #define __memexit __section(.memexit.text) __exitused __cold notrace
69332 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69333 index 5cd0f09..c9f67cc 100644
69334 --- a/include/linux/init_task.h
69335 +++ b/include/linux/init_task.h
69336 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
69337
69338 #define INIT_TASK_COMM "swapper"
69339
69340 +#ifdef CONFIG_X86
69341 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69342 +#else
69343 +#define INIT_TASK_THREAD_INFO
69344 +#endif
69345 +
69346 /*
69347 * INIT_TASK is used to set up the first task table, touch at
69348 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69349 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
69350 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69351 .comm = INIT_TASK_COMM, \
69352 .thread = INIT_THREAD, \
69353 + INIT_TASK_THREAD_INFO \
69354 .fs = &init_fs, \
69355 .files = &init_files, \
69356 .signal = &init_signals, \
69357 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69358 index 5fa5afe..ac55b25 100644
69359 --- a/include/linux/interrupt.h
69360 +++ b/include/linux/interrupt.h
69361 @@ -430,7 +430,7 @@ enum
69362 /* map softirq index to softirq name. update 'softirq_to_name' in
69363 * kernel/softirq.c when adding a new softirq.
69364 */
69365 -extern char *softirq_to_name[NR_SOFTIRQS];
69366 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69367
69368 /* softirq mask and active fields moved to irq_cpustat_t in
69369 * asm/hardirq.h to get better cache usage. KAO
69370 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69371
69372 struct softirq_action
69373 {
69374 - void (*action)(struct softirq_action *);
69375 -};
69376 + void (*action)(void);
69377 +} __no_const;
69378
69379 asmlinkage void do_softirq(void);
69380 asmlinkage void __do_softirq(void);
69381 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69382 +extern void open_softirq(int nr, void (*action)(void));
69383 extern void softirq_init(void);
69384 extern void __raise_softirq_irqoff(unsigned int nr);
69385
69386 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69387 index ba3b8a9..7e14ed8 100644
69388 --- a/include/linux/iommu.h
69389 +++ b/include/linux/iommu.h
69390 @@ -113,7 +113,7 @@ struct iommu_ops {
69391 u32 (*domain_get_windows)(struct iommu_domain *domain);
69392
69393 unsigned long pgsize_bitmap;
69394 -};
69395 +} __do_const;
69396
69397 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69398 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69399 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
69400 index 85ac9b9b..e5759ab 100644
69401 --- a/include/linux/ioport.h
69402 +++ b/include/linux/ioport.h
69403 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
69404 int adjust_resource(struct resource *res, resource_size_t start,
69405 resource_size_t size);
69406 resource_size_t resource_alignment(struct resource *res);
69407 -static inline resource_size_t resource_size(const struct resource *res)
69408 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
69409 {
69410 return res->end - res->start + 1;
69411 }
69412 diff --git a/include/linux/irq.h b/include/linux/irq.h
69413 index bc4e066..50468a9 100644
69414 --- a/include/linux/irq.h
69415 +++ b/include/linux/irq.h
69416 @@ -328,7 +328,8 @@ struct irq_chip {
69417 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69418
69419 unsigned long flags;
69420 -};
69421 +} __do_const;
69422 +typedef struct irq_chip __no_const irq_chip_no_const;
69423
69424 /*
69425 * irq_chip specific flags
69426 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
69427 index 3fd8e42..a73e966 100644
69428 --- a/include/linux/irqchip/arm-gic.h
69429 +++ b/include/linux/irqchip/arm-gic.h
69430 @@ -59,9 +59,11 @@
69431
69432 #ifndef __ASSEMBLY__
69433
69434 +#include <linux/irq.h>
69435 +
69436 struct device_node;
69437
69438 -extern struct irq_chip gic_arch_extn;
69439 +extern irq_chip_no_const gic_arch_extn;
69440
69441 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
69442 u32 offset, struct device_node *);
69443 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69444 index 6883e19..06992b1 100644
69445 --- a/include/linux/kallsyms.h
69446 +++ b/include/linux/kallsyms.h
69447 @@ -15,7 +15,8 @@
69448
69449 struct module;
69450
69451 -#ifdef CONFIG_KALLSYMS
69452 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69453 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69454 /* Lookup the address for a symbol. Returns 0 if not found. */
69455 unsigned long kallsyms_lookup_name(const char *name);
69456
69457 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69458 /* Stupid that this does nothing, but I didn't create this mess. */
69459 #define __print_symbol(fmt, addr)
69460 #endif /*CONFIG_KALLSYMS*/
69461 +#else /* when included by kallsyms.c, vsnprintf.c, or
69462 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69463 +extern void __print_symbol(const char *fmt, unsigned long address);
69464 +extern int sprint_backtrace(char *buffer, unsigned long address);
69465 +extern int sprint_symbol(char *buffer, unsigned long address);
69466 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69467 +const char *kallsyms_lookup(unsigned long addr,
69468 + unsigned long *symbolsize,
69469 + unsigned long *offset,
69470 + char **modname, char *namebuf);
69471 +#endif
69472
69473 /* This macro allows us to keep printk typechecking */
69474 static __printf(1, 2)
69475 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69476 index 518a53a..5e28358 100644
69477 --- a/include/linux/key-type.h
69478 +++ b/include/linux/key-type.h
69479 @@ -125,7 +125,7 @@ struct key_type {
69480 /* internal fields */
69481 struct list_head link; /* link in types list */
69482 struct lock_class_key lock_class; /* key->sem lock class */
69483 -};
69484 +} __do_const;
69485
69486 extern struct key_type key_type_keyring;
69487
69488 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69489 index c6e091b..a940adf 100644
69490 --- a/include/linux/kgdb.h
69491 +++ b/include/linux/kgdb.h
69492 @@ -52,7 +52,7 @@ extern int kgdb_connected;
69493 extern int kgdb_io_module_registered;
69494
69495 extern atomic_t kgdb_setting_breakpoint;
69496 -extern atomic_t kgdb_cpu_doing_single_step;
69497 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
69498
69499 extern struct task_struct *kgdb_usethread;
69500 extern struct task_struct *kgdb_contthread;
69501 @@ -254,7 +254,7 @@ struct kgdb_arch {
69502 void (*correct_hw_break)(void);
69503
69504 void (*enable_nmi)(bool on);
69505 -};
69506 +} __do_const;
69507
69508 /**
69509 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
69510 @@ -279,7 +279,7 @@ struct kgdb_io {
69511 void (*pre_exception) (void);
69512 void (*post_exception) (void);
69513 int is_console;
69514 -};
69515 +} __do_const;
69516
69517 extern struct kgdb_arch arch_kgdb_ops;
69518
69519 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
69520 index 5398d58..5883a34 100644
69521 --- a/include/linux/kmod.h
69522 +++ b/include/linux/kmod.h
69523 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
69524 * usually useless though. */
69525 extern __printf(2, 3)
69526 int __request_module(bool wait, const char *name, ...);
69527 +extern __printf(3, 4)
69528 +int ___request_module(bool wait, char *param_name, const char *name, ...);
69529 #define request_module(mod...) __request_module(true, mod)
69530 #define request_module_nowait(mod...) __request_module(false, mod)
69531 #define try_then_request_module(x, mod...) \
69532 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
69533 index 939b112..ed6ed51 100644
69534 --- a/include/linux/kobject.h
69535 +++ b/include/linux/kobject.h
69536 @@ -111,7 +111,7 @@ struct kobj_type {
69537 struct attribute **default_attrs;
69538 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
69539 const void *(*namespace)(struct kobject *kobj);
69540 -};
69541 +} __do_const;
69542
69543 struct kobj_uevent_env {
69544 char *envp[UEVENT_NUM_ENVP];
69545 @@ -134,6 +134,7 @@ struct kobj_attribute {
69546 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
69547 const char *buf, size_t count);
69548 };
69549 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
69550
69551 extern const struct sysfs_ops kobj_sysfs_ops;
69552
69553 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
69554 index f66b065..c2c29b4 100644
69555 --- a/include/linux/kobject_ns.h
69556 +++ b/include/linux/kobject_ns.h
69557 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
69558 const void *(*netlink_ns)(struct sock *sk);
69559 const void *(*initial_ns)(void);
69560 void (*drop_ns)(void *);
69561 -};
69562 +} __do_const;
69563
69564 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
69565 int kobj_ns_type_registered(enum kobj_ns_type type);
69566 diff --git a/include/linux/kref.h b/include/linux/kref.h
69567 index 7419c02..aa2f02d 100644
69568 --- a/include/linux/kref.h
69569 +++ b/include/linux/kref.h
69570 @@ -65,7 +65,7 @@ static inline void kref_get(struct kref *kref)
69571 static inline int kref_sub(struct kref *kref, unsigned int count,
69572 void (*release)(struct kref *kref))
69573 {
69574 - WARN_ON(release == NULL);
69575 + BUG_ON(release == NULL);
69576
69577 if (atomic_sub_and_test((int) count, &kref->refcount)) {
69578 release(kref);
69579 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
69580 index c139582..0b5b102 100644
69581 --- a/include/linux/kvm_host.h
69582 +++ b/include/linux/kvm_host.h
69583 @@ -424,7 +424,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
69584 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
69585 void vcpu_put(struct kvm_vcpu *vcpu);
69586
69587 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69588 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69589 struct module *module);
69590 void kvm_exit(void);
69591
69592 @@ -582,7 +582,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
69593 struct kvm_guest_debug *dbg);
69594 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
69595
69596 -int kvm_arch_init(void *opaque);
69597 +int kvm_arch_init(const void *opaque);
69598 void kvm_arch_exit(void);
69599
69600 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
69601 diff --git a/include/linux/libata.h b/include/linux/libata.h
69602 index eae7a05..2cdd875 100644
69603 --- a/include/linux/libata.h
69604 +++ b/include/linux/libata.h
69605 @@ -919,7 +919,7 @@ struct ata_port_operations {
69606 * fields must be pointers.
69607 */
69608 const struct ata_port_operations *inherits;
69609 -};
69610 +} __do_const;
69611
69612 struct ata_port_info {
69613 unsigned long flags;
69614 diff --git a/include/linux/list.h b/include/linux/list.h
69615 index 6a1f8df..eaec1ff 100644
69616 --- a/include/linux/list.h
69617 +++ b/include/linux/list.h
69618 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
69619 extern void list_del(struct list_head *entry);
69620 #endif
69621
69622 +extern void __pax_list_add(struct list_head *new,
69623 + struct list_head *prev,
69624 + struct list_head *next);
69625 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
69626 +{
69627 + __pax_list_add(new, head, head->next);
69628 +}
69629 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
69630 +{
69631 + __pax_list_add(new, head->prev, head);
69632 +}
69633 +extern void pax_list_del(struct list_head *entry);
69634 +
69635 /**
69636 * list_replace - replace old entry by new one
69637 * @old : the element to be replaced
69638 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
69639 INIT_LIST_HEAD(entry);
69640 }
69641
69642 +extern void pax_list_del_init(struct list_head *entry);
69643 +
69644 /**
69645 * list_move - delete from one list and add as another's head
69646 * @list: the entry to move
69647 diff --git a/include/linux/math64.h b/include/linux/math64.h
69648 index b8ba855..0148090 100644
69649 --- a/include/linux/math64.h
69650 +++ b/include/linux/math64.h
69651 @@ -14,7 +14,7 @@
69652 * This is commonly provided by 32bit archs to provide an optimized 64bit
69653 * divide.
69654 */
69655 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69656 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69657 {
69658 *remainder = dividend % divisor;
69659 return dividend / divisor;
69660 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
69661 #define div64_long(x,y) div_s64((x),(y))
69662
69663 #ifndef div_u64_rem
69664 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69665 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69666 {
69667 *remainder = do_div(dividend, divisor);
69668 return dividend;
69669 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
69670 * divide.
69671 */
69672 #ifndef div_u64
69673 -static inline u64 div_u64(u64 dividend, u32 divisor)
69674 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
69675 {
69676 u32 remainder;
69677 return div_u64_rem(dividend, divisor, &remainder);
69678 diff --git a/include/linux/mm.h b/include/linux/mm.h
69679 index e2091b8..821db54 100644
69680 --- a/include/linux/mm.h
69681 +++ b/include/linux/mm.h
69682 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
69683 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
69684 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
69685 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
69686 +
69687 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
69688 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
69689 +#endif
69690 +
69691 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
69692
69693 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
69694 @@ -202,8 +207,8 @@ struct vm_operations_struct {
69695 /* called by access_process_vm when get_user_pages() fails, typically
69696 * for use by special VMAs that can switch between memory and hardware
69697 */
69698 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
69699 - void *buf, int len, int write);
69700 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
69701 + void *buf, size_t len, int write);
69702 #ifdef CONFIG_NUMA
69703 /*
69704 * set_policy() op must add a reference to any non-NULL @new mempolicy
69705 @@ -233,6 +238,7 @@ struct vm_operations_struct {
69706 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
69707 unsigned long size, pgoff_t pgoff);
69708 };
69709 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
69710
69711 struct mmu_gather;
69712 struct inode;
69713 @@ -970,8 +976,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
69714 unsigned long *pfn);
69715 int follow_phys(struct vm_area_struct *vma, unsigned long address,
69716 unsigned int flags, unsigned long *prot, resource_size_t *phys);
69717 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
69718 - void *buf, int len, int write);
69719 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
69720 + void *buf, size_t len, int write);
69721
69722 static inline void unmap_shared_mapping_range(struct address_space *mapping,
69723 loff_t const holebegin, loff_t const holelen)
69724 @@ -1010,9 +1016,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
69725 }
69726 #endif
69727
69728 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
69729 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
69730 - void *buf, int len, int write);
69731 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
69732 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
69733 + void *buf, size_t len, int write);
69734
69735 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
69736 unsigned long start, unsigned long nr_pages,
69737 @@ -1043,34 +1049,6 @@ int set_page_dirty(struct page *page);
69738 int set_page_dirty_lock(struct page *page);
69739 int clear_page_dirty_for_io(struct page *page);
69740
69741 -/* Is the vma a continuation of the stack vma above it? */
69742 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
69743 -{
69744 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
69745 -}
69746 -
69747 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
69748 - unsigned long addr)
69749 -{
69750 - return (vma->vm_flags & VM_GROWSDOWN) &&
69751 - (vma->vm_start == addr) &&
69752 - !vma_growsdown(vma->vm_prev, addr);
69753 -}
69754 -
69755 -/* Is the vma a continuation of the stack vma below it? */
69756 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
69757 -{
69758 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
69759 -}
69760 -
69761 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
69762 - unsigned long addr)
69763 -{
69764 - return (vma->vm_flags & VM_GROWSUP) &&
69765 - (vma->vm_end == addr) &&
69766 - !vma_growsup(vma->vm_next, addr);
69767 -}
69768 -
69769 extern pid_t
69770 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
69771
69772 @@ -1173,6 +1151,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
69773 }
69774 #endif
69775
69776 +#ifdef CONFIG_MMU
69777 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
69778 +#else
69779 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
69780 +{
69781 + return __pgprot(0);
69782 +}
69783 +#endif
69784 +
69785 int vma_wants_writenotify(struct vm_area_struct *vma);
69786
69787 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
69788 @@ -1191,8 +1178,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
69789 {
69790 return 0;
69791 }
69792 +
69793 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
69794 + unsigned long address)
69795 +{
69796 + return 0;
69797 +}
69798 #else
69799 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69800 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69801 #endif
69802
69803 #ifdef __PAGETABLE_PMD_FOLDED
69804 @@ -1201,8 +1195,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
69805 {
69806 return 0;
69807 }
69808 +
69809 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
69810 + unsigned long address)
69811 +{
69812 + return 0;
69813 +}
69814 #else
69815 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
69816 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
69817 #endif
69818
69819 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
69820 @@ -1220,11 +1221,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
69821 NULL: pud_offset(pgd, address);
69822 }
69823
69824 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
69825 +{
69826 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
69827 + NULL: pud_offset(pgd, address);
69828 +}
69829 +
69830 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
69831 {
69832 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
69833 NULL: pmd_offset(pud, address);
69834 }
69835 +
69836 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
69837 +{
69838 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
69839 + NULL: pmd_offset(pud, address);
69840 +}
69841 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
69842
69843 #if USE_SPLIT_PTLOCKS
69844 @@ -1455,6 +1468,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
69845 unsigned long len, unsigned long prot, unsigned long flags,
69846 unsigned long pgoff, unsigned long *populate);
69847 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
69848 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
69849
69850 #ifdef CONFIG_MMU
69851 extern int __mm_populate(unsigned long addr, unsigned long len,
69852 @@ -1483,6 +1497,7 @@ struct vm_unmapped_area_info {
69853 unsigned long high_limit;
69854 unsigned long align_mask;
69855 unsigned long align_offset;
69856 + unsigned long threadstack_offset;
69857 };
69858
69859 extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
69860 @@ -1561,6 +1576,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
69861 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
69862 struct vm_area_struct **pprev);
69863
69864 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
69865 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
69866 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
69867 +
69868 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
69869 NULL if none. Assume start_addr < end_addr. */
69870 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
69871 @@ -1589,15 +1608,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
69872 return vma;
69873 }
69874
69875 -#ifdef CONFIG_MMU
69876 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
69877 -#else
69878 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
69879 -{
69880 - return __pgprot(0);
69881 -}
69882 -#endif
69883 -
69884 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
69885 unsigned long change_prot_numa(struct vm_area_struct *vma,
69886 unsigned long start, unsigned long end);
69887 @@ -1649,6 +1659,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
69888 static inline void vm_stat_account(struct mm_struct *mm,
69889 unsigned long flags, struct file *file, long pages)
69890 {
69891 +
69892 +#ifdef CONFIG_PAX_RANDMMAP
69893 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
69894 +#endif
69895 +
69896 mm->total_vm += pages;
69897 }
69898 #endif /* CONFIG_PROC_FS */
69899 @@ -1725,7 +1740,7 @@ extern int unpoison_memory(unsigned long pfn);
69900 extern int sysctl_memory_failure_early_kill;
69901 extern int sysctl_memory_failure_recovery;
69902 extern void shake_page(struct page *p, int access);
69903 -extern atomic_long_t num_poisoned_pages;
69904 +extern atomic_long_unchecked_t num_poisoned_pages;
69905 extern int soft_offline_page(struct page *page, int flags);
69906
69907 extern void dump_page(struct page *page);
69908 @@ -1756,5 +1771,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
69909 static inline bool page_is_guard(struct page *page) { return false; }
69910 #endif /* CONFIG_DEBUG_PAGEALLOC */
69911
69912 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
69913 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
69914 +#else
69915 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
69916 +#endif
69917 +
69918 #endif /* __KERNEL__ */
69919 #endif /* _LINUX_MM_H */
69920 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
69921 index ace9a5f..81bdb59 100644
69922 --- a/include/linux/mm_types.h
69923 +++ b/include/linux/mm_types.h
69924 @@ -289,6 +289,8 @@ struct vm_area_struct {
69925 #ifdef CONFIG_NUMA
69926 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
69927 #endif
69928 +
69929 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
69930 };
69931
69932 struct core_thread {
69933 @@ -437,6 +439,24 @@ struct mm_struct {
69934 int first_nid;
69935 #endif
69936 struct uprobes_state uprobes_state;
69937 +
69938 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
69939 + unsigned long pax_flags;
69940 +#endif
69941 +
69942 +#ifdef CONFIG_PAX_DLRESOLVE
69943 + unsigned long call_dl_resolve;
69944 +#endif
69945 +
69946 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
69947 + unsigned long call_syscall;
69948 +#endif
69949 +
69950 +#ifdef CONFIG_PAX_ASLR
69951 + unsigned long delta_mmap; /* randomized offset */
69952 + unsigned long delta_stack; /* randomized offset */
69953 +#endif
69954 +
69955 };
69956
69957 /* first nid will either be a valid NID or one of these values */
69958 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
69959 index c5d5278..f0b68c8 100644
69960 --- a/include/linux/mmiotrace.h
69961 +++ b/include/linux/mmiotrace.h
69962 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
69963 /* Called from ioremap.c */
69964 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
69965 void __iomem *addr);
69966 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
69967 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
69968
69969 /* For anyone to insert markers. Remember trailing newline. */
69970 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
69971 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
69972 {
69973 }
69974
69975 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
69976 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
69977 {
69978 }
69979
69980 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
69981 index c74092e..b663967 100644
69982 --- a/include/linux/mmzone.h
69983 +++ b/include/linux/mmzone.h
69984 @@ -396,7 +396,7 @@ struct zone {
69985 unsigned long flags; /* zone flags, see below */
69986
69987 /* Zone statistics */
69988 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
69989 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
69990
69991 /*
69992 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
69993 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
69994 index 779cf7c..e6768240 100644
69995 --- a/include/linux/mod_devicetable.h
69996 +++ b/include/linux/mod_devicetable.h
69997 @@ -12,7 +12,7 @@
69998 typedef unsigned long kernel_ulong_t;
69999 #endif
70000
70001 -#define PCI_ANY_ID (~0)
70002 +#define PCI_ANY_ID ((__u16)~0)
70003
70004 struct pci_device_id {
70005 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70006 @@ -138,7 +138,7 @@ struct usb_device_id {
70007 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70008 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70009
70010 -#define HID_ANY_ID (~0)
70011 +#define HID_ANY_ID (~0U)
70012 #define HID_BUS_ANY 0xffff
70013 #define HID_GROUP_ANY 0x0000
70014
70015 @@ -464,7 +464,7 @@ struct dmi_system_id {
70016 const char *ident;
70017 struct dmi_strmatch matches[4];
70018 void *driver_data;
70019 -};
70020 +} __do_const;
70021 /*
70022 * struct dmi_device_id appears during expansion of
70023 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70024 diff --git a/include/linux/module.h b/include/linux/module.h
70025 index ead1b57..81a3b6c 100644
70026 --- a/include/linux/module.h
70027 +++ b/include/linux/module.h
70028 @@ -17,9 +17,11 @@
70029 #include <linux/moduleparam.h>
70030 #include <linux/tracepoint.h>
70031 #include <linux/export.h>
70032 +#include <linux/fs.h>
70033
70034 #include <linux/percpu.h>
70035 #include <asm/module.h>
70036 +#include <asm/pgtable.h>
70037
70038 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70039 #define MODULE_SIG_STRING "~Module signature appended~\n"
70040 @@ -54,12 +56,13 @@ struct module_attribute {
70041 int (*test)(struct module *);
70042 void (*free)(struct module *);
70043 };
70044 +typedef struct module_attribute __no_const module_attribute_no_const;
70045
70046 struct module_version_attribute {
70047 struct module_attribute mattr;
70048 const char *module_name;
70049 const char *version;
70050 -} __attribute__ ((__aligned__(sizeof(void *))));
70051 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70052
70053 extern ssize_t __modver_version_show(struct module_attribute *,
70054 struct module_kobject *, char *);
70055 @@ -232,7 +235,7 @@ struct module
70056
70057 /* Sysfs stuff. */
70058 struct module_kobject mkobj;
70059 - struct module_attribute *modinfo_attrs;
70060 + module_attribute_no_const *modinfo_attrs;
70061 const char *version;
70062 const char *srcversion;
70063 struct kobject *holders_dir;
70064 @@ -281,19 +284,16 @@ struct module
70065 int (*init)(void);
70066
70067 /* If this is non-NULL, vfree after init() returns */
70068 - void *module_init;
70069 + void *module_init_rx, *module_init_rw;
70070
70071 /* Here is the actual code + data, vfree'd on unload. */
70072 - void *module_core;
70073 + void *module_core_rx, *module_core_rw;
70074
70075 /* Here are the sizes of the init and core sections */
70076 - unsigned int init_size, core_size;
70077 + unsigned int init_size_rw, core_size_rw;
70078
70079 /* The size of the executable code in each section. */
70080 - unsigned int init_text_size, core_text_size;
70081 -
70082 - /* Size of RO sections of the module (text+rodata) */
70083 - unsigned int init_ro_size, core_ro_size;
70084 + unsigned int init_size_rx, core_size_rx;
70085
70086 /* Arch-specific module values */
70087 struct mod_arch_specific arch;
70088 @@ -349,6 +349,10 @@ struct module
70089 #ifdef CONFIG_EVENT_TRACING
70090 struct ftrace_event_call **trace_events;
70091 unsigned int num_trace_events;
70092 + struct file_operations trace_id;
70093 + struct file_operations trace_enable;
70094 + struct file_operations trace_format;
70095 + struct file_operations trace_filter;
70096 #endif
70097 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70098 unsigned int num_ftrace_callsites;
70099 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70100 bool is_module_percpu_address(unsigned long addr);
70101 bool is_module_text_address(unsigned long addr);
70102
70103 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70104 +{
70105 +
70106 +#ifdef CONFIG_PAX_KERNEXEC
70107 + if (ktla_ktva(addr) >= (unsigned long)start &&
70108 + ktla_ktva(addr) < (unsigned long)start + size)
70109 + return 1;
70110 +#endif
70111 +
70112 + return ((void *)addr >= start && (void *)addr < start + size);
70113 +}
70114 +
70115 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
70116 +{
70117 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70118 +}
70119 +
70120 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
70121 +{
70122 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70123 +}
70124 +
70125 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
70126 +{
70127 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70128 +}
70129 +
70130 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
70131 +{
70132 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70133 +}
70134 +
70135 static inline int within_module_core(unsigned long addr, const struct module *mod)
70136 {
70137 - return (unsigned long)mod->module_core <= addr &&
70138 - addr < (unsigned long)mod->module_core + mod->core_size;
70139 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70140 }
70141
70142 static inline int within_module_init(unsigned long addr, const struct module *mod)
70143 {
70144 - return (unsigned long)mod->module_init <= addr &&
70145 - addr < (unsigned long)mod->module_init + mod->init_size;
70146 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70147 }
70148
70149 /* Search for module by name: must hold module_mutex. */
70150 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70151 index 560ca53..ef621ef 100644
70152 --- a/include/linux/moduleloader.h
70153 +++ b/include/linux/moduleloader.h
70154 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70155 sections. Returns NULL on failure. */
70156 void *module_alloc(unsigned long size);
70157
70158 +#ifdef CONFIG_PAX_KERNEXEC
70159 +void *module_alloc_exec(unsigned long size);
70160 +#else
70161 +#define module_alloc_exec(x) module_alloc(x)
70162 +#endif
70163 +
70164 /* Free memory returned from module_alloc. */
70165 void module_free(struct module *mod, void *module_region);
70166
70167 +#ifdef CONFIG_PAX_KERNEXEC
70168 +void module_free_exec(struct module *mod, void *module_region);
70169 +#else
70170 +#define module_free_exec(x, y) module_free((x), (y))
70171 +#endif
70172 +
70173 /*
70174 * Apply the given relocation to the (simplified) ELF. Return -error
70175 * or 0.
70176 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70177 unsigned int relsec,
70178 struct module *me)
70179 {
70180 +#ifdef CONFIG_MODULES
70181 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70182 +#endif
70183 return -ENOEXEC;
70184 }
70185 #endif
70186 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70187 unsigned int relsec,
70188 struct module *me)
70189 {
70190 +#ifdef CONFIG_MODULES
70191 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70192 +#endif
70193 return -ENOEXEC;
70194 }
70195 #endif
70196 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70197 index 137b419..fe663ec 100644
70198 --- a/include/linux/moduleparam.h
70199 +++ b/include/linux/moduleparam.h
70200 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70201 * @len is usually just sizeof(string).
70202 */
70203 #define module_param_string(name, string, len, perm) \
70204 - static const struct kparam_string __param_string_##name \
70205 + static const struct kparam_string __param_string_##name __used \
70206 = { len, string }; \
70207 __module_param_call(MODULE_PARAM_PREFIX, name, \
70208 &param_ops_string, \
70209 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70210 */
70211 #define module_param_array_named(name, array, type, nump, perm) \
70212 param_check_##type(name, &(array)[0]); \
70213 - static const struct kparam_array __param_arr_##name \
70214 + static const struct kparam_array __param_arr_##name __used \
70215 = { .max = ARRAY_SIZE(array), .num = nump, \
70216 .ops = &param_ops_##type, \
70217 .elemsize = sizeof(array[0]), .elem = array }; \
70218 diff --git a/include/linux/namei.h b/include/linux/namei.h
70219 index 5a5ff57..5ae5070 100644
70220 --- a/include/linux/namei.h
70221 +++ b/include/linux/namei.h
70222 @@ -19,7 +19,7 @@ struct nameidata {
70223 unsigned seq;
70224 int last_type;
70225 unsigned depth;
70226 - char *saved_names[MAX_NESTED_LINKS + 1];
70227 + const char *saved_names[MAX_NESTED_LINKS + 1];
70228 };
70229
70230 /*
70231 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70232
70233 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70234
70235 -static inline void nd_set_link(struct nameidata *nd, char *path)
70236 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70237 {
70238 nd->saved_names[nd->depth] = path;
70239 }
70240
70241 -static inline char *nd_get_link(struct nameidata *nd)
70242 +static inline const char *nd_get_link(const struct nameidata *nd)
70243 {
70244 return nd->saved_names[nd->depth];
70245 }
70246 diff --git a/include/linux/net.h b/include/linux/net.h
70247 index aa16731..514b875 100644
70248 --- a/include/linux/net.h
70249 +++ b/include/linux/net.h
70250 @@ -183,7 +183,7 @@ struct net_proto_family {
70251 int (*create)(struct net *net, struct socket *sock,
70252 int protocol, int kern);
70253 struct module *owner;
70254 -};
70255 +} __do_const;
70256
70257 struct iovec;
70258 struct kvec;
70259 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70260 index 6151e90..2e0afb0 100644
70261 --- a/include/linux/netdevice.h
70262 +++ b/include/linux/netdevice.h
70263 @@ -1028,6 +1028,7 @@ struct net_device_ops {
70264 int (*ndo_change_carrier)(struct net_device *dev,
70265 bool new_carrier);
70266 };
70267 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70268
70269 /*
70270 * The DEVICE structure.
70271 @@ -1094,7 +1095,7 @@ struct net_device {
70272 int iflink;
70273
70274 struct net_device_stats stats;
70275 - atomic_long_t rx_dropped; /* dropped packets by core network
70276 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70277 * Do not use this in drivers.
70278 */
70279
70280 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70281 index ee14284..bc65d63 100644
70282 --- a/include/linux/netfilter.h
70283 +++ b/include/linux/netfilter.h
70284 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70285 #endif
70286 /* Use the module struct to lock set/get code in place */
70287 struct module *owner;
70288 -};
70289 +} __do_const;
70290
70291 /* Function to register/unregister hook points. */
70292 int nf_register_hook(struct nf_hook_ops *reg);
70293 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70294 index 7958e84..ed74d7a 100644
70295 --- a/include/linux/netfilter/ipset/ip_set.h
70296 +++ b/include/linux/netfilter/ipset/ip_set.h
70297 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70298 /* Return true if "b" set is the same as "a"
70299 * according to the create set parameters */
70300 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70301 -};
70302 +} __do_const;
70303
70304 /* The core set type structure */
70305 struct ip_set_type {
70306 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70307 index ecbb8e4..8a1c4e1 100644
70308 --- a/include/linux/netfilter/nfnetlink.h
70309 +++ b/include/linux/netfilter/nfnetlink.h
70310 @@ -16,7 +16,7 @@ struct nfnl_callback {
70311 const struct nlattr * const cda[]);
70312 const struct nla_policy *policy; /* netlink attribute policy */
70313 const u_int16_t attr_count; /* number of nlattr's */
70314 -};
70315 +} __do_const;
70316
70317 struct nfnetlink_subsystem {
70318 const char *name;
70319 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70320 new file mode 100644
70321 index 0000000..33f4af8
70322 --- /dev/null
70323 +++ b/include/linux/netfilter/xt_gradm.h
70324 @@ -0,0 +1,9 @@
70325 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70326 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70327 +
70328 +struct xt_gradm_mtinfo {
70329 + __u16 flags;
70330 + __u16 invflags;
70331 +};
70332 +
70333 +#endif
70334 diff --git a/include/linux/nls.h b/include/linux/nls.h
70335 index 5dc635f..35f5e11 100644
70336 --- a/include/linux/nls.h
70337 +++ b/include/linux/nls.h
70338 @@ -31,7 +31,7 @@ struct nls_table {
70339 const unsigned char *charset2upper;
70340 struct module *owner;
70341 struct nls_table *next;
70342 -};
70343 +} __do_const;
70344
70345 /* this value hold the maximum octet of charset */
70346 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70347 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70348 index d65746e..62e72c2 100644
70349 --- a/include/linux/notifier.h
70350 +++ b/include/linux/notifier.h
70351 @@ -51,7 +51,8 @@ struct notifier_block {
70352 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70353 struct notifier_block __rcu *next;
70354 int priority;
70355 -};
70356 +} __do_const;
70357 +typedef struct notifier_block __no_const notifier_block_no_const;
70358
70359 struct atomic_notifier_head {
70360 spinlock_t lock;
70361 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70362 index a4c5624..79d6d88 100644
70363 --- a/include/linux/oprofile.h
70364 +++ b/include/linux/oprofile.h
70365 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70366 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70367 char const * name, ulong * val);
70368
70369 -/** Create a file for read-only access to an atomic_t. */
70370 +/** Create a file for read-only access to an atomic_unchecked_t. */
70371 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70372 - char const * name, atomic_t * val);
70373 + char const * name, atomic_unchecked_t * val);
70374
70375 /** create a directory */
70376 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70377 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70378 index 45fc162..01a4068 100644
70379 --- a/include/linux/pci_hotplug.h
70380 +++ b/include/linux/pci_hotplug.h
70381 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70382 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70383 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70384 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70385 -};
70386 +} __do_const;
70387 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70388
70389 /**
70390 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70391 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70392 index 1d795df..727aa7b 100644
70393 --- a/include/linux/perf_event.h
70394 +++ b/include/linux/perf_event.h
70395 @@ -333,8 +333,8 @@ struct perf_event {
70396
70397 enum perf_event_active_state state;
70398 unsigned int attach_state;
70399 - local64_t count;
70400 - atomic64_t child_count;
70401 + local64_t count; /* PaX: fix it one day */
70402 + atomic64_unchecked_t child_count;
70403
70404 /*
70405 * These are the total time in nanoseconds that the event
70406 @@ -385,8 +385,8 @@ struct perf_event {
70407 * These accumulate total time (in nanoseconds) that children
70408 * events have been enabled and running, respectively.
70409 */
70410 - atomic64_t child_total_time_enabled;
70411 - atomic64_t child_total_time_running;
70412 + atomic64_unchecked_t child_total_time_enabled;
70413 + atomic64_unchecked_t child_total_time_running;
70414
70415 /*
70416 * Protect attach/detach and child_list:
70417 @@ -704,7 +704,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
70418 entry->ip[entry->nr++] = ip;
70419 }
70420
70421 -extern int sysctl_perf_event_paranoid;
70422 +extern int sysctl_perf_event_legitimately_concerned;
70423 extern int sysctl_perf_event_mlock;
70424 extern int sysctl_perf_event_sample_rate;
70425
70426 @@ -714,17 +714,17 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
70427
70428 static inline bool perf_paranoid_tracepoint_raw(void)
70429 {
70430 - return sysctl_perf_event_paranoid > -1;
70431 + return sysctl_perf_event_legitimately_concerned > -1;
70432 }
70433
70434 static inline bool perf_paranoid_cpu(void)
70435 {
70436 - return sysctl_perf_event_paranoid > 0;
70437 + return sysctl_perf_event_legitimately_concerned > 0;
70438 }
70439
70440 static inline bool perf_paranoid_kernel(void)
70441 {
70442 - return sysctl_perf_event_paranoid > 1;
70443 + return sysctl_perf_event_legitimately_concerned > 1;
70444 }
70445
70446 extern void perf_event_init(void);
70447 @@ -812,7 +812,7 @@ static inline void perf_restore_debug_store(void) { }
70448 */
70449 #define perf_cpu_notifier(fn) \
70450 do { \
70451 - static struct notifier_block fn##_nb __cpuinitdata = \
70452 + static struct notifier_block fn##_nb = \
70453 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
70454 unsigned long cpu = smp_processor_id(); \
70455 unsigned long flags; \
70456 @@ -831,7 +831,7 @@ do { \
70457 struct perf_pmu_events_attr {
70458 struct device_attribute attr;
70459 u64 id;
70460 -};
70461 +} __do_const;
70462
70463 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
70464 static struct perf_pmu_events_attr _var = { \
70465 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
70466 index ad1a427..6419649 100644
70467 --- a/include/linux/pipe_fs_i.h
70468 +++ b/include/linux/pipe_fs_i.h
70469 @@ -45,9 +45,9 @@ struct pipe_buffer {
70470 struct pipe_inode_info {
70471 wait_queue_head_t wait;
70472 unsigned int nrbufs, curbuf, buffers;
70473 - unsigned int readers;
70474 - unsigned int writers;
70475 - unsigned int waiting_writers;
70476 + atomic_t readers;
70477 + atomic_t writers;
70478 + atomic_t waiting_writers;
70479 unsigned int r_counter;
70480 unsigned int w_counter;
70481 struct page *tmp_page;
70482 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
70483 index 5f28cae..3d23723 100644
70484 --- a/include/linux/platform_data/usb-ehci-s5p.h
70485 +++ b/include/linux/platform_data/usb-ehci-s5p.h
70486 @@ -14,7 +14,7 @@
70487 struct s5p_ehci_platdata {
70488 int (*phy_init)(struct platform_device *pdev, int type);
70489 int (*phy_exit)(struct platform_device *pdev, int type);
70490 -};
70491 +} __no_const;
70492
70493 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
70494
70495 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
70496 index c256c59..8ea94c7 100644
70497 --- a/include/linux/platform_data/usb-exynos.h
70498 +++ b/include/linux/platform_data/usb-exynos.h
70499 @@ -14,7 +14,7 @@
70500 struct exynos4_ohci_platdata {
70501 int (*phy_init)(struct platform_device *pdev, int type);
70502 int (*phy_exit)(struct platform_device *pdev, int type);
70503 -};
70504 +} __no_const;
70505
70506 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
70507
70508 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
70509 index 7c1d252..c5c773e 100644
70510 --- a/include/linux/pm_domain.h
70511 +++ b/include/linux/pm_domain.h
70512 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
70513
70514 struct gpd_cpu_data {
70515 unsigned int saved_exit_latency;
70516 - struct cpuidle_state *idle_state;
70517 + cpuidle_state_no_const *idle_state;
70518 };
70519
70520 struct generic_pm_domain {
70521 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
70522 index 7d7e09e..8671ef8 100644
70523 --- a/include/linux/pm_runtime.h
70524 +++ b/include/linux/pm_runtime.h
70525 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
70526
70527 static inline void pm_runtime_mark_last_busy(struct device *dev)
70528 {
70529 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
70530 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
70531 }
70532
70533 #else /* !CONFIG_PM_RUNTIME */
70534 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
70535 index 195aafc..49a7bc2 100644
70536 --- a/include/linux/pnp.h
70537 +++ b/include/linux/pnp.h
70538 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
70539 struct pnp_fixup {
70540 char id[7];
70541 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
70542 -};
70543 +} __do_const;
70544
70545 /* config parameters */
70546 #define PNP_CONFIG_NORMAL 0x0001
70547 diff --git a/include/linux/poison.h b/include/linux/poison.h
70548 index 2110a81..13a11bb 100644
70549 --- a/include/linux/poison.h
70550 +++ b/include/linux/poison.h
70551 @@ -19,8 +19,8 @@
70552 * under normal circumstances, used to verify that nobody uses
70553 * non-initialized list entries.
70554 */
70555 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
70556 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
70557 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
70558 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
70559
70560 /********** include/linux/timer.h **********/
70561 /*
70562 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
70563 index c0f44c2..1572583 100644
70564 --- a/include/linux/power/smartreflex.h
70565 +++ b/include/linux/power/smartreflex.h
70566 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
70567 int (*notify)(struct omap_sr *sr, u32 status);
70568 u8 notify_flags;
70569 u8 class_type;
70570 -};
70571 +} __do_const;
70572
70573 /**
70574 * struct omap_sr_nvalue_table - Smartreflex n-target value info
70575 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
70576 index 4ea1d37..80f4b33 100644
70577 --- a/include/linux/ppp-comp.h
70578 +++ b/include/linux/ppp-comp.h
70579 @@ -84,7 +84,7 @@ struct compressor {
70580 struct module *owner;
70581 /* Extra skb space needed by the compressor algorithm */
70582 unsigned int comp_extra;
70583 -};
70584 +} __do_const;
70585
70586 /*
70587 * The return value from decompress routine is the length of the
70588 diff --git a/include/linux/printk.h b/include/linux/printk.h
70589 index 822171f..12b30e8 100644
70590 --- a/include/linux/printk.h
70591 +++ b/include/linux/printk.h
70592 @@ -98,6 +98,8 @@ int no_printk(const char *fmt, ...)
70593 extern asmlinkage __printf(1, 2)
70594 void early_printk(const char *fmt, ...);
70595
70596 +extern int kptr_restrict;
70597 +
70598 #ifdef CONFIG_PRINTK
70599 asmlinkage __printf(5, 0)
70600 int vprintk_emit(int facility, int level,
70601 @@ -132,7 +134,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
70602
70603 extern int printk_delay_msec;
70604 extern int dmesg_restrict;
70605 -extern int kptr_restrict;
70606
70607 extern void wake_up_klogd(void);
70608
70609 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
70610 index 94dfb2a..88b9d3b 100644
70611 --- a/include/linux/proc_fs.h
70612 +++ b/include/linux/proc_fs.h
70613 @@ -165,6 +165,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
70614 return proc_create_data(name, mode, parent, proc_fops, NULL);
70615 }
70616
70617 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
70618 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
70619 +{
70620 +#ifdef CONFIG_GRKERNSEC_PROC_USER
70621 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
70622 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70623 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
70624 +#else
70625 + return proc_create_data(name, mode, parent, proc_fops, NULL);
70626 +#endif
70627 +}
70628 +
70629 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
70630 umode_t mode, struct proc_dir_entry *base,
70631 read_proc_t *read_proc, void * data)
70632 @@ -266,7 +278,7 @@ struct proc_ns_operations {
70633 void (*put)(void *ns);
70634 int (*install)(struct nsproxy *nsproxy, void *ns);
70635 unsigned int (*inum)(void *ns);
70636 -};
70637 +} __do_const;
70638 extern const struct proc_ns_operations netns_operations;
70639 extern const struct proc_ns_operations utsns_operations;
70640 extern const struct proc_ns_operations ipcns_operations;
70641 diff --git a/include/linux/random.h b/include/linux/random.h
70642 index 347ce55..880f97c 100644
70643 --- a/include/linux/random.h
70644 +++ b/include/linux/random.h
70645 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
70646 u32 prandom_u32_state(struct rnd_state *);
70647 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
70648
70649 +static inline unsigned long pax_get_random_long(void)
70650 +{
70651 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
70652 +}
70653 +
70654 /*
70655 * Handle minimum values for seeds
70656 */
70657 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
70658 index 8089e35..3a0d59a 100644
70659 --- a/include/linux/rculist.h
70660 +++ b/include/linux/rculist.h
70661 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
70662 struct list_head *prev, struct list_head *next);
70663 #endif
70664
70665 +extern void __pax_list_add_rcu(struct list_head *new,
70666 + struct list_head *prev, struct list_head *next);
70667 +
70668 /**
70669 * list_add_rcu - add a new entry to rcu-protected list
70670 * @new: new entry to be added
70671 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
70672 __list_add_rcu(new, head, head->next);
70673 }
70674
70675 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
70676 +{
70677 + __pax_list_add_rcu(new, head, head->next);
70678 +}
70679 +
70680 /**
70681 * list_add_tail_rcu - add a new entry to rcu-protected list
70682 * @new: new entry to be added
70683 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
70684 __list_add_rcu(new, head->prev, head);
70685 }
70686
70687 +static inline void pax_list_add_tail_rcu(struct list_head *new,
70688 + struct list_head *head)
70689 +{
70690 + __pax_list_add_rcu(new, head->prev, head);
70691 +}
70692 +
70693 /**
70694 * list_del_rcu - deletes entry from list without re-initialization
70695 * @entry: the element to delete from the list.
70696 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
70697 entry->prev = LIST_POISON2;
70698 }
70699
70700 +extern void pax_list_del_rcu(struct list_head *entry);
70701 +
70702 /**
70703 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
70704 * @n: the element to delete from the hash list.
70705 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
70706 index 23b3630..e1bc12b 100644
70707 --- a/include/linux/reboot.h
70708 +++ b/include/linux/reboot.h
70709 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
70710 * Architecture-specific implementations of sys_reboot commands.
70711 */
70712
70713 -extern void machine_restart(char *cmd);
70714 -extern void machine_halt(void);
70715 -extern void machine_power_off(void);
70716 +extern void machine_restart(char *cmd) __noreturn;
70717 +extern void machine_halt(void) __noreturn;
70718 +extern void machine_power_off(void) __noreturn;
70719
70720 extern void machine_shutdown(void);
70721 struct pt_regs;
70722 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
70723 */
70724
70725 extern void kernel_restart_prepare(char *cmd);
70726 -extern void kernel_restart(char *cmd);
70727 -extern void kernel_halt(void);
70728 -extern void kernel_power_off(void);
70729 +extern void kernel_restart(char *cmd) __noreturn;
70730 +extern void kernel_halt(void) __noreturn;
70731 +extern void kernel_power_off(void) __noreturn;
70732
70733 extern int C_A_D; /* for sysctl */
70734 void ctrl_alt_del(void);
70735 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
70736 * Emergency restart, callable from an interrupt handler.
70737 */
70738
70739 -extern void emergency_restart(void);
70740 +extern void emergency_restart(void) __noreturn;
70741 #include <asm/emergency-restart.h>
70742
70743 #endif /* _LINUX_REBOOT_H */
70744 diff --git a/include/linux/regset.h b/include/linux/regset.h
70745 index 8e0c9fe..ac4d221 100644
70746 --- a/include/linux/regset.h
70747 +++ b/include/linux/regset.h
70748 @@ -161,7 +161,8 @@ struct user_regset {
70749 unsigned int align;
70750 unsigned int bias;
70751 unsigned int core_note_type;
70752 -};
70753 +} __do_const;
70754 +typedef struct user_regset __no_const user_regset_no_const;
70755
70756 /**
70757 * struct user_regset_view - available regsets
70758 diff --git a/include/linux/relay.h b/include/linux/relay.h
70759 index 91cacc3..b55ff74 100644
70760 --- a/include/linux/relay.h
70761 +++ b/include/linux/relay.h
70762 @@ -160,7 +160,7 @@ struct rchan_callbacks
70763 * The callback should return 0 if successful, negative if not.
70764 */
70765 int (*remove_buf_file)(struct dentry *dentry);
70766 -};
70767 +} __no_const;
70768
70769 /*
70770 * CONFIG_RELAY kernel API, kernel/relay.c
70771 diff --git a/include/linux/rio.h b/include/linux/rio.h
70772 index a3e7842..d973ca6 100644
70773 --- a/include/linux/rio.h
70774 +++ b/include/linux/rio.h
70775 @@ -339,7 +339,7 @@ struct rio_ops {
70776 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
70777 u64 rstart, u32 size, u32 flags);
70778 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
70779 -};
70780 +} __no_const;
70781
70782 #define RIO_RESOURCE_MEM 0x00000100
70783 #define RIO_RESOURCE_DOORBELL 0x00000200
70784 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
70785 index 6dacb93..6174423 100644
70786 --- a/include/linux/rmap.h
70787 +++ b/include/linux/rmap.h
70788 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
70789 void anon_vma_init(void); /* create anon_vma_cachep */
70790 int anon_vma_prepare(struct vm_area_struct *);
70791 void unlink_anon_vmas(struct vm_area_struct *);
70792 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
70793 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
70794 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
70795 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
70796
70797 static inline void anon_vma_merge(struct vm_area_struct *vma,
70798 struct vm_area_struct *next)
70799 diff --git a/include/linux/sched.h b/include/linux/sched.h
70800 index be4e742..7f9d593 100644
70801 --- a/include/linux/sched.h
70802 +++ b/include/linux/sched.h
70803 @@ -62,6 +62,7 @@ struct bio_list;
70804 struct fs_struct;
70805 struct perf_event_context;
70806 struct blk_plug;
70807 +struct linux_binprm;
70808
70809 /*
70810 * List of flags we want to share for kernel threads,
70811 @@ -315,7 +316,7 @@ extern char __sched_text_start[], __sched_text_end[];
70812 extern int in_sched_functions(unsigned long addr);
70813
70814 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
70815 -extern signed long schedule_timeout(signed long timeout);
70816 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
70817 extern signed long schedule_timeout_interruptible(signed long timeout);
70818 extern signed long schedule_timeout_killable(signed long timeout);
70819 extern signed long schedule_timeout_uninterruptible(signed long timeout);
70820 @@ -329,6 +330,18 @@ struct user_namespace;
70821 #include <linux/aio.h>
70822
70823 #ifdef CONFIG_MMU
70824 +
70825 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
70826 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
70827 +#else
70828 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
70829 +{
70830 + return 0;
70831 +}
70832 +#endif
70833 +
70834 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
70835 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
70836 extern void arch_pick_mmap_layout(struct mm_struct *mm);
70837 extern unsigned long
70838 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
70839 @@ -605,6 +618,17 @@ struct signal_struct {
70840 #ifdef CONFIG_TASKSTATS
70841 struct taskstats *stats;
70842 #endif
70843 +
70844 +#ifdef CONFIG_GRKERNSEC
70845 + u32 curr_ip;
70846 + u32 saved_ip;
70847 + u32 gr_saddr;
70848 + u32 gr_daddr;
70849 + u16 gr_sport;
70850 + u16 gr_dport;
70851 + u8 used_accept:1;
70852 +#endif
70853 +
70854 #ifdef CONFIG_AUDIT
70855 unsigned audit_tty;
70856 struct tty_audit_buf *tty_audit_buf;
70857 @@ -683,6 +707,11 @@ struct user_struct {
70858 struct key *session_keyring; /* UID's default session keyring */
70859 #endif
70860
70861 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
70862 + unsigned int banned;
70863 + unsigned long ban_expires;
70864 +#endif
70865 +
70866 /* Hash table maintenance information */
70867 struct hlist_node uidhash_node;
70868 kuid_t uid;
70869 @@ -1082,7 +1111,7 @@ struct sched_class {
70870 #ifdef CONFIG_FAIR_GROUP_SCHED
70871 void (*task_move_group) (struct task_struct *p, int on_rq);
70872 #endif
70873 -};
70874 +} __do_const;
70875
70876 struct load_weight {
70877 unsigned long weight, inv_weight;
70878 @@ -1323,8 +1352,8 @@ struct task_struct {
70879 struct list_head thread_group;
70880
70881 struct completion *vfork_done; /* for vfork() */
70882 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
70883 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70884 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
70885 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70886
70887 cputime_t utime, stime, utimescaled, stimescaled;
70888 cputime_t gtime;
70889 @@ -1349,11 +1378,6 @@ struct task_struct {
70890 struct task_cputime cputime_expires;
70891 struct list_head cpu_timers[3];
70892
70893 -/* process credentials */
70894 - const struct cred __rcu *real_cred; /* objective and real subjective task
70895 - * credentials (COW) */
70896 - const struct cred __rcu *cred; /* effective (overridable) subjective task
70897 - * credentials (COW) */
70898 char comm[TASK_COMM_LEN]; /* executable name excluding path
70899 - access with [gs]et_task_comm (which lock
70900 it with task_lock())
70901 @@ -1370,6 +1394,10 @@ struct task_struct {
70902 #endif
70903 /* CPU-specific state of this task */
70904 struct thread_struct thread;
70905 +/* thread_info moved to task_struct */
70906 +#ifdef CONFIG_X86
70907 + struct thread_info tinfo;
70908 +#endif
70909 /* filesystem information */
70910 struct fs_struct *fs;
70911 /* open file information */
70912 @@ -1443,6 +1471,10 @@ struct task_struct {
70913 gfp_t lockdep_reclaim_gfp;
70914 #endif
70915
70916 +/* process credentials */
70917 + const struct cred __rcu *real_cred; /* objective and real subjective task
70918 + * credentials (COW) */
70919 +
70920 /* journalling filesystem info */
70921 void *journal_info;
70922
70923 @@ -1481,6 +1513,10 @@ struct task_struct {
70924 /* cg_list protected by css_set_lock and tsk->alloc_lock */
70925 struct list_head cg_list;
70926 #endif
70927 +
70928 + const struct cred __rcu *cred; /* effective (overridable) subjective task
70929 + * credentials (COW) */
70930 +
70931 #ifdef CONFIG_FUTEX
70932 struct robust_list_head __user *robust_list;
70933 #ifdef CONFIG_COMPAT
70934 @@ -1577,8 +1613,74 @@ struct task_struct {
70935 #ifdef CONFIG_UPROBES
70936 struct uprobe_task *utask;
70937 #endif
70938 +
70939 +#ifdef CONFIG_GRKERNSEC
70940 + /* grsecurity */
70941 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70942 + u64 exec_id;
70943 +#endif
70944 +#ifdef CONFIG_GRKERNSEC_SETXID
70945 + const struct cred *delayed_cred;
70946 +#endif
70947 + struct dentry *gr_chroot_dentry;
70948 + struct acl_subject_label *acl;
70949 + struct acl_role_label *role;
70950 + struct file *exec_file;
70951 + unsigned long brute_expires;
70952 + u16 acl_role_id;
70953 + /* is this the task that authenticated to the special role */
70954 + u8 acl_sp_role;
70955 + u8 is_writable;
70956 + u8 brute;
70957 + u8 gr_is_chrooted;
70958 +#endif
70959 +
70960 };
70961
70962 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
70963 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
70964 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
70965 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
70966 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
70967 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
70968 +
70969 +#ifdef CONFIG_PAX_SOFTMODE
70970 +extern int pax_softmode;
70971 +#endif
70972 +
70973 +extern int pax_check_flags(unsigned long *);
70974 +
70975 +/* if tsk != current then task_lock must be held on it */
70976 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70977 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
70978 +{
70979 + if (likely(tsk->mm))
70980 + return tsk->mm->pax_flags;
70981 + else
70982 + return 0UL;
70983 +}
70984 +
70985 +/* if tsk != current then task_lock must be held on it */
70986 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
70987 +{
70988 + if (likely(tsk->mm)) {
70989 + tsk->mm->pax_flags = flags;
70990 + return 0;
70991 + }
70992 + return -EINVAL;
70993 +}
70994 +#endif
70995 +
70996 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
70997 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
70998 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
70999 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71000 +#endif
71001 +
71002 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71003 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71004 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71005 +
71006 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71007 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71008
71009 @@ -1637,7 +1739,7 @@ struct pid_namespace;
71010 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71011 struct pid_namespace *ns);
71012
71013 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71014 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71015 {
71016 return tsk->pid;
71017 }
71018 @@ -2073,7 +2175,9 @@ void yield(void);
71019 extern struct exec_domain default_exec_domain;
71020
71021 union thread_union {
71022 +#ifndef CONFIG_X86
71023 struct thread_info thread_info;
71024 +#endif
71025 unsigned long stack[THREAD_SIZE/sizeof(long)];
71026 };
71027
71028 @@ -2106,6 +2210,7 @@ extern struct pid_namespace init_pid_ns;
71029 */
71030
71031 extern struct task_struct *find_task_by_vpid(pid_t nr);
71032 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71033 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71034 struct pid_namespace *ns);
71035
71036 @@ -2272,7 +2377,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71037 extern void exit_itimers(struct signal_struct *);
71038 extern void flush_itimer_signals(void);
71039
71040 -extern void do_group_exit(int);
71041 +extern __noreturn void do_group_exit(int);
71042
71043 extern int allow_signal(int);
71044 extern int disallow_signal(int);
71045 @@ -2463,9 +2568,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71046
71047 #endif
71048
71049 -static inline int object_is_on_stack(void *obj)
71050 +static inline int object_starts_on_stack(void *obj)
71051 {
71052 - void *stack = task_stack_page(current);
71053 + const void *stack = task_stack_page(current);
71054
71055 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71056 }
71057 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
71058 index bf8086b..962b035 100644
71059 --- a/include/linux/sched/sysctl.h
71060 +++ b/include/linux/sched/sysctl.h
71061 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
71062 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71063
71064 extern int sysctl_max_map_count;
71065 +extern unsigned long sysctl_heap_stack_gap;
71066
71067 extern unsigned int sysctl_sched_latency;
71068 extern unsigned int sysctl_sched_min_granularity;
71069 diff --git a/include/linux/security.h b/include/linux/security.h
71070 index 032c366..2c1c2dc2 100644
71071 --- a/include/linux/security.h
71072 +++ b/include/linux/security.h
71073 @@ -26,6 +26,7 @@
71074 #include <linux/capability.h>
71075 #include <linux/slab.h>
71076 #include <linux/err.h>
71077 +#include <linux/grsecurity.h>
71078
71079 struct linux_binprm;
71080 struct cred;
71081 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71082 index 68a04a3..866e6a1 100644
71083 --- a/include/linux/seq_file.h
71084 +++ b/include/linux/seq_file.h
71085 @@ -26,6 +26,9 @@ struct seq_file {
71086 struct mutex lock;
71087 const struct seq_operations *op;
71088 int poll_event;
71089 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71090 + u64 exec_id;
71091 +#endif
71092 #ifdef CONFIG_USER_NS
71093 struct user_namespace *user_ns;
71094 #endif
71095 @@ -38,6 +41,7 @@ struct seq_operations {
71096 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71097 int (*show) (struct seq_file *m, void *v);
71098 };
71099 +typedef struct seq_operations __no_const seq_operations_no_const;
71100
71101 #define SEQ_SKIP 1
71102
71103 diff --git a/include/linux/shm.h b/include/linux/shm.h
71104 index 429c199..4d42e38 100644
71105 --- a/include/linux/shm.h
71106 +++ b/include/linux/shm.h
71107 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71108
71109 /* The task created the shm object. NULL if the task is dead. */
71110 struct task_struct *shm_creator;
71111 +#ifdef CONFIG_GRKERNSEC
71112 + time_t shm_createtime;
71113 + pid_t shm_lapid;
71114 +#endif
71115 };
71116
71117 /* shm_mode upper byte flags */
71118 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71119 index b8292d8..96db310 100644
71120 --- a/include/linux/skbuff.h
71121 +++ b/include/linux/skbuff.h
71122 @@ -599,7 +599,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71123 extern struct sk_buff *__alloc_skb(unsigned int size,
71124 gfp_t priority, int flags, int node);
71125 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71126 -static inline struct sk_buff *alloc_skb(unsigned int size,
71127 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71128 gfp_t priority)
71129 {
71130 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71131 @@ -709,7 +709,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71132 */
71133 static inline int skb_queue_empty(const struct sk_buff_head *list)
71134 {
71135 - return list->next == (struct sk_buff *)list;
71136 + return list->next == (const struct sk_buff *)list;
71137 }
71138
71139 /**
71140 @@ -722,7 +722,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71141 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71142 const struct sk_buff *skb)
71143 {
71144 - return skb->next == (struct sk_buff *)list;
71145 + return skb->next == (const struct sk_buff *)list;
71146 }
71147
71148 /**
71149 @@ -735,7 +735,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71150 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71151 const struct sk_buff *skb)
71152 {
71153 - return skb->prev == (struct sk_buff *)list;
71154 + return skb->prev == (const struct sk_buff *)list;
71155 }
71156
71157 /**
71158 @@ -1756,7 +1756,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71159 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71160 */
71161 #ifndef NET_SKB_PAD
71162 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71163 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71164 #endif
71165
71166 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71167 @@ -2351,7 +2351,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71168 int noblock, int *err);
71169 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71170 struct poll_table_struct *wait);
71171 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71172 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71173 int offset, struct iovec *to,
71174 int size);
71175 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71176 @@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
71177 nf_bridge_put(skb->nf_bridge);
71178 skb->nf_bridge = NULL;
71179 #endif
71180 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71181 + skb->nf_trace = 0;
71182 +#endif
71183 }
71184
71185 static inline void nf_reset_trace(struct sk_buff *skb)
71186 diff --git a/include/linux/slab.h b/include/linux/slab.h
71187 index 5d168d7..720bff3 100644
71188 --- a/include/linux/slab.h
71189 +++ b/include/linux/slab.h
71190 @@ -12,13 +12,20 @@
71191 #include <linux/gfp.h>
71192 #include <linux/types.h>
71193 #include <linux/workqueue.h>
71194 -
71195 +#include <linux/err.h>
71196
71197 /*
71198 * Flags to pass to kmem_cache_create().
71199 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71200 */
71201 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71202 +
71203 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71204 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71205 +#else
71206 +#define SLAB_USERCOPY 0x00000000UL
71207 +#endif
71208 +
71209 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71210 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71211 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71212 @@ -89,10 +96,13 @@
71213 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71214 * Both make kfree a no-op.
71215 */
71216 -#define ZERO_SIZE_PTR ((void *)16)
71217 +#define ZERO_SIZE_PTR \
71218 +({ \
71219 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71220 + (void *)(-MAX_ERRNO-1L); \
71221 +})
71222
71223 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71224 - (unsigned long)ZERO_SIZE_PTR)
71225 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71226
71227 /*
71228 * Common fields provided in kmem_cache by all slab allocators
71229 @@ -112,7 +122,7 @@ struct kmem_cache {
71230 unsigned int align; /* Alignment as calculated */
71231 unsigned long flags; /* Active flags on the slab */
71232 const char *name; /* Slab name for sysfs */
71233 - int refcount; /* Use counter */
71234 + atomic_t refcount; /* Use counter */
71235 void (*ctor)(void *); /* Called on object slot creation */
71236 struct list_head list; /* List of all slab caches on the system */
71237 };
71238 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71239 void kfree(const void *);
71240 void kzfree(const void *);
71241 size_t ksize(const void *);
71242 +const char *check_heap_object(const void *ptr, unsigned long n);
71243 +bool is_usercopy_object(const void *ptr);
71244
71245 /*
71246 * Allocator specific definitions. These are mainly used to establish optimized
71247 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71248 * for general use, and so are not documented here. For a full list of
71249 * potential flags, always refer to linux/gfp.h.
71250 */
71251 +
71252 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71253 {
71254 if (size != 0 && n > SIZE_MAX / size)
71255 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71256 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71257 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71258 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71259 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71260 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71261 #define kmalloc_track_caller(size, flags) \
71262 __kmalloc_track_caller(size, flags, _RET_IP_)
71263 #else
71264 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71265 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71266 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71267 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71268 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71269 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71270 #define kmalloc_node_track_caller(size, flags, node) \
71271 __kmalloc_node_track_caller(size, flags, node, \
71272 _RET_IP_)
71273 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71274 index 8bb6e0e..8eb0dbe 100644
71275 --- a/include/linux/slab_def.h
71276 +++ b/include/linux/slab_def.h
71277 @@ -52,7 +52,7 @@ struct kmem_cache {
71278 /* 4) cache creation/removal */
71279 const char *name;
71280 struct list_head list;
71281 - int refcount;
71282 + atomic_t refcount;
71283 int object_size;
71284 int align;
71285
71286 @@ -68,10 +68,10 @@ struct kmem_cache {
71287 unsigned long node_allocs;
71288 unsigned long node_frees;
71289 unsigned long node_overflow;
71290 - atomic_t allochit;
71291 - atomic_t allocmiss;
71292 - atomic_t freehit;
71293 - atomic_t freemiss;
71294 + atomic_unchecked_t allochit;
71295 + atomic_unchecked_t allocmiss;
71296 + atomic_unchecked_t freehit;
71297 + atomic_unchecked_t freemiss;
71298
71299 /*
71300 * If debugging is enabled, then the allocator can add additional
71301 @@ -111,11 +111,16 @@ struct cache_sizes {
71302 #ifdef CONFIG_ZONE_DMA
71303 struct kmem_cache *cs_dmacachep;
71304 #endif
71305 +
71306 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71307 + struct kmem_cache *cs_usercopycachep;
71308 +#endif
71309 +
71310 };
71311 extern struct cache_sizes malloc_sizes[];
71312
71313 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71314 -void *__kmalloc(size_t size, gfp_t flags);
71315 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71316
71317 #ifdef CONFIG_TRACING
71318 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71319 @@ -152,6 +157,13 @@ found:
71320 cachep = malloc_sizes[i].cs_dmacachep;
71321 else
71322 #endif
71323 +
71324 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71325 + if (flags & GFP_USERCOPY)
71326 + cachep = malloc_sizes[i].cs_usercopycachep;
71327 + else
71328 +#endif
71329 +
71330 cachep = malloc_sizes[i].cs_cachep;
71331
71332 ret = kmem_cache_alloc_trace(cachep, flags, size);
71333 @@ -162,7 +174,7 @@ found:
71334 }
71335
71336 #ifdef CONFIG_NUMA
71337 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71338 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71339 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71340
71341 #ifdef CONFIG_TRACING
71342 @@ -205,6 +217,13 @@ found:
71343 cachep = malloc_sizes[i].cs_dmacachep;
71344 else
71345 #endif
71346 +
71347 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71348 + if (flags & GFP_USERCOPY)
71349 + cachep = malloc_sizes[i].cs_usercopycachep;
71350 + else
71351 +#endif
71352 +
71353 cachep = malloc_sizes[i].cs_cachep;
71354
71355 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71356 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71357 index f28e14a..7831211 100644
71358 --- a/include/linux/slob_def.h
71359 +++ b/include/linux/slob_def.h
71360 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71361 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71362 }
71363
71364 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71365 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71366
71367 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71368 {
71369 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71370 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71371 }
71372
71373 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71374 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71375 {
71376 return kmalloc(size, flags);
71377 }
71378 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71379 index 9db4825..ed42fb5 100644
71380 --- a/include/linux/slub_def.h
71381 +++ b/include/linux/slub_def.h
71382 @@ -91,7 +91,7 @@ struct kmem_cache {
71383 struct kmem_cache_order_objects max;
71384 struct kmem_cache_order_objects min;
71385 gfp_t allocflags; /* gfp flags to use on each alloc */
71386 - int refcount; /* Refcount for slab cache destroy */
71387 + atomic_t refcount; /* Refcount for slab cache destroy */
71388 void (*ctor)(void *);
71389 int inuse; /* Offset to metadata */
71390 int align; /* Alignment */
71391 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71392 * Sorry that the following has to be that ugly but some versions of GCC
71393 * have trouble with constant propagation and loops.
71394 */
71395 -static __always_inline int kmalloc_index(size_t size)
71396 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71397 {
71398 if (!size)
71399 return 0;
71400 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71401 }
71402
71403 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71404 -void *__kmalloc(size_t size, gfp_t flags);
71405 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71406
71407 static __always_inline void *
71408 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71409 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71410 }
71411 #endif
71412
71413 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71414 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71415 {
71416 unsigned int order = get_order(size);
71417 return kmalloc_order_trace(size, flags, order);
71418 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71419 }
71420
71421 #ifdef CONFIG_NUMA
71422 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71423 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71424 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71425
71426 #ifdef CONFIG_TRACING
71427 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71428 index e8d702e..0a56eb4 100644
71429 --- a/include/linux/sock_diag.h
71430 +++ b/include/linux/sock_diag.h
71431 @@ -10,7 +10,7 @@ struct sock;
71432 struct sock_diag_handler {
71433 __u8 family;
71434 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71435 -};
71436 +} __do_const;
71437
71438 int sock_diag_register(const struct sock_diag_handler *h);
71439 void sock_diag_unregister(const struct sock_diag_handler *h);
71440 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71441 index 680f9a3..f13aeb0 100644
71442 --- a/include/linux/sonet.h
71443 +++ b/include/linux/sonet.h
71444 @@ -7,7 +7,7 @@
71445 #include <uapi/linux/sonet.h>
71446
71447 struct k_sonet_stats {
71448 -#define __HANDLE_ITEM(i) atomic_t i
71449 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71450 __SONET_ITEMS
71451 #undef __HANDLE_ITEM
71452 };
71453 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
71454 index 07d8e53..dc934c9 100644
71455 --- a/include/linux/sunrpc/addr.h
71456 +++ b/include/linux/sunrpc/addr.h
71457 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
71458 {
71459 switch (sap->sa_family) {
71460 case AF_INET:
71461 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
71462 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
71463 case AF_INET6:
71464 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
71465 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
71466 }
71467 return 0;
71468 }
71469 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
71470 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
71471 const struct sockaddr *src)
71472 {
71473 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
71474 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
71475 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
71476
71477 dsin->sin_family = ssin->sin_family;
71478 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
71479 if (sa->sa_family != AF_INET6)
71480 return 0;
71481
71482 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
71483 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
71484 }
71485
71486 #endif /* _LINUX_SUNRPC_ADDR_H */
71487 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71488 index 2cf4ffa..470d140 100644
71489 --- a/include/linux/sunrpc/clnt.h
71490 +++ b/include/linux/sunrpc/clnt.h
71491 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71492 unsigned int p_timer; /* Which RTT timer to use */
71493 u32 p_statidx; /* Which procedure to account */
71494 const char * p_name; /* name of procedure */
71495 -};
71496 +} __do_const;
71497
71498 #ifdef __KERNEL__
71499
71500 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
71501 index 1f0216b..6a4fa50 100644
71502 --- a/include/linux/sunrpc/svc.h
71503 +++ b/include/linux/sunrpc/svc.h
71504 @@ -411,7 +411,7 @@ struct svc_procedure {
71505 unsigned int pc_count; /* call count */
71506 unsigned int pc_cachetype; /* cache info (NFS) */
71507 unsigned int pc_xdrressize; /* maximum size of XDR reply */
71508 -};
71509 +} __do_const;
71510
71511 /*
71512 * Function prototypes.
71513 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
71514 index 0b8e3e6..33e0a01 100644
71515 --- a/include/linux/sunrpc/svc_rdma.h
71516 +++ b/include/linux/sunrpc/svc_rdma.h
71517 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
71518 extern unsigned int svcrdma_max_requests;
71519 extern unsigned int svcrdma_max_req_size;
71520
71521 -extern atomic_t rdma_stat_recv;
71522 -extern atomic_t rdma_stat_read;
71523 -extern atomic_t rdma_stat_write;
71524 -extern atomic_t rdma_stat_sq_starve;
71525 -extern atomic_t rdma_stat_rq_starve;
71526 -extern atomic_t rdma_stat_rq_poll;
71527 -extern atomic_t rdma_stat_rq_prod;
71528 -extern atomic_t rdma_stat_sq_poll;
71529 -extern atomic_t rdma_stat_sq_prod;
71530 +extern atomic_unchecked_t rdma_stat_recv;
71531 +extern atomic_unchecked_t rdma_stat_read;
71532 +extern atomic_unchecked_t rdma_stat_write;
71533 +extern atomic_unchecked_t rdma_stat_sq_starve;
71534 +extern atomic_unchecked_t rdma_stat_rq_starve;
71535 +extern atomic_unchecked_t rdma_stat_rq_poll;
71536 +extern atomic_unchecked_t rdma_stat_rq_prod;
71537 +extern atomic_unchecked_t rdma_stat_sq_poll;
71538 +extern atomic_unchecked_t rdma_stat_sq_prod;
71539
71540 #define RPCRDMA_VERSION 1
71541
71542 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
71543 index ff374ab..7fd2ecb 100644
71544 --- a/include/linux/sunrpc/svcauth.h
71545 +++ b/include/linux/sunrpc/svcauth.h
71546 @@ -109,7 +109,7 @@ struct auth_ops {
71547 int (*release)(struct svc_rqst *rq);
71548 void (*domain_release)(struct auth_domain *);
71549 int (*set_client)(struct svc_rqst *rq);
71550 -};
71551 +} __do_const;
71552
71553 #define SVC_GARBAGE 1
71554 #define SVC_SYSERR 2
71555 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
71556 index a5ffd32..0935dea 100644
71557 --- a/include/linux/swiotlb.h
71558 +++ b/include/linux/swiotlb.h
71559 @@ -60,7 +60,8 @@ extern void
71560
71561 extern void
71562 swiotlb_free_coherent(struct device *hwdev, size_t size,
71563 - void *vaddr, dma_addr_t dma_handle);
71564 + void *vaddr, dma_addr_t dma_handle,
71565 + struct dma_attrs *attrs);
71566
71567 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
71568 unsigned long offset, size_t size,
71569 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
71570 index 313a8e0..6b273a9 100644
71571 --- a/include/linux/syscalls.h
71572 +++ b/include/linux/syscalls.h
71573 @@ -418,11 +418,11 @@ asmlinkage long sys_sync(void);
71574 asmlinkage long sys_fsync(unsigned int fd);
71575 asmlinkage long sys_fdatasync(unsigned int fd);
71576 asmlinkage long sys_bdflush(int func, long data);
71577 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
71578 - char __user *type, unsigned long flags,
71579 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
71580 + const char __user *type, unsigned long flags,
71581 void __user *data);
71582 -asmlinkage long sys_umount(char __user *name, int flags);
71583 -asmlinkage long sys_oldumount(char __user *name);
71584 +asmlinkage long sys_umount(const char __user *name, int flags);
71585 +asmlinkage long sys_oldumount(const char __user *name);
71586 asmlinkage long sys_truncate(const char __user *path, long length);
71587 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
71588 asmlinkage long sys_stat(const char __user *filename,
71589 @@ -634,7 +634,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
71590 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
71591 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
71592 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
71593 - struct sockaddr __user *, int);
71594 + struct sockaddr __user *, int) __intentional_overflow(0);
71595 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
71596 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
71597 unsigned int vlen, unsigned flags);
71598 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
71599 index 27b3b0b..e093dd9 100644
71600 --- a/include/linux/syscore_ops.h
71601 +++ b/include/linux/syscore_ops.h
71602 @@ -16,7 +16,7 @@ struct syscore_ops {
71603 int (*suspend)(void);
71604 void (*resume)(void);
71605 void (*shutdown)(void);
71606 -};
71607 +} __do_const;
71608
71609 extern void register_syscore_ops(struct syscore_ops *ops);
71610 extern void unregister_syscore_ops(struct syscore_ops *ops);
71611 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
71612 index 14a8ff2..af52bad 100644
71613 --- a/include/linux/sysctl.h
71614 +++ b/include/linux/sysctl.h
71615 @@ -34,13 +34,13 @@ struct ctl_table_root;
71616 struct ctl_table_header;
71617 struct ctl_dir;
71618
71619 -typedef struct ctl_table ctl_table;
71620 -
71621 typedef int proc_handler (struct ctl_table *ctl, int write,
71622 void __user *buffer, size_t *lenp, loff_t *ppos);
71623
71624 extern int proc_dostring(struct ctl_table *, int,
71625 void __user *, size_t *, loff_t *);
71626 +extern int proc_dostring_modpriv(struct ctl_table *, int,
71627 + void __user *, size_t *, loff_t *);
71628 extern int proc_dointvec(struct ctl_table *, int,
71629 void __user *, size_t *, loff_t *);
71630 extern int proc_dointvec_minmax(struct ctl_table *, int,
71631 @@ -115,7 +115,9 @@ struct ctl_table
71632 struct ctl_table_poll *poll;
71633 void *extra1;
71634 void *extra2;
71635 -};
71636 +} __do_const;
71637 +typedef struct ctl_table __no_const ctl_table_no_const;
71638 +typedef struct ctl_table ctl_table;
71639
71640 struct ctl_node {
71641 struct rb_node node;
71642 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
71643 index e2cee22..3ddb921 100644
71644 --- a/include/linux/sysfs.h
71645 +++ b/include/linux/sysfs.h
71646 @@ -31,7 +31,8 @@ struct attribute {
71647 struct lock_class_key *key;
71648 struct lock_class_key skey;
71649 #endif
71650 -};
71651 +} __do_const;
71652 +typedef struct attribute __no_const attribute_no_const;
71653
71654 /**
71655 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
71656 @@ -59,8 +60,8 @@ struct attribute_group {
71657 umode_t (*is_visible)(struct kobject *,
71658 struct attribute *, int);
71659 struct attribute **attrs;
71660 -};
71661 -
71662 +} __do_const;
71663 +typedef struct attribute_group __no_const attribute_group_no_const;
71664
71665
71666 /**
71667 @@ -107,7 +108,8 @@ struct bin_attribute {
71668 char *, loff_t, size_t);
71669 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
71670 struct vm_area_struct *vma);
71671 -};
71672 +} __do_const;
71673 +typedef struct bin_attribute __no_const bin_attribute_no_const;
71674
71675 /**
71676 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
71677 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
71678 index 7faf933..9b85a0c 100644
71679 --- a/include/linux/sysrq.h
71680 +++ b/include/linux/sysrq.h
71681 @@ -16,6 +16,7 @@
71682
71683 #include <linux/errno.h>
71684 #include <linux/types.h>
71685 +#include <linux/compiler.h>
71686
71687 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
71688 #define SYSRQ_DEFAULT_ENABLE 1
71689 @@ -36,7 +37,7 @@ struct sysrq_key_op {
71690 char *help_msg;
71691 char *action_msg;
71692 int enable_mask;
71693 -};
71694 +} __do_const;
71695
71696 #ifdef CONFIG_MAGIC_SYSRQ
71697
71698 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
71699 index e7e0473..7989295 100644
71700 --- a/include/linux/thread_info.h
71701 +++ b/include/linux/thread_info.h
71702 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
71703 #error "no set_restore_sigmask() provided and default one won't work"
71704 #endif
71705
71706 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
71707 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
71708 +{
71709 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
71710 + if (!__builtin_constant_p(n))
71711 +#endif
71712 + __check_object_size(ptr, n, to_user);
71713 +}
71714 +
71715 #endif /* __KERNEL__ */
71716
71717 #endif /* _LINUX_THREAD_INFO_H */
71718 diff --git a/include/linux/tty.h b/include/linux/tty.h
71719 index c75d886..04cb148 100644
71720 --- a/include/linux/tty.h
71721 +++ b/include/linux/tty.h
71722 @@ -194,7 +194,7 @@ struct tty_port {
71723 const struct tty_port_operations *ops; /* Port operations */
71724 spinlock_t lock; /* Lock protecting tty field */
71725 int blocked_open; /* Waiting to open */
71726 - int count; /* Usage count */
71727 + atomic_t count; /* Usage count */
71728 wait_queue_head_t open_wait; /* Open waiters */
71729 wait_queue_head_t close_wait; /* Close waiters */
71730 wait_queue_head_t delta_msr_wait; /* Modem status change */
71731 @@ -515,7 +515,7 @@ extern int tty_port_open(struct tty_port *port,
71732 struct tty_struct *tty, struct file *filp);
71733 static inline int tty_port_users(struct tty_port *port)
71734 {
71735 - return port->count + port->blocked_open;
71736 + return atomic_read(&port->count) + port->blocked_open;
71737 }
71738
71739 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
71740 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
71741 index 756a609..b302dd6 100644
71742 --- a/include/linux/tty_driver.h
71743 +++ b/include/linux/tty_driver.h
71744 @@ -285,7 +285,7 @@ struct tty_operations {
71745 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
71746 #endif
71747 const struct file_operations *proc_fops;
71748 -};
71749 +} __do_const;
71750
71751 struct tty_driver {
71752 int magic; /* magic number for this structure */
71753 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
71754 index 455a0d7..bf97ff5 100644
71755 --- a/include/linux/tty_ldisc.h
71756 +++ b/include/linux/tty_ldisc.h
71757 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
71758
71759 struct module *owner;
71760
71761 - int refcount;
71762 + atomic_t refcount;
71763 };
71764
71765 struct tty_ldisc {
71766 diff --git a/include/linux/types.h b/include/linux/types.h
71767 index 4d118ba..c3ee9bf 100644
71768 --- a/include/linux/types.h
71769 +++ b/include/linux/types.h
71770 @@ -176,10 +176,26 @@ typedef struct {
71771 int counter;
71772 } atomic_t;
71773
71774 +#ifdef CONFIG_PAX_REFCOUNT
71775 +typedef struct {
71776 + int counter;
71777 +} atomic_unchecked_t;
71778 +#else
71779 +typedef atomic_t atomic_unchecked_t;
71780 +#endif
71781 +
71782 #ifdef CONFIG_64BIT
71783 typedef struct {
71784 long counter;
71785 } atomic64_t;
71786 +
71787 +#ifdef CONFIG_PAX_REFCOUNT
71788 +typedef struct {
71789 + long counter;
71790 +} atomic64_unchecked_t;
71791 +#else
71792 +typedef atomic64_t atomic64_unchecked_t;
71793 +#endif
71794 #endif
71795
71796 struct list_head {
71797 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
71798 index 5ca0951..ab496a5 100644
71799 --- a/include/linux/uaccess.h
71800 +++ b/include/linux/uaccess.h
71801 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
71802 long ret; \
71803 mm_segment_t old_fs = get_fs(); \
71804 \
71805 - set_fs(KERNEL_DS); \
71806 pagefault_disable(); \
71807 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
71808 - pagefault_enable(); \
71809 + set_fs(KERNEL_DS); \
71810 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
71811 set_fs(old_fs); \
71812 + pagefault_enable(); \
71813 ret; \
71814 })
71815
71816 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
71817 index 8e522cbc..aa8572d 100644
71818 --- a/include/linux/uidgid.h
71819 +++ b/include/linux/uidgid.h
71820 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
71821
71822 #endif /* CONFIG_USER_NS */
71823
71824 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
71825 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
71826 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
71827 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
71828 +
71829 #endif /* _LINUX_UIDGID_H */
71830 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
71831 index 99c1b4d..562e6f3 100644
71832 --- a/include/linux/unaligned/access_ok.h
71833 +++ b/include/linux/unaligned/access_ok.h
71834 @@ -4,34 +4,34 @@
71835 #include <linux/kernel.h>
71836 #include <asm/byteorder.h>
71837
71838 -static inline u16 get_unaligned_le16(const void *p)
71839 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
71840 {
71841 - return le16_to_cpup((__le16 *)p);
71842 + return le16_to_cpup((const __le16 *)p);
71843 }
71844
71845 -static inline u32 get_unaligned_le32(const void *p)
71846 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
71847 {
71848 - return le32_to_cpup((__le32 *)p);
71849 + return le32_to_cpup((const __le32 *)p);
71850 }
71851
71852 -static inline u64 get_unaligned_le64(const void *p)
71853 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
71854 {
71855 - return le64_to_cpup((__le64 *)p);
71856 + return le64_to_cpup((const __le64 *)p);
71857 }
71858
71859 -static inline u16 get_unaligned_be16(const void *p)
71860 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
71861 {
71862 - return be16_to_cpup((__be16 *)p);
71863 + return be16_to_cpup((const __be16 *)p);
71864 }
71865
71866 -static inline u32 get_unaligned_be32(const void *p)
71867 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
71868 {
71869 - return be32_to_cpup((__be32 *)p);
71870 + return be32_to_cpup((const __be32 *)p);
71871 }
71872
71873 -static inline u64 get_unaligned_be64(const void *p)
71874 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
71875 {
71876 - return be64_to_cpup((__be64 *)p);
71877 + return be64_to_cpup((const __be64 *)p);
71878 }
71879
71880 static inline void put_unaligned_le16(u16 val, void *p)
71881 diff --git a/include/linux/usb.h b/include/linux/usb.h
71882 index 4d22d0f..8d0e8f8 100644
71883 --- a/include/linux/usb.h
71884 +++ b/include/linux/usb.h
71885 @@ -554,7 +554,7 @@ struct usb_device {
71886 int maxchild;
71887
71888 u32 quirks;
71889 - atomic_t urbnum;
71890 + atomic_unchecked_t urbnum;
71891
71892 unsigned long active_duration;
71893
71894 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
71895
71896 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
71897 __u8 request, __u8 requesttype, __u16 value, __u16 index,
71898 - void *data, __u16 size, int timeout);
71899 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
71900 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
71901 void *data, int len, int *actual_length, int timeout);
71902 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
71903 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
71904 index c5d36c6..108f4f9 100644
71905 --- a/include/linux/usb/renesas_usbhs.h
71906 +++ b/include/linux/usb/renesas_usbhs.h
71907 @@ -39,7 +39,7 @@ enum {
71908 */
71909 struct renesas_usbhs_driver_callback {
71910 int (*notify_hotplug)(struct platform_device *pdev);
71911 -};
71912 +} __no_const;
71913
71914 /*
71915 * callback functions for platform
71916 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
71917 index 6f8fbcf..8259001 100644
71918 --- a/include/linux/vermagic.h
71919 +++ b/include/linux/vermagic.h
71920 @@ -25,9 +25,35 @@
71921 #define MODULE_ARCH_VERMAGIC ""
71922 #endif
71923
71924 +#ifdef CONFIG_PAX_REFCOUNT
71925 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
71926 +#else
71927 +#define MODULE_PAX_REFCOUNT ""
71928 +#endif
71929 +
71930 +#ifdef CONSTIFY_PLUGIN
71931 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
71932 +#else
71933 +#define MODULE_CONSTIFY_PLUGIN ""
71934 +#endif
71935 +
71936 +#ifdef STACKLEAK_PLUGIN
71937 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
71938 +#else
71939 +#define MODULE_STACKLEAK_PLUGIN ""
71940 +#endif
71941 +
71942 +#ifdef CONFIG_GRKERNSEC
71943 +#define MODULE_GRSEC "GRSEC "
71944 +#else
71945 +#define MODULE_GRSEC ""
71946 +#endif
71947 +
71948 #define VERMAGIC_STRING \
71949 UTS_RELEASE " " \
71950 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
71951 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
71952 - MODULE_ARCH_VERMAGIC
71953 + MODULE_ARCH_VERMAGIC \
71954 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
71955 + MODULE_GRSEC
71956
71957 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
71958 index 6071e91..ca6a489 100644
71959 --- a/include/linux/vmalloc.h
71960 +++ b/include/linux/vmalloc.h
71961 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
71962 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
71963 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
71964 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
71965 +
71966 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
71967 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
71968 +#endif
71969 +
71970 /* bits [20..32] reserved for arch specific ioremap internals */
71971
71972 /*
71973 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
71974 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
71975 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
71976 unsigned long start, unsigned long end, gfp_t gfp_mask,
71977 - pgprot_t prot, int node, const void *caller);
71978 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
71979 extern void vfree(const void *addr);
71980
71981 extern void *vmap(struct page **pages, unsigned int count,
71982 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
71983 extern void free_vm_area(struct vm_struct *area);
71984
71985 /* for /dev/kmem */
71986 -extern long vread(char *buf, char *addr, unsigned long count);
71987 -extern long vwrite(char *buf, char *addr, unsigned long count);
71988 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
71989 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
71990
71991 /*
71992 * Internals. Dont't use..
71993 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
71994 index 5fd71a7..e5ef9a9 100644
71995 --- a/include/linux/vmstat.h
71996 +++ b/include/linux/vmstat.h
71997 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
71998 /*
71999 * Zone based page accounting with per cpu differentials.
72000 */
72001 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72002 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72003
72004 static inline void zone_page_state_add(long x, struct zone *zone,
72005 enum zone_stat_item item)
72006 {
72007 - atomic_long_add(x, &zone->vm_stat[item]);
72008 - atomic_long_add(x, &vm_stat[item]);
72009 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72010 + atomic_long_add_unchecked(x, &vm_stat[item]);
72011 }
72012
72013 static inline unsigned long global_page_state(enum zone_stat_item item)
72014 {
72015 - long x = atomic_long_read(&vm_stat[item]);
72016 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72017 #ifdef CONFIG_SMP
72018 if (x < 0)
72019 x = 0;
72020 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72021 static inline unsigned long zone_page_state(struct zone *zone,
72022 enum zone_stat_item item)
72023 {
72024 - long x = atomic_long_read(&zone->vm_stat[item]);
72025 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72026 #ifdef CONFIG_SMP
72027 if (x < 0)
72028 x = 0;
72029 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72030 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72031 enum zone_stat_item item)
72032 {
72033 - long x = atomic_long_read(&zone->vm_stat[item]);
72034 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72035
72036 #ifdef CONFIG_SMP
72037 int cpu;
72038 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72039
72040 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72041 {
72042 - atomic_long_inc(&zone->vm_stat[item]);
72043 - atomic_long_inc(&vm_stat[item]);
72044 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72045 + atomic_long_inc_unchecked(&vm_stat[item]);
72046 }
72047
72048 static inline void __inc_zone_page_state(struct page *page,
72049 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72050
72051 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72052 {
72053 - atomic_long_dec(&zone->vm_stat[item]);
72054 - atomic_long_dec(&vm_stat[item]);
72055 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72056 + atomic_long_dec_unchecked(&vm_stat[item]);
72057 }
72058
72059 static inline void __dec_zone_page_state(struct page *page,
72060 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72061 index fdbafc6..49dfe4f 100644
72062 --- a/include/linux/xattr.h
72063 +++ b/include/linux/xattr.h
72064 @@ -28,7 +28,7 @@ struct xattr_handler {
72065 size_t size, int handler_flags);
72066 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72067 size_t size, int flags, int handler_flags);
72068 -};
72069 +} __do_const;
72070
72071 struct xattr {
72072 char *name;
72073 @@ -37,6 +37,9 @@ struct xattr {
72074 };
72075
72076 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
72077 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
72078 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
72079 +#endif
72080 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
72081 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
72082 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
72083 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72084 index 9c5a6b4..09c9438 100644
72085 --- a/include/linux/zlib.h
72086 +++ b/include/linux/zlib.h
72087 @@ -31,6 +31,7 @@
72088 #define _ZLIB_H
72089
72090 #include <linux/zconf.h>
72091 +#include <linux/compiler.h>
72092
72093 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72094 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72095 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72096
72097 /* basic functions */
72098
72099 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72100 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72101 /*
72102 Returns the number of bytes that needs to be allocated for a per-
72103 stream workspace with the specified parameters. A pointer to this
72104 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72105 index 95d1c91..6798cca 100644
72106 --- a/include/media/v4l2-dev.h
72107 +++ b/include/media/v4l2-dev.h
72108 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72109 int (*mmap) (struct file *, struct vm_area_struct *);
72110 int (*open) (struct file *);
72111 int (*release) (struct file *);
72112 -};
72113 +} __do_const;
72114
72115 /*
72116 * Newer version of video_device, handled by videodev2.c
72117 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72118 index 4118ad1..cb7e25f 100644
72119 --- a/include/media/v4l2-ioctl.h
72120 +++ b/include/media/v4l2-ioctl.h
72121 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72122 bool valid_prio, int cmd, void *arg);
72123 };
72124
72125 -
72126 /* v4l debugging and diagnostics */
72127
72128 /* Debug bitmask flags to be used on V4L2 */
72129 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72130 index adcbb20..62c2559 100644
72131 --- a/include/net/9p/transport.h
72132 +++ b/include/net/9p/transport.h
72133 @@ -57,7 +57,7 @@ struct p9_trans_module {
72134 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72135 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72136 char *, char *, int , int, int, int);
72137 -};
72138 +} __do_const;
72139
72140 void v9fs_register_trans(struct p9_trans_module *m);
72141 void v9fs_unregister_trans(struct p9_trans_module *m);
72142 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72143 index cdd3302..76f8ede 100644
72144 --- a/include/net/bluetooth/l2cap.h
72145 +++ b/include/net/bluetooth/l2cap.h
72146 @@ -551,7 +551,7 @@ struct l2cap_ops {
72147 void (*defer) (struct l2cap_chan *chan);
72148 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72149 unsigned long len, int nb);
72150 -};
72151 +} __do_const;
72152
72153 struct l2cap_conn {
72154 struct hci_conn *hcon;
72155 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72156 index 9e5425b..8136ffc 100644
72157 --- a/include/net/caif/cfctrl.h
72158 +++ b/include/net/caif/cfctrl.h
72159 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72160 void (*radioset_rsp)(void);
72161 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72162 struct cflayer *client_layer);
72163 -};
72164 +} __no_const;
72165
72166 /* Link Setup Parameters for CAIF-Links. */
72167 struct cfctrl_link_param {
72168 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72169 struct cfctrl {
72170 struct cfsrvl serv;
72171 struct cfctrl_rsp res;
72172 - atomic_t req_seq_no;
72173 - atomic_t rsp_seq_no;
72174 + atomic_unchecked_t req_seq_no;
72175 + atomic_unchecked_t rsp_seq_no;
72176 struct list_head list;
72177 /* Protects from simultaneous access to first_req list */
72178 spinlock_t info_list_lock;
72179 diff --git a/include/net/flow.h b/include/net/flow.h
72180 index 628e11b..4c475df 100644
72181 --- a/include/net/flow.h
72182 +++ b/include/net/flow.h
72183 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72184
72185 extern void flow_cache_flush(void);
72186 extern void flow_cache_flush_deferred(void);
72187 -extern atomic_t flow_cache_genid;
72188 +extern atomic_unchecked_t flow_cache_genid;
72189
72190 #endif
72191 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72192 index bdfbe68..4402ebe 100644
72193 --- a/include/net/genetlink.h
72194 +++ b/include/net/genetlink.h
72195 @@ -118,7 +118,7 @@ struct genl_ops {
72196 struct netlink_callback *cb);
72197 int (*done)(struct netlink_callback *cb);
72198 struct list_head ops_list;
72199 -};
72200 +} __do_const;
72201
72202 extern int genl_register_family(struct genl_family *family);
72203 extern int genl_register_family_with_ops(struct genl_family *family,
72204 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72205 index 734d9b5..48a9a4b 100644
72206 --- a/include/net/gro_cells.h
72207 +++ b/include/net/gro_cells.h
72208 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72209 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72210
72211 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72212 - atomic_long_inc(&dev->rx_dropped);
72213 + atomic_long_inc_unchecked(&dev->rx_dropped);
72214 kfree_skb(skb);
72215 return;
72216 }
72217 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72218 index 1832927..ce39aea 100644
72219 --- a/include/net/inet_connection_sock.h
72220 +++ b/include/net/inet_connection_sock.h
72221 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72222 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72223 int (*bind_conflict)(const struct sock *sk,
72224 const struct inet_bind_bucket *tb, bool relax);
72225 -};
72226 +} __do_const;
72227
72228 /** inet_connection_sock - INET connection oriented sock
72229 *
72230 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72231 index 53f464d..ba76aaa 100644
72232 --- a/include/net/inetpeer.h
72233 +++ b/include/net/inetpeer.h
72234 @@ -47,8 +47,8 @@ struct inet_peer {
72235 */
72236 union {
72237 struct {
72238 - atomic_t rid; /* Frag reception counter */
72239 - atomic_t ip_id_count; /* IP ID for the next packet */
72240 + atomic_unchecked_t rid; /* Frag reception counter */
72241 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72242 };
72243 struct rcu_head rcu;
72244 struct inet_peer *gc_next;
72245 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72246 more++;
72247 inet_peer_refcheck(p);
72248 do {
72249 - old = atomic_read(&p->ip_id_count);
72250 + old = atomic_read_unchecked(&p->ip_id_count);
72251 new = old + more;
72252 if (!new)
72253 new = 1;
72254 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72255 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72256 return new;
72257 }
72258
72259 diff --git a/include/net/ip.h b/include/net/ip.h
72260 index a68f838..74518ab 100644
72261 --- a/include/net/ip.h
72262 +++ b/include/net/ip.h
72263 @@ -202,7 +202,7 @@ extern struct local_ports {
72264 } sysctl_local_ports;
72265 extern void inet_get_local_port_range(int *low, int *high);
72266
72267 -extern unsigned long *sysctl_local_reserved_ports;
72268 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72269 static inline int inet_is_reserved_local_port(int port)
72270 {
72271 return test_bit(port, sysctl_local_reserved_ports);
72272 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72273 index e49db91..76a81de 100644
72274 --- a/include/net/ip_fib.h
72275 +++ b/include/net/ip_fib.h
72276 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72277
72278 #define FIB_RES_SADDR(net, res) \
72279 ((FIB_RES_NH(res).nh_saddr_genid == \
72280 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72281 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72282 FIB_RES_NH(res).nh_saddr : \
72283 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72284 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72285 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72286 index fce8e6b..3ca4916 100644
72287 --- a/include/net/ip_vs.h
72288 +++ b/include/net/ip_vs.h
72289 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72290 struct ip_vs_conn *control; /* Master control connection */
72291 atomic_t n_control; /* Number of controlled ones */
72292 struct ip_vs_dest *dest; /* real server */
72293 - atomic_t in_pkts; /* incoming packet counter */
72294 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72295
72296 /* packet transmitter for different forwarding methods. If it
72297 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72298 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72299 __be16 port; /* port number of the server */
72300 union nf_inet_addr addr; /* IP address of the server */
72301 volatile unsigned int flags; /* dest status flags */
72302 - atomic_t conn_flags; /* flags to copy to conn */
72303 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72304 atomic_t weight; /* server weight */
72305
72306 atomic_t refcnt; /* reference counter */
72307 @@ -981,11 +981,11 @@ struct netns_ipvs {
72308 /* ip_vs_lblc */
72309 int sysctl_lblc_expiration;
72310 struct ctl_table_header *lblc_ctl_header;
72311 - struct ctl_table *lblc_ctl_table;
72312 + ctl_table_no_const *lblc_ctl_table;
72313 /* ip_vs_lblcr */
72314 int sysctl_lblcr_expiration;
72315 struct ctl_table_header *lblcr_ctl_header;
72316 - struct ctl_table *lblcr_ctl_table;
72317 + ctl_table_no_const *lblcr_ctl_table;
72318 /* ip_vs_est */
72319 struct list_head est_list; /* estimator list */
72320 spinlock_t est_lock;
72321 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72322 index 80ffde3..968b0f4 100644
72323 --- a/include/net/irda/ircomm_tty.h
72324 +++ b/include/net/irda/ircomm_tty.h
72325 @@ -35,6 +35,7 @@
72326 #include <linux/termios.h>
72327 #include <linux/timer.h>
72328 #include <linux/tty.h> /* struct tty_struct */
72329 +#include <asm/local.h>
72330
72331 #include <net/irda/irias_object.h>
72332 #include <net/irda/ircomm_core.h>
72333 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72334 index 714cc9a..ea05f3e 100644
72335 --- a/include/net/iucv/af_iucv.h
72336 +++ b/include/net/iucv/af_iucv.h
72337 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
72338 struct iucv_sock_list {
72339 struct hlist_head head;
72340 rwlock_t lock;
72341 - atomic_t autobind_name;
72342 + atomic_unchecked_t autobind_name;
72343 };
72344
72345 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72346 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72347 index df83f69..9b640b8 100644
72348 --- a/include/net/llc_c_ac.h
72349 +++ b/include/net/llc_c_ac.h
72350 @@ -87,7 +87,7 @@
72351 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72352 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72353
72354 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72355 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72356
72357 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72358 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72359 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72360 index 6ca3113..f8026dd 100644
72361 --- a/include/net/llc_c_ev.h
72362 +++ b/include/net/llc_c_ev.h
72363 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72364 return (struct llc_conn_state_ev *)skb->cb;
72365 }
72366
72367 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72368 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72369 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72370 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72371
72372 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72373 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72374 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72375 index 0e79cfb..f46db31 100644
72376 --- a/include/net/llc_c_st.h
72377 +++ b/include/net/llc_c_st.h
72378 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72379 u8 next_state;
72380 llc_conn_ev_qfyr_t *ev_qualifiers;
72381 llc_conn_action_t *ev_actions;
72382 -};
72383 +} __do_const;
72384
72385 struct llc_conn_state {
72386 u8 current_state;
72387 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72388 index 37a3bbd..55a4241 100644
72389 --- a/include/net/llc_s_ac.h
72390 +++ b/include/net/llc_s_ac.h
72391 @@ -23,7 +23,7 @@
72392 #define SAP_ACT_TEST_IND 9
72393
72394 /* All action functions must look like this */
72395 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72396 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72397
72398 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72399 struct sk_buff *skb);
72400 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72401 index 567c681..cd73ac0 100644
72402 --- a/include/net/llc_s_st.h
72403 +++ b/include/net/llc_s_st.h
72404 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72405 llc_sap_ev_t ev;
72406 u8 next_state;
72407 llc_sap_action_t *ev_actions;
72408 -};
72409 +} __do_const;
72410
72411 struct llc_sap_state {
72412 u8 curr_state;
72413 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72414 index f7eba13..91ed983 100644
72415 --- a/include/net/mac80211.h
72416 +++ b/include/net/mac80211.h
72417 @@ -4119,7 +4119,7 @@ struct rate_control_ops {
72418 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72419 struct dentry *dir);
72420 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72421 -};
72422 +} __do_const;
72423
72424 static inline int rate_supported(struct ieee80211_sta *sta,
72425 enum ieee80211_band band,
72426 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72427 index 7e748ad..5c6229b 100644
72428 --- a/include/net/neighbour.h
72429 +++ b/include/net/neighbour.h
72430 @@ -123,7 +123,7 @@ struct neigh_ops {
72431 void (*error_report)(struct neighbour *, struct sk_buff *);
72432 int (*output)(struct neighbour *, struct sk_buff *);
72433 int (*connected_output)(struct neighbour *, struct sk_buff *);
72434 -};
72435 +} __do_const;
72436
72437 struct pneigh_entry {
72438 struct pneigh_entry *next;
72439 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72440 index de644bc..dfbcc4c 100644
72441 --- a/include/net/net_namespace.h
72442 +++ b/include/net/net_namespace.h
72443 @@ -115,7 +115,7 @@ struct net {
72444 #endif
72445 struct netns_ipvs *ipvs;
72446 struct sock *diag_nlsk;
72447 - atomic_t rt_genid;
72448 + atomic_unchecked_t rt_genid;
72449 };
72450
72451 /*
72452 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
72453 #define __net_init __init
72454 #define __net_exit __exit_refok
72455 #define __net_initdata __initdata
72456 +#ifdef CONSTIFY_PLUGIN
72457 #define __net_initconst __initconst
72458 +#else
72459 +#define __net_initconst __initdata
72460 +#endif
72461 #endif
72462
72463 struct pernet_operations {
72464 @@ -282,7 +286,7 @@ struct pernet_operations {
72465 void (*exit_batch)(struct list_head *net_exit_list);
72466 int *id;
72467 size_t size;
72468 -};
72469 +} __do_const;
72470
72471 /*
72472 * Use these carefully. If you implement a network device and it
72473 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
72474
72475 static inline int rt_genid(struct net *net)
72476 {
72477 - return atomic_read(&net->rt_genid);
72478 + return atomic_read_unchecked(&net->rt_genid);
72479 }
72480
72481 static inline void rt_genid_bump(struct net *net)
72482 {
72483 - atomic_inc(&net->rt_genid);
72484 + atomic_inc_unchecked(&net->rt_genid);
72485 }
72486
72487 #endif /* __NET_NET_NAMESPACE_H */
72488 diff --git a/include/net/netdma.h b/include/net/netdma.h
72489 index 8ba8ce2..99b7fff 100644
72490 --- a/include/net/netdma.h
72491 +++ b/include/net/netdma.h
72492 @@ -24,7 +24,7 @@
72493 #include <linux/dmaengine.h>
72494 #include <linux/skbuff.h>
72495
72496 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72497 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72498 struct sk_buff *skb, int offset, struct iovec *to,
72499 size_t len, struct dma_pinned_list *pinned_list);
72500
72501 diff --git a/include/net/netlink.h b/include/net/netlink.h
72502 index 9690b0f..87aded7 100644
72503 --- a/include/net/netlink.h
72504 +++ b/include/net/netlink.h
72505 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
72506 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
72507 {
72508 if (mark)
72509 - skb_trim(skb, (unsigned char *) mark - skb->data);
72510 + skb_trim(skb, (const unsigned char *) mark - skb->data);
72511 }
72512
72513 /**
72514 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
72515 index c9c0c53..53f24c3 100644
72516 --- a/include/net/netns/conntrack.h
72517 +++ b/include/net/netns/conntrack.h
72518 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
72519 struct nf_proto_net {
72520 #ifdef CONFIG_SYSCTL
72521 struct ctl_table_header *ctl_table_header;
72522 - struct ctl_table *ctl_table;
72523 + ctl_table_no_const *ctl_table;
72524 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
72525 struct ctl_table_header *ctl_compat_header;
72526 - struct ctl_table *ctl_compat_table;
72527 + ctl_table_no_const *ctl_compat_table;
72528 #endif
72529 #endif
72530 unsigned int users;
72531 @@ -58,7 +58,7 @@ struct nf_ip_net {
72532 struct nf_icmp_net icmpv6;
72533 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
72534 struct ctl_table_header *ctl_table_header;
72535 - struct ctl_table *ctl_table;
72536 + ctl_table_no_const *ctl_table;
72537 #endif
72538 };
72539
72540 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
72541 index 2ba9de8..47bd6c7 100644
72542 --- a/include/net/netns/ipv4.h
72543 +++ b/include/net/netns/ipv4.h
72544 @@ -67,7 +67,7 @@ struct netns_ipv4 {
72545 kgid_t sysctl_ping_group_range[2];
72546 long sysctl_tcp_mem[3];
72547
72548 - atomic_t dev_addr_genid;
72549 + atomic_unchecked_t dev_addr_genid;
72550
72551 #ifdef CONFIG_IP_MROUTE
72552 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
72553 diff --git a/include/net/protocol.h b/include/net/protocol.h
72554 index 047c047..b9dad15 100644
72555 --- a/include/net/protocol.h
72556 +++ b/include/net/protocol.h
72557 @@ -44,7 +44,7 @@ struct net_protocol {
72558 void (*err_handler)(struct sk_buff *skb, u32 info);
72559 unsigned int no_policy:1,
72560 netns_ok:1;
72561 -};
72562 +} __do_const;
72563
72564 #if IS_ENABLED(CONFIG_IPV6)
72565 struct inet6_protocol {
72566 @@ -57,7 +57,7 @@ struct inet6_protocol {
72567 u8 type, u8 code, int offset,
72568 __be32 info);
72569 unsigned int flags; /* INET6_PROTO_xxx */
72570 -};
72571 +} __do_const;
72572
72573 #define INET6_PROTO_NOPOLICY 0x1
72574 #define INET6_PROTO_FINAL 0x2
72575 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
72576 index 5a15fab..d799ea7 100644
72577 --- a/include/net/rtnetlink.h
72578 +++ b/include/net/rtnetlink.h
72579 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
72580 const struct net_device *dev);
72581 unsigned int (*get_num_tx_queues)(void);
72582 unsigned int (*get_num_rx_queues)(void);
72583 -};
72584 +} __do_const;
72585
72586 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
72587 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
72588 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
72589 index df85a0c..19ac300 100644
72590 --- a/include/net/sctp/sctp.h
72591 +++ b/include/net/sctp/sctp.h
72592 @@ -330,9 +330,9 @@ do { \
72593
72594 #else /* SCTP_DEBUG */
72595
72596 -#define SCTP_DEBUG_PRINTK(whatever...)
72597 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
72598 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
72599 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
72600 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
72601 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
72602 #define SCTP_ENABLE_DEBUG
72603 #define SCTP_DISABLE_DEBUG
72604 #define SCTP_ASSERT(expr, str, func)
72605 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
72606 index 2a82d13..62a31c2 100644
72607 --- a/include/net/sctp/sm.h
72608 +++ b/include/net/sctp/sm.h
72609 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
72610 typedef struct {
72611 sctp_state_fn_t *fn;
72612 const char *name;
72613 -} sctp_sm_table_entry_t;
72614 +} __do_const sctp_sm_table_entry_t;
72615
72616 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
72617 * currently in use.
72618 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
72619 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
72620
72621 /* Extern declarations for major data structures. */
72622 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72623 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72624
72625
72626 /* Get the size of a DATA chunk payload. */
72627 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
72628 index 0e0f9d2..cd05ebb 100644
72629 --- a/include/net/sctp/structs.h
72630 +++ b/include/net/sctp/structs.h
72631 @@ -517,7 +517,7 @@ struct sctp_pf {
72632 struct sctp_association *asoc);
72633 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
72634 struct sctp_af *af;
72635 -};
72636 +} __do_const;
72637
72638
72639 /* Structure to track chunk fragments that have been acked, but peer
72640 diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
72641 index c2e542b..6ca975b 100644
72642 --- a/include/net/secure_seq.h
72643 +++ b/include/net/secure_seq.h
72644 @@ -3,6 +3,7 @@
72645
72646 #include <linux/types.h>
72647
72648 +extern void net_secret_init(void);
72649 extern __u32 secure_ip_id(__be32 daddr);
72650 extern __u32 secure_ipv6_id(const __be32 daddr[4]);
72651 extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
72652 diff --git a/include/net/sock.h b/include/net/sock.h
72653 index 0be480a..586232f 100644
72654 --- a/include/net/sock.h
72655 +++ b/include/net/sock.h
72656 @@ -325,7 +325,7 @@ struct sock {
72657 #ifdef CONFIG_RPS
72658 __u32 sk_rxhash;
72659 #endif
72660 - atomic_t sk_drops;
72661 + atomic_unchecked_t sk_drops;
72662 int sk_rcvbuf;
72663
72664 struct sk_filter __rcu *sk_filter;
72665 @@ -1796,7 +1796,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
72666 }
72667
72668 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
72669 - char __user *from, char *to,
72670 + char __user *from, unsigned char *to,
72671 int copy, int offset)
72672 {
72673 if (skb->ip_summed == CHECKSUM_NONE) {
72674 @@ -2055,7 +2055,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
72675 }
72676 }
72677
72678 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72679 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72680
72681 /**
72682 * sk_page_frag - return an appropriate page_frag
72683 diff --git a/include/net/tcp.h b/include/net/tcp.h
72684 index a345480..3c65cf4 100644
72685 --- a/include/net/tcp.h
72686 +++ b/include/net/tcp.h
72687 @@ -529,7 +529,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
72688 extern void tcp_xmit_retransmit_queue(struct sock *);
72689 extern void tcp_simple_retransmit(struct sock *);
72690 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
72691 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72692 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72693
72694 extern void tcp_send_probe0(struct sock *);
72695 extern void tcp_send_partial(struct sock *);
72696 @@ -700,8 +700,8 @@ struct tcp_skb_cb {
72697 struct inet6_skb_parm h6;
72698 #endif
72699 } header; /* For incoming frames */
72700 - __u32 seq; /* Starting sequence number */
72701 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
72702 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
72703 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
72704 __u32 when; /* used to compute rtt's */
72705 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
72706
72707 @@ -715,7 +715,7 @@ struct tcp_skb_cb {
72708
72709 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
72710 /* 1 byte hole */
72711 - __u32 ack_seq; /* Sequence number ACK'd */
72712 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
72713 };
72714
72715 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
72716 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
72717 index 24c8886..e6fb816 100644
72718 --- a/include/net/xfrm.h
72719 +++ b/include/net/xfrm.h
72720 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
72721 struct net_device *dev,
72722 const struct flowi *fl);
72723 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
72724 -};
72725 +} __do_const;
72726
72727 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
72728 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
72729 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
72730 struct sk_buff *skb);
72731 int (*transport_finish)(struct sk_buff *skb,
72732 int async);
72733 -};
72734 +} __do_const;
72735
72736 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
72737 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
72738 @@ -423,7 +423,7 @@ struct xfrm_mode {
72739 struct module *owner;
72740 unsigned int encap;
72741 int flags;
72742 -};
72743 +} __do_const;
72744
72745 /* Flags for xfrm_mode. */
72746 enum {
72747 @@ -520,7 +520,7 @@ struct xfrm_policy {
72748 struct timer_list timer;
72749
72750 struct flow_cache_object flo;
72751 - atomic_t genid;
72752 + atomic_unchecked_t genid;
72753 u32 priority;
72754 u32 index;
72755 struct xfrm_mark mark;
72756 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
72757 index 1a046b1..ee0bef0 100644
72758 --- a/include/rdma/iw_cm.h
72759 +++ b/include/rdma/iw_cm.h
72760 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
72761 int backlog);
72762
72763 int (*destroy_listen)(struct iw_cm_id *cm_id);
72764 -};
72765 +} __no_const;
72766
72767 /**
72768 * iw_create_cm_id - Create an IW CM identifier.
72769 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
72770 index e1379b4..67eafbe 100644
72771 --- a/include/scsi/libfc.h
72772 +++ b/include/scsi/libfc.h
72773 @@ -762,6 +762,7 @@ struct libfc_function_template {
72774 */
72775 void (*disc_stop_final) (struct fc_lport *);
72776 };
72777 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
72778
72779 /**
72780 * struct fc_disc - Discovery context
72781 @@ -866,7 +867,7 @@ struct fc_lport {
72782 struct fc_vport *vport;
72783
72784 /* Operational Information */
72785 - struct libfc_function_template tt;
72786 + libfc_function_template_no_const tt;
72787 u8 link_up;
72788 u8 qfull;
72789 enum fc_lport_state state;
72790 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
72791 index a7f9cba..b1f44d0 100644
72792 --- a/include/scsi/scsi_device.h
72793 +++ b/include/scsi/scsi_device.h
72794 @@ -171,9 +171,9 @@ struct scsi_device {
72795 unsigned int max_device_blocked; /* what device_blocked counts down from */
72796 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
72797
72798 - atomic_t iorequest_cnt;
72799 - atomic_t iodone_cnt;
72800 - atomic_t ioerr_cnt;
72801 + atomic_unchecked_t iorequest_cnt;
72802 + atomic_unchecked_t iodone_cnt;
72803 + atomic_unchecked_t ioerr_cnt;
72804
72805 struct device sdev_gendev,
72806 sdev_dev;
72807 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
72808 index b797e8f..8e2c3aa 100644
72809 --- a/include/scsi/scsi_transport_fc.h
72810 +++ b/include/scsi/scsi_transport_fc.h
72811 @@ -751,7 +751,8 @@ struct fc_function_template {
72812 unsigned long show_host_system_hostname:1;
72813
72814 unsigned long disable_target_scan:1;
72815 -};
72816 +} __do_const;
72817 +typedef struct fc_function_template __no_const fc_function_template_no_const;
72818
72819
72820 /**
72821 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
72822 index ff6c741..393815f 100644
72823 --- a/include/sound/compress_driver.h
72824 +++ b/include/sound/compress_driver.h
72825 @@ -130,7 +130,7 @@ struct snd_compr_ops {
72826 struct snd_compr_caps *caps);
72827 int (*get_codec_caps) (struct snd_compr_stream *stream,
72828 struct snd_compr_codec_caps *codec);
72829 -};
72830 +} __no_const;
72831
72832 /**
72833 * struct snd_compr: Compressed device
72834 diff --git a/include/sound/soc.h b/include/sound/soc.h
72835 index a6a059c..2243336 100644
72836 --- a/include/sound/soc.h
72837 +++ b/include/sound/soc.h
72838 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
72839 /* probe ordering - for components with runtime dependencies */
72840 int probe_order;
72841 int remove_order;
72842 -};
72843 +} __do_const;
72844
72845 /* SoC platform interface */
72846 struct snd_soc_platform_driver {
72847 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
72848 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
72849 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
72850 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
72851 -};
72852 +} __do_const;
72853
72854 struct snd_soc_platform {
72855 const char *name;
72856 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
72857 index c4af592..20c52d2 100644
72858 --- a/include/target/target_core_base.h
72859 +++ b/include/target/target_core_base.h
72860 @@ -657,7 +657,7 @@ struct se_device {
72861 spinlock_t stats_lock;
72862 /* Active commands on this virtual SE device */
72863 atomic_t simple_cmds;
72864 - atomic_t dev_ordered_id;
72865 + atomic_unchecked_t dev_ordered_id;
72866 atomic_t dev_ordered_sync;
72867 atomic_t dev_qf_count;
72868 int export_count;
72869 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
72870 new file mode 100644
72871 index 0000000..fb634b7
72872 --- /dev/null
72873 +++ b/include/trace/events/fs.h
72874 @@ -0,0 +1,53 @@
72875 +#undef TRACE_SYSTEM
72876 +#define TRACE_SYSTEM fs
72877 +
72878 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
72879 +#define _TRACE_FS_H
72880 +
72881 +#include <linux/fs.h>
72882 +#include <linux/tracepoint.h>
72883 +
72884 +TRACE_EVENT(do_sys_open,
72885 +
72886 + TP_PROTO(const char *filename, int flags, int mode),
72887 +
72888 + TP_ARGS(filename, flags, mode),
72889 +
72890 + TP_STRUCT__entry(
72891 + __string( filename, filename )
72892 + __field( int, flags )
72893 + __field( int, mode )
72894 + ),
72895 +
72896 + TP_fast_assign(
72897 + __assign_str(filename, filename);
72898 + __entry->flags = flags;
72899 + __entry->mode = mode;
72900 + ),
72901 +
72902 + TP_printk("\"%s\" %x %o",
72903 + __get_str(filename), __entry->flags, __entry->mode)
72904 +);
72905 +
72906 +TRACE_EVENT(open_exec,
72907 +
72908 + TP_PROTO(const char *filename),
72909 +
72910 + TP_ARGS(filename),
72911 +
72912 + TP_STRUCT__entry(
72913 + __string( filename, filename )
72914 + ),
72915 +
72916 + TP_fast_assign(
72917 + __assign_str(filename, filename);
72918 + ),
72919 +
72920 + TP_printk("\"%s\"",
72921 + __get_str(filename))
72922 +);
72923 +
72924 +#endif /* _TRACE_FS_H */
72925 +
72926 +/* This part must be outside protection */
72927 +#include <trace/define_trace.h>
72928 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
72929 index 1c09820..7f5ec79 100644
72930 --- a/include/trace/events/irq.h
72931 +++ b/include/trace/events/irq.h
72932 @@ -36,7 +36,7 @@ struct softirq_action;
72933 */
72934 TRACE_EVENT(irq_handler_entry,
72935
72936 - TP_PROTO(int irq, struct irqaction *action),
72937 + TP_PROTO(int irq, const struct irqaction *action),
72938
72939 TP_ARGS(irq, action),
72940
72941 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
72942 */
72943 TRACE_EVENT(irq_handler_exit,
72944
72945 - TP_PROTO(int irq, struct irqaction *action, int ret),
72946 + TP_PROTO(int irq, const struct irqaction *action, int ret),
72947
72948 TP_ARGS(irq, action, ret),
72949
72950 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
72951 index 7caf44c..23c6f27 100644
72952 --- a/include/uapi/linux/a.out.h
72953 +++ b/include/uapi/linux/a.out.h
72954 @@ -39,6 +39,14 @@ enum machine_type {
72955 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
72956 };
72957
72958 +/* Constants for the N_FLAGS field */
72959 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72960 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
72961 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
72962 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
72963 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72964 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72965 +
72966 #if !defined (N_MAGIC)
72967 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
72968 #endif
72969 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
72970 index d876736..ccce5c0 100644
72971 --- a/include/uapi/linux/byteorder/little_endian.h
72972 +++ b/include/uapi/linux/byteorder/little_endian.h
72973 @@ -42,51 +42,51 @@
72974
72975 static inline __le64 __cpu_to_le64p(const __u64 *p)
72976 {
72977 - return (__force __le64)*p;
72978 + return (__force const __le64)*p;
72979 }
72980 -static inline __u64 __le64_to_cpup(const __le64 *p)
72981 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
72982 {
72983 - return (__force __u64)*p;
72984 + return (__force const __u64)*p;
72985 }
72986 static inline __le32 __cpu_to_le32p(const __u32 *p)
72987 {
72988 - return (__force __le32)*p;
72989 + return (__force const __le32)*p;
72990 }
72991 static inline __u32 __le32_to_cpup(const __le32 *p)
72992 {
72993 - return (__force __u32)*p;
72994 + return (__force const __u32)*p;
72995 }
72996 static inline __le16 __cpu_to_le16p(const __u16 *p)
72997 {
72998 - return (__force __le16)*p;
72999 + return (__force const __le16)*p;
73000 }
73001 static inline __u16 __le16_to_cpup(const __le16 *p)
73002 {
73003 - return (__force __u16)*p;
73004 + return (__force const __u16)*p;
73005 }
73006 static inline __be64 __cpu_to_be64p(const __u64 *p)
73007 {
73008 - return (__force __be64)__swab64p(p);
73009 + return (__force const __be64)__swab64p(p);
73010 }
73011 static inline __u64 __be64_to_cpup(const __be64 *p)
73012 {
73013 - return __swab64p((__u64 *)p);
73014 + return __swab64p((const __u64 *)p);
73015 }
73016 static inline __be32 __cpu_to_be32p(const __u32 *p)
73017 {
73018 - return (__force __be32)__swab32p(p);
73019 + return (__force const __be32)__swab32p(p);
73020 }
73021 -static inline __u32 __be32_to_cpup(const __be32 *p)
73022 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73023 {
73024 - return __swab32p((__u32 *)p);
73025 + return __swab32p((const __u32 *)p);
73026 }
73027 static inline __be16 __cpu_to_be16p(const __u16 *p)
73028 {
73029 - return (__force __be16)__swab16p(p);
73030 + return (__force const __be16)__swab16p(p);
73031 }
73032 static inline __u16 __be16_to_cpup(const __be16 *p)
73033 {
73034 - return __swab16p((__u16 *)p);
73035 + return __swab16p((const __u16 *)p);
73036 }
73037 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73038 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73039 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73040 index 8072d35..e77aeb8 100644
73041 --- a/include/uapi/linux/elf.h
73042 +++ b/include/uapi/linux/elf.h
73043 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73044 #define PT_GNU_EH_FRAME 0x6474e550
73045
73046 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73047 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73048 +
73049 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73050 +
73051 +/* Constants for the e_flags field */
73052 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73053 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73054 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73055 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73056 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73057 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73058
73059 /*
73060 * Extended Numbering
73061 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73062 #define DT_DEBUG 21
73063 #define DT_TEXTREL 22
73064 #define DT_JMPREL 23
73065 +#define DT_FLAGS 30
73066 + #define DF_TEXTREL 0x00000004
73067 #define DT_ENCODING 32
73068 #define OLD_DT_LOOS 0x60000000
73069 #define DT_LOOS 0x6000000d
73070 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73071 #define PF_W 0x2
73072 #define PF_X 0x1
73073
73074 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73075 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73076 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73077 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73078 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73079 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73080 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73081 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73082 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73083 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73084 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73085 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73086 +
73087 typedef struct elf32_phdr{
73088 Elf32_Word p_type;
73089 Elf32_Off p_offset;
73090 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73091 #define EI_OSABI 7
73092 #define EI_PAD 8
73093
73094 +#define EI_PAX 14
73095 +
73096 #define ELFMAG0 0x7f /* EI_MAG */
73097 #define ELFMAG1 'E'
73098 #define ELFMAG2 'L'
73099 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73100 index aa169c4..6a2771d 100644
73101 --- a/include/uapi/linux/personality.h
73102 +++ b/include/uapi/linux/personality.h
73103 @@ -30,6 +30,7 @@ enum {
73104 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73105 ADDR_NO_RANDOMIZE | \
73106 ADDR_COMPAT_LAYOUT | \
73107 + ADDR_LIMIT_3GB | \
73108 MMAP_PAGE_ZERO)
73109
73110 /*
73111 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73112 index 7530e74..e714828 100644
73113 --- a/include/uapi/linux/screen_info.h
73114 +++ b/include/uapi/linux/screen_info.h
73115 @@ -43,7 +43,8 @@ struct screen_info {
73116 __u16 pages; /* 0x32 */
73117 __u16 vesa_attributes; /* 0x34 */
73118 __u32 capabilities; /* 0x36 */
73119 - __u8 _reserved[6]; /* 0x3a */
73120 + __u16 vesapm_size; /* 0x3a */
73121 + __u8 _reserved[4]; /* 0x3c */
73122 } __attribute__((packed));
73123
73124 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73125 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73126 index 0e011eb..82681b1 100644
73127 --- a/include/uapi/linux/swab.h
73128 +++ b/include/uapi/linux/swab.h
73129 @@ -43,7 +43,7 @@
73130 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73131 */
73132
73133 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73134 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73135 {
73136 #ifdef __HAVE_BUILTIN_BSWAP16__
73137 return __builtin_bswap16(val);
73138 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73139 #endif
73140 }
73141
73142 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73143 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73144 {
73145 #ifdef __HAVE_BUILTIN_BSWAP32__
73146 return __builtin_bswap32(val);
73147 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73148 #endif
73149 }
73150
73151 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73152 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73153 {
73154 #ifdef __HAVE_BUILTIN_BSWAP64__
73155 return __builtin_bswap64(val);
73156 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73157 index 6d67213..8dab561 100644
73158 --- a/include/uapi/linux/sysctl.h
73159 +++ b/include/uapi/linux/sysctl.h
73160 @@ -155,7 +155,11 @@ enum
73161 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73162 };
73163
73164 -
73165 +#ifdef CONFIG_PAX_SOFTMODE
73166 +enum {
73167 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73168 +};
73169 +#endif
73170
73171 /* CTL_VM names: */
73172 enum
73173 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73174 index e4629b9..6958086 100644
73175 --- a/include/uapi/linux/xattr.h
73176 +++ b/include/uapi/linux/xattr.h
73177 @@ -63,5 +63,9 @@
73178 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73179 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73180
73181 +/* User namespace */
73182 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73183 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73184 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73185
73186 #endif /* _UAPI_LINUX_XATTR_H */
73187 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73188 index f9466fa..f4e2b81 100644
73189 --- a/include/video/udlfb.h
73190 +++ b/include/video/udlfb.h
73191 @@ -53,10 +53,10 @@ struct dlfb_data {
73192 u32 pseudo_palette[256];
73193 int blank_mode; /*one of FB_BLANK_ */
73194 /* blit-only rendering path metrics, exposed through sysfs */
73195 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73196 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73197 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73198 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73199 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73200 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73201 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73202 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73203 };
73204
73205 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73206 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73207 index 1a91850..28573f8 100644
73208 --- a/include/video/uvesafb.h
73209 +++ b/include/video/uvesafb.h
73210 @@ -122,6 +122,7 @@ struct uvesafb_par {
73211 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73212 u8 pmi_setpal; /* PMI for palette changes */
73213 u16 *pmi_base; /* protected mode interface location */
73214 + u8 *pmi_code; /* protected mode code location */
73215 void *pmi_start;
73216 void *pmi_pal;
73217 u8 *vbe_state_orig; /*
73218 diff --git a/init/Kconfig b/init/Kconfig
73219 index 5341d72..153f24f 100644
73220 --- a/init/Kconfig
73221 +++ b/init/Kconfig
73222 @@ -984,6 +984,7 @@ endif # CGROUPS
73223
73224 config CHECKPOINT_RESTORE
73225 bool "Checkpoint/restore support" if EXPERT
73226 + depends on !GRKERNSEC
73227 default n
73228 help
73229 Enables additional kernel features in a sake of checkpoint/restore.
73230 @@ -1471,7 +1472,7 @@ config SLUB_DEBUG
73231
73232 config COMPAT_BRK
73233 bool "Disable heap randomization"
73234 - default y
73235 + default n
73236 help
73237 Randomizing heap placement makes heap exploits harder, but it
73238 also breaks ancient binaries (including anything libc5 based).
73239 @@ -1734,7 +1735,7 @@ config INIT_ALL_POSSIBLE
73240 config STOP_MACHINE
73241 bool
73242 default y
73243 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73244 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73245 help
73246 Need stop_machine() primitive.
73247
73248 diff --git a/init/Makefile b/init/Makefile
73249 index 7bc47ee..6da2dc7 100644
73250 --- a/init/Makefile
73251 +++ b/init/Makefile
73252 @@ -2,6 +2,9 @@
73253 # Makefile for the linux kernel.
73254 #
73255
73256 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73257 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73258 +
73259 obj-y := main.o version.o mounts.o
73260 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73261 obj-y += noinitramfs.o
73262 diff --git a/init/do_mounts.c b/init/do_mounts.c
73263 index a2b49f2..03a0e17c 100644
73264 --- a/init/do_mounts.c
73265 +++ b/init/do_mounts.c
73266 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73267 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73268 {
73269 struct super_block *s;
73270 - int err = sys_mount(name, "/root", fs, flags, data);
73271 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73272 if (err)
73273 return err;
73274
73275 - sys_chdir("/root");
73276 + sys_chdir((const char __force_user *)"/root");
73277 s = current->fs->pwd.dentry->d_sb;
73278 ROOT_DEV = s->s_dev;
73279 printk(KERN_INFO
73280 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73281 va_start(args, fmt);
73282 vsprintf(buf, fmt, args);
73283 va_end(args);
73284 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73285 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73286 if (fd >= 0) {
73287 sys_ioctl(fd, FDEJECT, 0);
73288 sys_close(fd);
73289 }
73290 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73291 - fd = sys_open("/dev/console", O_RDWR, 0);
73292 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73293 if (fd >= 0) {
73294 sys_ioctl(fd, TCGETS, (long)&termios);
73295 termios.c_lflag &= ~ICANON;
73296 sys_ioctl(fd, TCSETSF, (long)&termios);
73297 - sys_read(fd, &c, 1);
73298 + sys_read(fd, (char __user *)&c, 1);
73299 termios.c_lflag |= ICANON;
73300 sys_ioctl(fd, TCSETSF, (long)&termios);
73301 sys_close(fd);
73302 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73303 mount_root();
73304 out:
73305 devtmpfs_mount("dev");
73306 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73307 - sys_chroot(".");
73308 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73309 + sys_chroot((const char __force_user *)".");
73310 }
73311 diff --git a/init/do_mounts.h b/init/do_mounts.h
73312 index f5b978a..69dbfe8 100644
73313 --- a/init/do_mounts.h
73314 +++ b/init/do_mounts.h
73315 @@ -15,15 +15,15 @@ extern int root_mountflags;
73316
73317 static inline int create_dev(char *name, dev_t dev)
73318 {
73319 - sys_unlink(name);
73320 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73321 + sys_unlink((char __force_user *)name);
73322 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73323 }
73324
73325 #if BITS_PER_LONG == 32
73326 static inline u32 bstat(char *name)
73327 {
73328 struct stat64 stat;
73329 - if (sys_stat64(name, &stat) != 0)
73330 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73331 return 0;
73332 if (!S_ISBLK(stat.st_mode))
73333 return 0;
73334 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73335 static inline u32 bstat(char *name)
73336 {
73337 struct stat stat;
73338 - if (sys_newstat(name, &stat) != 0)
73339 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73340 return 0;
73341 if (!S_ISBLK(stat.st_mode))
73342 return 0;
73343 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73344 index a32ec1c..60a6659 100644
73345 --- a/init/do_mounts_initrd.c
73346 +++ b/init/do_mounts_initrd.c
73347 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
73348 {
73349 sys_unshare(CLONE_FS | CLONE_FILES);
73350 /* stdin/stdout/stderr for /linuxrc */
73351 - sys_open("/dev/console", O_RDWR, 0);
73352 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
73353 sys_dup(0);
73354 sys_dup(0);
73355 /* move initrd over / and chdir/chroot in initrd root */
73356 - sys_chdir("/root");
73357 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73358 - sys_chroot(".");
73359 + sys_chdir((const char __force_user *)"/root");
73360 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73361 + sys_chroot((const char __force_user *)".");
73362 sys_setsid();
73363 return 0;
73364 }
73365 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73366 create_dev("/dev/root.old", Root_RAM0);
73367 /* mount initrd on rootfs' /root */
73368 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73369 - sys_mkdir("/old", 0700);
73370 - sys_chdir("/old");
73371 + sys_mkdir((const char __force_user *)"/old", 0700);
73372 + sys_chdir((const char __force_user *)"/old");
73373
73374 /* try loading default modules from initrd */
73375 load_default_modules();
73376 @@ -76,31 +76,31 @@ static void __init handle_initrd(void)
73377 current->flags &= ~PF_FREEZER_SKIP;
73378
73379 /* move initrd to rootfs' /old */
73380 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73381 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73382 /* switch root and cwd back to / of rootfs */
73383 - sys_chroot("..");
73384 + sys_chroot((const char __force_user *)"..");
73385
73386 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73387 - sys_chdir("/old");
73388 + sys_chdir((const char __force_user *)"/old");
73389 return;
73390 }
73391
73392 - sys_chdir("/");
73393 + sys_chdir((const char __force_user *)"/");
73394 ROOT_DEV = new_decode_dev(real_root_dev);
73395 mount_root();
73396
73397 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73398 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73399 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73400 if (!error)
73401 printk("okay\n");
73402 else {
73403 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73404 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73405 if (error == -ENOENT)
73406 printk("/initrd does not exist. Ignored.\n");
73407 else
73408 printk("failed\n");
73409 printk(KERN_NOTICE "Unmounting old root\n");
73410 - sys_umount("/old", MNT_DETACH);
73411 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73412 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73413 if (fd < 0) {
73414 error = fd;
73415 @@ -123,11 +123,11 @@ int __init initrd_load(void)
73416 * mounted in the normal path.
73417 */
73418 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73419 - sys_unlink("/initrd.image");
73420 + sys_unlink((const char __force_user *)"/initrd.image");
73421 handle_initrd();
73422 return 1;
73423 }
73424 }
73425 - sys_unlink("/initrd.image");
73426 + sys_unlink((const char __force_user *)"/initrd.image");
73427 return 0;
73428 }
73429 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73430 index 8cb6db5..d729f50 100644
73431 --- a/init/do_mounts_md.c
73432 +++ b/init/do_mounts_md.c
73433 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73434 partitioned ? "_d" : "", minor,
73435 md_setup_args[ent].device_names);
73436
73437 - fd = sys_open(name, 0, 0);
73438 + fd = sys_open((char __force_user *)name, 0, 0);
73439 if (fd < 0) {
73440 printk(KERN_ERR "md: open failed - cannot start "
73441 "array %s\n", name);
73442 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73443 * array without it
73444 */
73445 sys_close(fd);
73446 - fd = sys_open(name, 0, 0);
73447 + fd = sys_open((char __force_user *)name, 0, 0);
73448 sys_ioctl(fd, BLKRRPART, 0);
73449 }
73450 sys_close(fd);
73451 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73452
73453 wait_for_device_probe();
73454
73455 - fd = sys_open("/dev/md0", 0, 0);
73456 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73457 if (fd >= 0) {
73458 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73459 sys_close(fd);
73460 diff --git a/init/init_task.c b/init/init_task.c
73461 index ba0a7f36..2bcf1d5 100644
73462 --- a/init/init_task.c
73463 +++ b/init/init_task.c
73464 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
73465 * Initial thread structure. Alignment of this is handled by a special
73466 * linker map entry.
73467 */
73468 +#ifdef CONFIG_X86
73469 +union thread_union init_thread_union __init_task_data;
73470 +#else
73471 union thread_union init_thread_union __init_task_data =
73472 { INIT_THREAD_INFO(init_task) };
73473 +#endif
73474 diff --git a/init/initramfs.c b/init/initramfs.c
73475 index a67ef9d..3d88592 100644
73476 --- a/init/initramfs.c
73477 +++ b/init/initramfs.c
73478 @@ -84,7 +84,7 @@ static void __init free_hash(void)
73479 }
73480 }
73481
73482 -static long __init do_utime(char *filename, time_t mtime)
73483 +static long __init do_utime(char __force_user *filename, time_t mtime)
73484 {
73485 struct timespec t[2];
73486
73487 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
73488 struct dir_entry *de, *tmp;
73489 list_for_each_entry_safe(de, tmp, &dir_list, list) {
73490 list_del(&de->list);
73491 - do_utime(de->name, de->mtime);
73492 + do_utime((char __force_user *)de->name, de->mtime);
73493 kfree(de->name);
73494 kfree(de);
73495 }
73496 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
73497 if (nlink >= 2) {
73498 char *old = find_link(major, minor, ino, mode, collected);
73499 if (old)
73500 - return (sys_link(old, collected) < 0) ? -1 : 1;
73501 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
73502 }
73503 return 0;
73504 }
73505 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
73506 {
73507 struct stat st;
73508
73509 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
73510 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
73511 if (S_ISDIR(st.st_mode))
73512 - sys_rmdir(path);
73513 + sys_rmdir((char __force_user *)path);
73514 else
73515 - sys_unlink(path);
73516 + sys_unlink((char __force_user *)path);
73517 }
73518 }
73519
73520 @@ -315,7 +315,7 @@ static int __init do_name(void)
73521 int openflags = O_WRONLY|O_CREAT;
73522 if (ml != 1)
73523 openflags |= O_TRUNC;
73524 - wfd = sys_open(collected, openflags, mode);
73525 + wfd = sys_open((char __force_user *)collected, openflags, mode);
73526
73527 if (wfd >= 0) {
73528 sys_fchown(wfd, uid, gid);
73529 @@ -327,17 +327,17 @@ static int __init do_name(void)
73530 }
73531 }
73532 } else if (S_ISDIR(mode)) {
73533 - sys_mkdir(collected, mode);
73534 - sys_chown(collected, uid, gid);
73535 - sys_chmod(collected, mode);
73536 + sys_mkdir((char __force_user *)collected, mode);
73537 + sys_chown((char __force_user *)collected, uid, gid);
73538 + sys_chmod((char __force_user *)collected, mode);
73539 dir_add(collected, mtime);
73540 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
73541 S_ISFIFO(mode) || S_ISSOCK(mode)) {
73542 if (maybe_link() == 0) {
73543 - sys_mknod(collected, mode, rdev);
73544 - sys_chown(collected, uid, gid);
73545 - sys_chmod(collected, mode);
73546 - do_utime(collected, mtime);
73547 + sys_mknod((char __force_user *)collected, mode, rdev);
73548 + sys_chown((char __force_user *)collected, uid, gid);
73549 + sys_chmod((char __force_user *)collected, mode);
73550 + do_utime((char __force_user *)collected, mtime);
73551 }
73552 }
73553 return 0;
73554 @@ -346,15 +346,15 @@ static int __init do_name(void)
73555 static int __init do_copy(void)
73556 {
73557 if (count >= body_len) {
73558 - sys_write(wfd, victim, body_len);
73559 + sys_write(wfd, (char __force_user *)victim, body_len);
73560 sys_close(wfd);
73561 - do_utime(vcollected, mtime);
73562 + do_utime((char __force_user *)vcollected, mtime);
73563 kfree(vcollected);
73564 eat(body_len);
73565 state = SkipIt;
73566 return 0;
73567 } else {
73568 - sys_write(wfd, victim, count);
73569 + sys_write(wfd, (char __force_user *)victim, count);
73570 body_len -= count;
73571 eat(count);
73572 return 1;
73573 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
73574 {
73575 collected[N_ALIGN(name_len) + body_len] = '\0';
73576 clean_path(collected, 0);
73577 - sys_symlink(collected + N_ALIGN(name_len), collected);
73578 - sys_lchown(collected, uid, gid);
73579 - do_utime(collected, mtime);
73580 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
73581 + sys_lchown((char __force_user *)collected, uid, gid);
73582 + do_utime((char __force_user *)collected, mtime);
73583 state = SkipIt;
73584 next_state = Reset;
73585 return 0;
73586 diff --git a/init/main.c b/init/main.c
73587 index 63534a1..85feae2 100644
73588 --- a/init/main.c
73589 +++ b/init/main.c
73590 @@ -98,6 +98,8 @@ static inline void mark_rodata_ro(void) { }
73591 extern void tc_init(void);
73592 #endif
73593
73594 +extern void grsecurity_init(void);
73595 +
73596 /*
73597 * Debug helper: via this flag we know that we are in 'early bootup code'
73598 * where only the boot processor is running with IRQ disabled. This means
73599 @@ -151,6 +153,64 @@ static int __init set_reset_devices(char *str)
73600
73601 __setup("reset_devices", set_reset_devices);
73602
73603 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
73604 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
73605 +static int __init setup_grsec_proc_gid(char *str)
73606 +{
73607 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
73608 + return 1;
73609 +}
73610 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
73611 +#endif
73612 +
73613 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
73614 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
73615 +EXPORT_SYMBOL(pax_user_shadow_base);
73616 +extern char pax_enter_kernel_user[];
73617 +extern char pax_exit_kernel_user[];
73618 +extern pgdval_t clone_pgd_mask;
73619 +#endif
73620 +
73621 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
73622 +static int __init setup_pax_nouderef(char *str)
73623 +{
73624 +#ifdef CONFIG_X86_32
73625 + unsigned int cpu;
73626 + struct desc_struct *gdt;
73627 +
73628 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
73629 + gdt = get_cpu_gdt_table(cpu);
73630 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
73631 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
73632 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
73633 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
73634 + }
73635 + loadsegment(ds, __KERNEL_DS);
73636 + loadsegment(es, __KERNEL_DS);
73637 + loadsegment(ss, __KERNEL_DS);
73638 +#else
73639 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
73640 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
73641 + clone_pgd_mask = ~(pgdval_t)0UL;
73642 + pax_user_shadow_base = 0UL;
73643 +#endif
73644 +
73645 + return 0;
73646 +}
73647 +early_param("pax_nouderef", setup_pax_nouderef);
73648 +#endif
73649 +
73650 +#ifdef CONFIG_PAX_SOFTMODE
73651 +int pax_softmode;
73652 +
73653 +static int __init setup_pax_softmode(char *str)
73654 +{
73655 + get_option(&str, &pax_softmode);
73656 + return 1;
73657 +}
73658 +__setup("pax_softmode=", setup_pax_softmode);
73659 +#endif
73660 +
73661 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
73662 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
73663 static const char *panic_later, *panic_param;
73664 @@ -683,6 +743,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
73665 {
73666 int count = preempt_count();
73667 int ret;
73668 + const char *msg1 = "", *msg2 = "";
73669
73670 if (initcall_debug)
73671 ret = do_one_initcall_debug(fn);
73672 @@ -695,15 +756,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
73673 sprintf(msgbuf, "error code %d ", ret);
73674
73675 if (preempt_count() != count) {
73676 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
73677 + msg1 = " preemption imbalance";
73678 preempt_count() = count;
73679 }
73680 if (irqs_disabled()) {
73681 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
73682 + msg2 = " disabled interrupts";
73683 local_irq_enable();
73684 }
73685 - if (msgbuf[0]) {
73686 - printk("initcall %pF returned with %s\n", fn, msgbuf);
73687 + if (msgbuf[0] || *msg1 || *msg2) {
73688 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
73689 }
73690
73691 return ret;
73692 @@ -757,8 +818,14 @@ static void __init do_initcall_level(int level)
73693 level, level,
73694 &repair_env_string);
73695
73696 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
73697 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
73698 do_one_initcall(*fn);
73699 +
73700 +#ifdef LATENT_ENTROPY_PLUGIN
73701 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73702 +#endif
73703 +
73704 + }
73705 }
73706
73707 static void __init do_initcalls(void)
73708 @@ -792,8 +859,14 @@ static void __init do_pre_smp_initcalls(void)
73709 {
73710 initcall_t *fn;
73711
73712 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
73713 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
73714 do_one_initcall(*fn);
73715 +
73716 +#ifdef LATENT_ENTROPY_PLUGIN
73717 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73718 +#endif
73719 +
73720 + }
73721 }
73722
73723 /*
73724 @@ -811,8 +884,8 @@ static int run_init_process(const char *init_filename)
73725 {
73726 argv_init[0] = init_filename;
73727 return do_execve(init_filename,
73728 - (const char __user *const __user *)argv_init,
73729 - (const char __user *const __user *)envp_init);
73730 + (const char __user *const __force_user *)argv_init,
73731 + (const char __user *const __force_user *)envp_init);
73732 }
73733
73734 static noinline void __init kernel_init_freeable(void);
73735 @@ -890,7 +963,7 @@ static noinline void __init kernel_init_freeable(void)
73736 do_basic_setup();
73737
73738 /* Open the /dev/console on the rootfs, this should never fail */
73739 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
73740 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
73741 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
73742
73743 (void) sys_dup(0);
73744 @@ -903,11 +976,13 @@ static noinline void __init kernel_init_freeable(void)
73745 if (!ramdisk_execute_command)
73746 ramdisk_execute_command = "/init";
73747
73748 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
73749 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
73750 ramdisk_execute_command = NULL;
73751 prepare_namespace();
73752 }
73753
73754 + grsecurity_init();
73755 +
73756 /*
73757 * Ok, we have completed the initial bootup, and
73758 * we're essentially up and running. Get rid of the
73759 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
73760 index 130dfec..cc88451 100644
73761 --- a/ipc/ipc_sysctl.c
73762 +++ b/ipc/ipc_sysctl.c
73763 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
73764 static int proc_ipc_dointvec(ctl_table *table, int write,
73765 void __user *buffer, size_t *lenp, loff_t *ppos)
73766 {
73767 - struct ctl_table ipc_table;
73768 + ctl_table_no_const ipc_table;
73769
73770 memcpy(&ipc_table, table, sizeof(ipc_table));
73771 ipc_table.data = get_ipc(table);
73772 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
73773 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
73774 void __user *buffer, size_t *lenp, loff_t *ppos)
73775 {
73776 - struct ctl_table ipc_table;
73777 + ctl_table_no_const ipc_table;
73778
73779 memcpy(&ipc_table, table, sizeof(ipc_table));
73780 ipc_table.data = get_ipc(table);
73781 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
73782 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73783 void __user *buffer, size_t *lenp, loff_t *ppos)
73784 {
73785 - struct ctl_table ipc_table;
73786 + ctl_table_no_const ipc_table;
73787 size_t lenp_bef = *lenp;
73788 int rc;
73789
73790 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73791 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
73792 void __user *buffer, size_t *lenp, loff_t *ppos)
73793 {
73794 - struct ctl_table ipc_table;
73795 + ctl_table_no_const ipc_table;
73796 memcpy(&ipc_table, table, sizeof(ipc_table));
73797 ipc_table.data = get_ipc(table);
73798
73799 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
73800 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
73801 void __user *buffer, size_t *lenp, loff_t *ppos)
73802 {
73803 - struct ctl_table ipc_table;
73804 + ctl_table_no_const ipc_table;
73805 size_t lenp_bef = *lenp;
73806 int oldval;
73807 int rc;
73808 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
73809 index 383d638..943fdbb 100644
73810 --- a/ipc/mq_sysctl.c
73811 +++ b/ipc/mq_sysctl.c
73812 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
73813 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
73814 void __user *buffer, size_t *lenp, loff_t *ppos)
73815 {
73816 - struct ctl_table mq_table;
73817 + ctl_table_no_const mq_table;
73818 memcpy(&mq_table, table, sizeof(mq_table));
73819 mq_table.data = get_mq(table);
73820
73821 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
73822 index e4e47f6..a85e0ad 100644
73823 --- a/ipc/mqueue.c
73824 +++ b/ipc/mqueue.c
73825 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
73826 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
73827 info->attr.mq_msgsize);
73828
73829 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
73830 spin_lock(&mq_lock);
73831 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
73832 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
73833 diff --git a/ipc/msg.c b/ipc/msg.c
73834 index fede1d0..9778e0f8 100644
73835 --- a/ipc/msg.c
73836 +++ b/ipc/msg.c
73837 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
73838 return security_msg_queue_associate(msq, msgflg);
73839 }
73840
73841 +static struct ipc_ops msg_ops = {
73842 + .getnew = newque,
73843 + .associate = msg_security,
73844 + .more_checks = NULL
73845 +};
73846 +
73847 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
73848 {
73849 struct ipc_namespace *ns;
73850 - struct ipc_ops msg_ops;
73851 struct ipc_params msg_params;
73852
73853 ns = current->nsproxy->ipc_ns;
73854
73855 - msg_ops.getnew = newque;
73856 - msg_ops.associate = msg_security;
73857 - msg_ops.more_checks = NULL;
73858 -
73859 msg_params.key = key;
73860 msg_params.flg = msgflg;
73861
73862 diff --git a/ipc/sem.c b/ipc/sem.c
73863 index 58d31f1..cce7a55 100644
73864 --- a/ipc/sem.c
73865 +++ b/ipc/sem.c
73866 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
73867 return 0;
73868 }
73869
73870 +static struct ipc_ops sem_ops = {
73871 + .getnew = newary,
73872 + .associate = sem_security,
73873 + .more_checks = sem_more_checks
73874 +};
73875 +
73876 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73877 {
73878 struct ipc_namespace *ns;
73879 - struct ipc_ops sem_ops;
73880 struct ipc_params sem_params;
73881
73882 ns = current->nsproxy->ipc_ns;
73883 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73884 if (nsems < 0 || nsems > ns->sc_semmsl)
73885 return -EINVAL;
73886
73887 - sem_ops.getnew = newary;
73888 - sem_ops.associate = sem_security;
73889 - sem_ops.more_checks = sem_more_checks;
73890 -
73891 sem_params.key = key;
73892 sem_params.flg = semflg;
73893 sem_params.u.nsems = nsems;
73894 diff --git a/ipc/shm.c b/ipc/shm.c
73895 index 7e199fa..180a1ca 100644
73896 --- a/ipc/shm.c
73897 +++ b/ipc/shm.c
73898 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
73899 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
73900 #endif
73901
73902 +#ifdef CONFIG_GRKERNSEC
73903 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73904 + const time_t shm_createtime, const kuid_t cuid,
73905 + const int shmid);
73906 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73907 + const time_t shm_createtime);
73908 +#endif
73909 +
73910 void shm_init_ns(struct ipc_namespace *ns)
73911 {
73912 ns->shm_ctlmax = SHMMAX;
73913 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
73914 shp->shm_lprid = 0;
73915 shp->shm_atim = shp->shm_dtim = 0;
73916 shp->shm_ctim = get_seconds();
73917 +#ifdef CONFIG_GRKERNSEC
73918 + {
73919 + struct timespec timeval;
73920 + do_posix_clock_monotonic_gettime(&timeval);
73921 +
73922 + shp->shm_createtime = timeval.tv_sec;
73923 + }
73924 +#endif
73925 shp->shm_segsz = size;
73926 shp->shm_nattch = 0;
73927 shp->shm_file = file;
73928 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
73929 return 0;
73930 }
73931
73932 +static struct ipc_ops shm_ops = {
73933 + .getnew = newseg,
73934 + .associate = shm_security,
73935 + .more_checks = shm_more_checks
73936 +};
73937 +
73938 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
73939 {
73940 struct ipc_namespace *ns;
73941 - struct ipc_ops shm_ops;
73942 struct ipc_params shm_params;
73943
73944 ns = current->nsproxy->ipc_ns;
73945
73946 - shm_ops.getnew = newseg;
73947 - shm_ops.associate = shm_security;
73948 - shm_ops.more_checks = shm_more_checks;
73949 -
73950 shm_params.key = key;
73951 shm_params.flg = shmflg;
73952 shm_params.u.size = size;
73953 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73954 f_mode = FMODE_READ | FMODE_WRITE;
73955 }
73956 if (shmflg & SHM_EXEC) {
73957 +
73958 +#ifdef CONFIG_PAX_MPROTECT
73959 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
73960 + goto out;
73961 +#endif
73962 +
73963 prot |= PROT_EXEC;
73964 acc_mode |= S_IXUGO;
73965 }
73966 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73967 if (err)
73968 goto out_unlock;
73969
73970 +#ifdef CONFIG_GRKERNSEC
73971 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
73972 + shp->shm_perm.cuid, shmid) ||
73973 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
73974 + err = -EACCES;
73975 + goto out_unlock;
73976 + }
73977 +#endif
73978 +
73979 path = shp->shm_file->f_path;
73980 path_get(&path);
73981 shp->shm_nattch++;
73982 +#ifdef CONFIG_GRKERNSEC
73983 + shp->shm_lapid = current->pid;
73984 +#endif
73985 size = i_size_read(path.dentry->d_inode);
73986 shm_unlock(shp);
73987
73988 diff --git a/kernel/acct.c b/kernel/acct.c
73989 index b9bd7f0..1762b4a 100644
73990 --- a/kernel/acct.c
73991 +++ b/kernel/acct.c
73992 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
73993 */
73994 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
73995 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
73996 - file->f_op->write(file, (char *)&ac,
73997 + file->f_op->write(file, (char __force_user *)&ac,
73998 sizeof(acct_t), &file->f_pos);
73999 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74000 set_fs(fs);
74001 diff --git a/kernel/audit.c b/kernel/audit.c
74002 index d596e53..dbef3c3 100644
74003 --- a/kernel/audit.c
74004 +++ b/kernel/audit.c
74005 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74006 3) suppressed due to audit_rate_limit
74007 4) suppressed due to audit_backlog_limit
74008 */
74009 -static atomic_t audit_lost = ATOMIC_INIT(0);
74010 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74011
74012 /* The netlink socket. */
74013 static struct sock *audit_sock;
74014 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74015 unsigned long now;
74016 int print;
74017
74018 - atomic_inc(&audit_lost);
74019 + atomic_inc_unchecked(&audit_lost);
74020
74021 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74022
74023 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74024 printk(KERN_WARNING
74025 "audit: audit_lost=%d audit_rate_limit=%d "
74026 "audit_backlog_limit=%d\n",
74027 - atomic_read(&audit_lost),
74028 + atomic_read_unchecked(&audit_lost),
74029 audit_rate_limit,
74030 audit_backlog_limit);
74031 audit_panic(message);
74032 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74033 status_set.pid = audit_pid;
74034 status_set.rate_limit = audit_rate_limit;
74035 status_set.backlog_limit = audit_backlog_limit;
74036 - status_set.lost = atomic_read(&audit_lost);
74037 + status_set.lost = atomic_read_unchecked(&audit_lost);
74038 status_set.backlog = skb_queue_len(&audit_skb_queue);
74039 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74040 &status_set, sizeof(status_set));
74041 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74042 index c4b72b0..8654c4e 100644
74043 --- a/kernel/auditsc.c
74044 +++ b/kernel/auditsc.c
74045 @@ -2295,7 +2295,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74046 }
74047
74048 /* global counter which is incremented every time something logs in */
74049 -static atomic_t session_id = ATOMIC_INIT(0);
74050 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74051
74052 /**
74053 * audit_set_loginuid - set current task's audit_context loginuid
74054 @@ -2319,7 +2319,7 @@ int audit_set_loginuid(kuid_t loginuid)
74055 return -EPERM;
74056 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74057
74058 - sessionid = atomic_inc_return(&session_id);
74059 + sessionid = atomic_inc_return_unchecked(&session_id);
74060 if (context && context->in_syscall) {
74061 struct audit_buffer *ab;
74062
74063 diff --git a/kernel/capability.c b/kernel/capability.c
74064 index f6c2ce5..982c0f9 100644
74065 --- a/kernel/capability.c
74066 +++ b/kernel/capability.c
74067 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74068 * before modification is attempted and the application
74069 * fails.
74070 */
74071 + if (tocopy > ARRAY_SIZE(kdata))
74072 + return -EFAULT;
74073 +
74074 if (copy_to_user(dataptr, kdata, tocopy
74075 * sizeof(struct __user_cap_data_struct))) {
74076 return -EFAULT;
74077 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74078 int ret;
74079
74080 rcu_read_lock();
74081 - ret = security_capable(__task_cred(t), ns, cap);
74082 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74083 + gr_task_is_capable(t, __task_cred(t), cap);
74084 rcu_read_unlock();
74085
74086 - return (ret == 0);
74087 + return ret;
74088 }
74089
74090 /**
74091 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74092 int ret;
74093
74094 rcu_read_lock();
74095 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74096 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74097 rcu_read_unlock();
74098
74099 - return (ret == 0);
74100 + return ret;
74101 }
74102
74103 /**
74104 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74105 BUG();
74106 }
74107
74108 - if (security_capable(current_cred(), ns, cap) == 0) {
74109 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74110 current->flags |= PF_SUPERPRIV;
74111 return true;
74112 }
74113 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74114 }
74115 EXPORT_SYMBOL(ns_capable);
74116
74117 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74118 +{
74119 + if (unlikely(!cap_valid(cap))) {
74120 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74121 + BUG();
74122 + }
74123 +
74124 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74125 + current->flags |= PF_SUPERPRIV;
74126 + return true;
74127 + }
74128 + return false;
74129 +}
74130 +EXPORT_SYMBOL(ns_capable_nolog);
74131 +
74132 /**
74133 * file_ns_capable - Determine if the file's opener had a capability in effect
74134 * @file: The file we want to check
74135 @@ -432,6 +451,12 @@ bool capable(int cap)
74136 }
74137 EXPORT_SYMBOL(capable);
74138
74139 +bool capable_nolog(int cap)
74140 +{
74141 + return ns_capable_nolog(&init_user_ns, cap);
74142 +}
74143 +EXPORT_SYMBOL(capable_nolog);
74144 +
74145 /**
74146 * nsown_capable - Check superior capability to one's own user_ns
74147 * @cap: The capability in question
74148 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
74149
74150 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74151 }
74152 +
74153 +bool inode_capable_nolog(const struct inode *inode, int cap)
74154 +{
74155 + struct user_namespace *ns = current_user_ns();
74156 +
74157 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74158 +}
74159 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74160 index ba1f977..f840d9c 100644
74161 --- a/kernel/cgroup.c
74162 +++ b/kernel/cgroup.c
74163 @@ -5569,7 +5569,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74164 struct css_set *cg = link->cg;
74165 struct task_struct *task;
74166 int count = 0;
74167 - seq_printf(seq, "css_set %p\n", cg);
74168 + seq_printf(seq, "css_set %pK\n", cg);
74169 list_for_each_entry(task, &cg->tasks, cg_list) {
74170 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74171 seq_puts(seq, " ...\n");
74172 diff --git a/kernel/compat.c b/kernel/compat.c
74173 index 19971d8..02fe2df 100644
74174 --- a/kernel/compat.c
74175 +++ b/kernel/compat.c
74176 @@ -13,6 +13,7 @@
74177
74178 #include <linux/linkage.h>
74179 #include <linux/compat.h>
74180 +#include <linux/module.h>
74181 #include <linux/errno.h>
74182 #include <linux/time.h>
74183 #include <linux/signal.h>
74184 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74185 mm_segment_t oldfs;
74186 long ret;
74187
74188 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74189 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74190 oldfs = get_fs();
74191 set_fs(KERNEL_DS);
74192 ret = hrtimer_nanosleep_restart(restart);
74193 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74194 oldfs = get_fs();
74195 set_fs(KERNEL_DS);
74196 ret = hrtimer_nanosleep(&tu,
74197 - rmtp ? (struct timespec __user *)&rmt : NULL,
74198 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74199 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74200 set_fs(oldfs);
74201
74202 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74203 mm_segment_t old_fs = get_fs();
74204
74205 set_fs(KERNEL_DS);
74206 - ret = sys_sigpending((old_sigset_t __user *) &s);
74207 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74208 set_fs(old_fs);
74209 if (ret == 0)
74210 ret = put_user(s, set);
74211 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74212 mm_segment_t old_fs = get_fs();
74213
74214 set_fs(KERNEL_DS);
74215 - ret = sys_old_getrlimit(resource, &r);
74216 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74217 set_fs(old_fs);
74218
74219 if (!ret) {
74220 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74221 mm_segment_t old_fs = get_fs();
74222
74223 set_fs(KERNEL_DS);
74224 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74225 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74226 set_fs(old_fs);
74227
74228 if (ret)
74229 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74230 set_fs (KERNEL_DS);
74231 ret = sys_wait4(pid,
74232 (stat_addr ?
74233 - (unsigned int __user *) &status : NULL),
74234 - options, (struct rusage __user *) &r);
74235 + (unsigned int __force_user *) &status : NULL),
74236 + options, (struct rusage __force_user *) &r);
74237 set_fs (old_fs);
74238
74239 if (ret > 0) {
74240 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74241 memset(&info, 0, sizeof(info));
74242
74243 set_fs(KERNEL_DS);
74244 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74245 - uru ? (struct rusage __user *)&ru : NULL);
74246 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74247 + uru ? (struct rusage __force_user *)&ru : NULL);
74248 set_fs(old_fs);
74249
74250 if ((ret < 0) || (info.si_signo == 0))
74251 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74252 oldfs = get_fs();
74253 set_fs(KERNEL_DS);
74254 err = sys_timer_settime(timer_id, flags,
74255 - (struct itimerspec __user *) &newts,
74256 - (struct itimerspec __user *) &oldts);
74257 + (struct itimerspec __force_user *) &newts,
74258 + (struct itimerspec __force_user *) &oldts);
74259 set_fs(oldfs);
74260 if (!err && old && put_compat_itimerspec(old, &oldts))
74261 return -EFAULT;
74262 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74263 oldfs = get_fs();
74264 set_fs(KERNEL_DS);
74265 err = sys_timer_gettime(timer_id,
74266 - (struct itimerspec __user *) &ts);
74267 + (struct itimerspec __force_user *) &ts);
74268 set_fs(oldfs);
74269 if (!err && put_compat_itimerspec(setting, &ts))
74270 return -EFAULT;
74271 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74272 oldfs = get_fs();
74273 set_fs(KERNEL_DS);
74274 err = sys_clock_settime(which_clock,
74275 - (struct timespec __user *) &ts);
74276 + (struct timespec __force_user *) &ts);
74277 set_fs(oldfs);
74278 return err;
74279 }
74280 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74281 oldfs = get_fs();
74282 set_fs(KERNEL_DS);
74283 err = sys_clock_gettime(which_clock,
74284 - (struct timespec __user *) &ts);
74285 + (struct timespec __force_user *) &ts);
74286 set_fs(oldfs);
74287 if (!err && put_compat_timespec(&ts, tp))
74288 return -EFAULT;
74289 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74290
74291 oldfs = get_fs();
74292 set_fs(KERNEL_DS);
74293 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74294 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74295 set_fs(oldfs);
74296
74297 err = compat_put_timex(utp, &txc);
74298 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74299 oldfs = get_fs();
74300 set_fs(KERNEL_DS);
74301 err = sys_clock_getres(which_clock,
74302 - (struct timespec __user *) &ts);
74303 + (struct timespec __force_user *) &ts);
74304 set_fs(oldfs);
74305 if (!err && tp && put_compat_timespec(&ts, tp))
74306 return -EFAULT;
74307 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74308 long err;
74309 mm_segment_t oldfs;
74310 struct timespec tu;
74311 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74312 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74313
74314 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74315 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74316 oldfs = get_fs();
74317 set_fs(KERNEL_DS);
74318 err = clock_nanosleep_restart(restart);
74319 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74320 oldfs = get_fs();
74321 set_fs(KERNEL_DS);
74322 err = sys_clock_nanosleep(which_clock, flags,
74323 - (struct timespec __user *) &in,
74324 - (struct timespec __user *) &out);
74325 + (struct timespec __force_user *) &in,
74326 + (struct timespec __force_user *) &out);
74327 set_fs(oldfs);
74328
74329 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74330 diff --git a/kernel/configs.c b/kernel/configs.c
74331 index 42e8fa0..9e7406b 100644
74332 --- a/kernel/configs.c
74333 +++ b/kernel/configs.c
74334 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74335 struct proc_dir_entry *entry;
74336
74337 /* create the current config file */
74338 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74339 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74340 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74341 + &ikconfig_file_ops);
74342 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74343 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74344 + &ikconfig_file_ops);
74345 +#endif
74346 +#else
74347 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74348 &ikconfig_file_ops);
74349 +#endif
74350 +
74351 if (!entry)
74352 return -ENOMEM;
74353
74354 diff --git a/kernel/cred.c b/kernel/cred.c
74355 index e0573a4..3874e41 100644
74356 --- a/kernel/cred.c
74357 +++ b/kernel/cred.c
74358 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74359 validate_creds(cred);
74360 alter_cred_subscribers(cred, -1);
74361 put_cred(cred);
74362 +
74363 +#ifdef CONFIG_GRKERNSEC_SETXID
74364 + cred = (struct cred *) tsk->delayed_cred;
74365 + if (cred != NULL) {
74366 + tsk->delayed_cred = NULL;
74367 + validate_creds(cred);
74368 + alter_cred_subscribers(cred, -1);
74369 + put_cred(cred);
74370 + }
74371 +#endif
74372 }
74373
74374 /**
74375 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74376 * Always returns 0 thus allowing this function to be tail-called at the end
74377 * of, say, sys_setgid().
74378 */
74379 -int commit_creds(struct cred *new)
74380 +static int __commit_creds(struct cred *new)
74381 {
74382 struct task_struct *task = current;
74383 const struct cred *old = task->real_cred;
74384 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74385
74386 get_cred(new); /* we will require a ref for the subj creds too */
74387
74388 + gr_set_role_label(task, new->uid, new->gid);
74389 +
74390 /* dumpability changes */
74391 if (!uid_eq(old->euid, new->euid) ||
74392 !gid_eq(old->egid, new->egid) ||
74393 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74394 put_cred(old);
74395 return 0;
74396 }
74397 +#ifdef CONFIG_GRKERNSEC_SETXID
74398 +extern int set_user(struct cred *new);
74399 +
74400 +void gr_delayed_cred_worker(void)
74401 +{
74402 + const struct cred *new = current->delayed_cred;
74403 + struct cred *ncred;
74404 +
74405 + current->delayed_cred = NULL;
74406 +
74407 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74408 + // from doing get_cred on it when queueing this
74409 + put_cred(new);
74410 + return;
74411 + } else if (new == NULL)
74412 + return;
74413 +
74414 + ncred = prepare_creds();
74415 + if (!ncred)
74416 + goto die;
74417 + // uids
74418 + ncred->uid = new->uid;
74419 + ncred->euid = new->euid;
74420 + ncred->suid = new->suid;
74421 + ncred->fsuid = new->fsuid;
74422 + // gids
74423 + ncred->gid = new->gid;
74424 + ncred->egid = new->egid;
74425 + ncred->sgid = new->sgid;
74426 + ncred->fsgid = new->fsgid;
74427 + // groups
74428 + if (set_groups(ncred, new->group_info) < 0) {
74429 + abort_creds(ncred);
74430 + goto die;
74431 + }
74432 + // caps
74433 + ncred->securebits = new->securebits;
74434 + ncred->cap_inheritable = new->cap_inheritable;
74435 + ncred->cap_permitted = new->cap_permitted;
74436 + ncred->cap_effective = new->cap_effective;
74437 + ncred->cap_bset = new->cap_bset;
74438 +
74439 + if (set_user(ncred)) {
74440 + abort_creds(ncred);
74441 + goto die;
74442 + }
74443 +
74444 + // from doing get_cred on it when queueing this
74445 + put_cred(new);
74446 +
74447 + __commit_creds(ncred);
74448 + return;
74449 +die:
74450 + // from doing get_cred on it when queueing this
74451 + put_cred(new);
74452 + do_group_exit(SIGKILL);
74453 +}
74454 +#endif
74455 +
74456 +int commit_creds(struct cred *new)
74457 +{
74458 +#ifdef CONFIG_GRKERNSEC_SETXID
74459 + int ret;
74460 + int schedule_it = 0;
74461 + struct task_struct *t;
74462 +
74463 + /* we won't get called with tasklist_lock held for writing
74464 + and interrupts disabled as the cred struct in that case is
74465 + init_cred
74466 + */
74467 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74468 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74469 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74470 + schedule_it = 1;
74471 + }
74472 + ret = __commit_creds(new);
74473 + if (schedule_it) {
74474 + rcu_read_lock();
74475 + read_lock(&tasklist_lock);
74476 + for (t = next_thread(current); t != current;
74477 + t = next_thread(t)) {
74478 + if (t->delayed_cred == NULL) {
74479 + t->delayed_cred = get_cred(new);
74480 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74481 + set_tsk_need_resched(t);
74482 + }
74483 + }
74484 + read_unlock(&tasklist_lock);
74485 + rcu_read_unlock();
74486 + }
74487 + return ret;
74488 +#else
74489 + return __commit_creds(new);
74490 +#endif
74491 +}
74492 +
74493 EXPORT_SYMBOL(commit_creds);
74494
74495 /**
74496 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
74497 index c26278f..e323fb8 100644
74498 --- a/kernel/debug/debug_core.c
74499 +++ b/kernel/debug/debug_core.c
74500 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
74501 */
74502 static atomic_t masters_in_kgdb;
74503 static atomic_t slaves_in_kgdb;
74504 -static atomic_t kgdb_break_tasklet_var;
74505 +static atomic_unchecked_t kgdb_break_tasklet_var;
74506 atomic_t kgdb_setting_breakpoint;
74507
74508 struct task_struct *kgdb_usethread;
74509 @@ -133,7 +133,7 @@ int kgdb_single_step;
74510 static pid_t kgdb_sstep_pid;
74511
74512 /* to keep track of the CPU which is doing the single stepping*/
74513 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74514 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74515
74516 /*
74517 * If you are debugging a problem where roundup (the collection of
74518 @@ -541,7 +541,7 @@ return_normal:
74519 * kernel will only try for the value of sstep_tries before
74520 * giving up and continuing on.
74521 */
74522 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
74523 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
74524 (kgdb_info[cpu].task &&
74525 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
74526 atomic_set(&kgdb_active, -1);
74527 @@ -635,8 +635,8 @@ cpu_master_loop:
74528 }
74529
74530 kgdb_restore:
74531 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
74532 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
74533 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
74534 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
74535 if (kgdb_info[sstep_cpu].task)
74536 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
74537 else
74538 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
74539 static void kgdb_tasklet_bpt(unsigned long ing)
74540 {
74541 kgdb_breakpoint();
74542 - atomic_set(&kgdb_break_tasklet_var, 0);
74543 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
74544 }
74545
74546 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
74547
74548 void kgdb_schedule_breakpoint(void)
74549 {
74550 - if (atomic_read(&kgdb_break_tasklet_var) ||
74551 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
74552 atomic_read(&kgdb_active) != -1 ||
74553 atomic_read(&kgdb_setting_breakpoint))
74554 return;
74555 - atomic_inc(&kgdb_break_tasklet_var);
74556 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
74557 tasklet_schedule(&kgdb_tasklet_breakpoint);
74558 }
74559 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
74560 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
74561 index 00eb8f7..d7e3244 100644
74562 --- a/kernel/debug/kdb/kdb_main.c
74563 +++ b/kernel/debug/kdb/kdb_main.c
74564 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
74565 continue;
74566
74567 kdb_printf("%-20s%8u 0x%p ", mod->name,
74568 - mod->core_size, (void *)mod);
74569 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
74570 #ifdef CONFIG_MODULE_UNLOAD
74571 kdb_printf("%4ld ", module_refcount(mod));
74572 #endif
74573 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
74574 kdb_printf(" (Loading)");
74575 else
74576 kdb_printf(" (Live)");
74577 - kdb_printf(" 0x%p", mod->module_core);
74578 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
74579
74580 #ifdef CONFIG_MODULE_UNLOAD
74581 {
74582 diff --git a/kernel/events/core.c b/kernel/events/core.c
74583 index 9fcb094..fd68c54 100644
74584 --- a/kernel/events/core.c
74585 +++ b/kernel/events/core.c
74586 @@ -155,7 +155,11 @@ static struct srcu_struct pmus_srcu;
74587 * 1 - disallow cpu events for unpriv
74588 * 2 - disallow kernel profiling for unpriv
74589 */
74590 -int sysctl_perf_event_paranoid __read_mostly = 1;
74591 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74592 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
74593 +#else
74594 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
74595 +#endif
74596
74597 /* Minimum for 512 kiB + 1 user control page */
74598 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
74599 @@ -182,7 +186,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
74600 return 0;
74601 }
74602
74603 -static atomic64_t perf_event_id;
74604 +static atomic64_unchecked_t perf_event_id;
74605
74606 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
74607 enum event_type_t event_type);
74608 @@ -2677,7 +2681,7 @@ static void __perf_event_read(void *info)
74609
74610 static inline u64 perf_event_count(struct perf_event *event)
74611 {
74612 - return local64_read(&event->count) + atomic64_read(&event->child_count);
74613 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
74614 }
74615
74616 static u64 perf_event_read(struct perf_event *event)
74617 @@ -3007,9 +3011,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
74618 mutex_lock(&event->child_mutex);
74619 total += perf_event_read(event);
74620 *enabled += event->total_time_enabled +
74621 - atomic64_read(&event->child_total_time_enabled);
74622 + atomic64_read_unchecked(&event->child_total_time_enabled);
74623 *running += event->total_time_running +
74624 - atomic64_read(&event->child_total_time_running);
74625 + atomic64_read_unchecked(&event->child_total_time_running);
74626
74627 list_for_each_entry(child, &event->child_list, child_list) {
74628 total += perf_event_read(child);
74629 @@ -3412,10 +3416,10 @@ void perf_event_update_userpage(struct perf_event *event)
74630 userpg->offset -= local64_read(&event->hw.prev_count);
74631
74632 userpg->time_enabled = enabled +
74633 - atomic64_read(&event->child_total_time_enabled);
74634 + atomic64_read_unchecked(&event->child_total_time_enabled);
74635
74636 userpg->time_running = running +
74637 - atomic64_read(&event->child_total_time_running);
74638 + atomic64_read_unchecked(&event->child_total_time_running);
74639
74640 arch_perf_update_userpage(userpg, now);
74641
74642 @@ -3886,7 +3890,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
74643
74644 /* Data. */
74645 sp = perf_user_stack_pointer(regs);
74646 - rem = __output_copy_user(handle, (void *) sp, dump_size);
74647 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
74648 dyn_size = dump_size - rem;
74649
74650 perf_output_skip(handle, rem);
74651 @@ -3974,11 +3978,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
74652 values[n++] = perf_event_count(event);
74653 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
74654 values[n++] = enabled +
74655 - atomic64_read(&event->child_total_time_enabled);
74656 + atomic64_read_unchecked(&event->child_total_time_enabled);
74657 }
74658 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
74659 values[n++] = running +
74660 - atomic64_read(&event->child_total_time_running);
74661 + atomic64_read_unchecked(&event->child_total_time_running);
74662 }
74663 if (read_format & PERF_FORMAT_ID)
74664 values[n++] = primary_event_id(event);
74665 @@ -4726,12 +4730,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
74666 * need to add enough zero bytes after the string to handle
74667 * the 64bit alignment we do later.
74668 */
74669 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
74670 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
74671 if (!buf) {
74672 name = strncpy(tmp, "//enomem", sizeof(tmp));
74673 goto got_name;
74674 }
74675 - name = d_path(&file->f_path, buf, PATH_MAX);
74676 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
74677 if (IS_ERR(name)) {
74678 name = strncpy(tmp, "//toolong", sizeof(tmp));
74679 goto got_name;
74680 @@ -6167,7 +6171,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
74681 event->parent = parent_event;
74682
74683 event->ns = get_pid_ns(task_active_pid_ns(current));
74684 - event->id = atomic64_inc_return(&perf_event_id);
74685 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
74686
74687 event->state = PERF_EVENT_STATE_INACTIVE;
74688
74689 @@ -6795,10 +6799,10 @@ static void sync_child_event(struct perf_event *child_event,
74690 /*
74691 * Add back the child's count to the parent's count:
74692 */
74693 - atomic64_add(child_val, &parent_event->child_count);
74694 - atomic64_add(child_event->total_time_enabled,
74695 + atomic64_add_unchecked(child_val, &parent_event->child_count);
74696 + atomic64_add_unchecked(child_event->total_time_enabled,
74697 &parent_event->child_total_time_enabled);
74698 - atomic64_add(child_event->total_time_running,
74699 + atomic64_add_unchecked(child_event->total_time_running,
74700 &parent_event->child_total_time_running);
74701
74702 /*
74703 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
74704 index eb675c4..54912ff 100644
74705 --- a/kernel/events/internal.h
74706 +++ b/kernel/events/internal.h
74707 @@ -77,10 +77,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
74708 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
74709 }
74710
74711 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
74712 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
74713 static inline unsigned int \
74714 func_name(struct perf_output_handle *handle, \
74715 - const void *buf, unsigned int len) \
74716 + const void user *buf, unsigned int len) \
74717 { \
74718 unsigned long size, written; \
74719 \
74720 @@ -112,17 +112,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
74721 return n;
74722 }
74723
74724 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
74725 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
74726
74727 #define MEMCPY_SKIP(dst, src, n) (n)
74728
74729 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
74730 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
74731
74732 #ifndef arch_perf_out_copy_user
74733 #define arch_perf_out_copy_user __copy_from_user_inatomic
74734 #endif
74735
74736 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
74737 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
74738
74739 /* Callchain handling */
74740 extern struct perf_callchain_entry *
74741 diff --git a/kernel/exit.c b/kernel/exit.c
74742 index 60bc027..ca6d727 100644
74743 --- a/kernel/exit.c
74744 +++ b/kernel/exit.c
74745 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
74746 struct task_struct *leader;
74747 int zap_leader;
74748 repeat:
74749 +#ifdef CONFIG_NET
74750 + gr_del_task_from_ip_table(p);
74751 +#endif
74752 +
74753 /* don't need to get the RCU readlock here - the process is dead and
74754 * can't be modifying its own credentials. But shut RCU-lockdep up */
74755 rcu_read_lock();
74756 @@ -340,7 +344,7 @@ int allow_signal(int sig)
74757 * know it'll be handled, so that they don't get converted to
74758 * SIGKILL or just silently dropped.
74759 */
74760 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
74761 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
74762 recalc_sigpending();
74763 spin_unlock_irq(&current->sighand->siglock);
74764 return 0;
74765 @@ -710,6 +714,8 @@ void do_exit(long code)
74766 struct task_struct *tsk = current;
74767 int group_dead;
74768
74769 + set_fs(USER_DS);
74770 +
74771 profile_task_exit(tsk);
74772
74773 WARN_ON(blk_needs_flush_plug(tsk));
74774 @@ -726,7 +732,6 @@ void do_exit(long code)
74775 * mm_release()->clear_child_tid() from writing to a user-controlled
74776 * kernel address.
74777 */
74778 - set_fs(USER_DS);
74779
74780 ptrace_event(PTRACE_EVENT_EXIT, code);
74781
74782 @@ -785,6 +790,9 @@ void do_exit(long code)
74783 tsk->exit_code = code;
74784 taskstats_exit(tsk, group_dead);
74785
74786 + gr_acl_handle_psacct(tsk, code);
74787 + gr_acl_handle_exit();
74788 +
74789 exit_mm(tsk);
74790
74791 if (group_dead)
74792 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
74793 * Take down every thread in the group. This is called by fatal signals
74794 * as well as by sys_exit_group (below).
74795 */
74796 -void
74797 +__noreturn void
74798 do_group_exit(int exit_code)
74799 {
74800 struct signal_struct *sig = current->signal;
74801 diff --git a/kernel/fork.c b/kernel/fork.c
74802 index 1766d32..c0e44e2 100644
74803 --- a/kernel/fork.c
74804 +++ b/kernel/fork.c
74805 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
74806 *stackend = STACK_END_MAGIC; /* for overflow detection */
74807
74808 #ifdef CONFIG_CC_STACKPROTECTOR
74809 - tsk->stack_canary = get_random_int();
74810 + tsk->stack_canary = pax_get_random_long();
74811 #endif
74812
74813 /*
74814 @@ -344,13 +344,81 @@ free_tsk:
74815 }
74816
74817 #ifdef CONFIG_MMU
74818 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
74819 +{
74820 + struct vm_area_struct *tmp;
74821 + unsigned long charge;
74822 + struct mempolicy *pol;
74823 + struct file *file;
74824 +
74825 + charge = 0;
74826 + if (mpnt->vm_flags & VM_ACCOUNT) {
74827 + unsigned long len = vma_pages(mpnt);
74828 +
74829 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74830 + goto fail_nomem;
74831 + charge = len;
74832 + }
74833 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74834 + if (!tmp)
74835 + goto fail_nomem;
74836 + *tmp = *mpnt;
74837 + tmp->vm_mm = mm;
74838 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
74839 + pol = mpol_dup(vma_policy(mpnt));
74840 + if (IS_ERR(pol))
74841 + goto fail_nomem_policy;
74842 + vma_set_policy(tmp, pol);
74843 + if (anon_vma_fork(tmp, mpnt))
74844 + goto fail_nomem_anon_vma_fork;
74845 + tmp->vm_flags &= ~VM_LOCKED;
74846 + tmp->vm_next = tmp->vm_prev = NULL;
74847 + tmp->vm_mirror = NULL;
74848 + file = tmp->vm_file;
74849 + if (file) {
74850 + struct inode *inode = file_inode(file);
74851 + struct address_space *mapping = file->f_mapping;
74852 +
74853 + get_file(file);
74854 + if (tmp->vm_flags & VM_DENYWRITE)
74855 + atomic_dec(&inode->i_writecount);
74856 + mutex_lock(&mapping->i_mmap_mutex);
74857 + if (tmp->vm_flags & VM_SHARED)
74858 + mapping->i_mmap_writable++;
74859 + flush_dcache_mmap_lock(mapping);
74860 + /* insert tmp into the share list, just after mpnt */
74861 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74862 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
74863 + else
74864 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
74865 + flush_dcache_mmap_unlock(mapping);
74866 + mutex_unlock(&mapping->i_mmap_mutex);
74867 + }
74868 +
74869 + /*
74870 + * Clear hugetlb-related page reserves for children. This only
74871 + * affects MAP_PRIVATE mappings. Faults generated by the child
74872 + * are not guaranteed to succeed, even if read-only
74873 + */
74874 + if (is_vm_hugetlb_page(tmp))
74875 + reset_vma_resv_huge_pages(tmp);
74876 +
74877 + return tmp;
74878 +
74879 +fail_nomem_anon_vma_fork:
74880 + mpol_put(pol);
74881 +fail_nomem_policy:
74882 + kmem_cache_free(vm_area_cachep, tmp);
74883 +fail_nomem:
74884 + vm_unacct_memory(charge);
74885 + return NULL;
74886 +}
74887 +
74888 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74889 {
74890 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
74891 struct rb_node **rb_link, *rb_parent;
74892 int retval;
74893 - unsigned long charge;
74894 - struct mempolicy *pol;
74895
74896 uprobe_start_dup_mmap();
74897 down_write(&oldmm->mmap_sem);
74898 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74899 mm->locked_vm = 0;
74900 mm->mmap = NULL;
74901 mm->mmap_cache = NULL;
74902 - mm->free_area_cache = oldmm->mmap_base;
74903 - mm->cached_hole_size = ~0UL;
74904 + mm->free_area_cache = oldmm->free_area_cache;
74905 + mm->cached_hole_size = oldmm->cached_hole_size;
74906 mm->map_count = 0;
74907 cpumask_clear(mm_cpumask(mm));
74908 mm->mm_rb = RB_ROOT;
74909 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74910
74911 prev = NULL;
74912 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
74913 - struct file *file;
74914 -
74915 if (mpnt->vm_flags & VM_DONTCOPY) {
74916 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
74917 -vma_pages(mpnt));
74918 continue;
74919 }
74920 - charge = 0;
74921 - if (mpnt->vm_flags & VM_ACCOUNT) {
74922 - unsigned long len = vma_pages(mpnt);
74923 -
74924 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74925 - goto fail_nomem;
74926 - charge = len;
74927 - }
74928 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74929 - if (!tmp)
74930 - goto fail_nomem;
74931 - *tmp = *mpnt;
74932 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
74933 - pol = mpol_dup(vma_policy(mpnt));
74934 - retval = PTR_ERR(pol);
74935 - if (IS_ERR(pol))
74936 - goto fail_nomem_policy;
74937 - vma_set_policy(tmp, pol);
74938 - tmp->vm_mm = mm;
74939 - if (anon_vma_fork(tmp, mpnt))
74940 - goto fail_nomem_anon_vma_fork;
74941 - tmp->vm_flags &= ~VM_LOCKED;
74942 - tmp->vm_next = tmp->vm_prev = NULL;
74943 - file = tmp->vm_file;
74944 - if (file) {
74945 - struct inode *inode = file_inode(file);
74946 - struct address_space *mapping = file->f_mapping;
74947 -
74948 - get_file(file);
74949 - if (tmp->vm_flags & VM_DENYWRITE)
74950 - atomic_dec(&inode->i_writecount);
74951 - mutex_lock(&mapping->i_mmap_mutex);
74952 - if (tmp->vm_flags & VM_SHARED)
74953 - mapping->i_mmap_writable++;
74954 - flush_dcache_mmap_lock(mapping);
74955 - /* insert tmp into the share list, just after mpnt */
74956 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74957 - vma_nonlinear_insert(tmp,
74958 - &mapping->i_mmap_nonlinear);
74959 - else
74960 - vma_interval_tree_insert_after(tmp, mpnt,
74961 - &mapping->i_mmap);
74962 - flush_dcache_mmap_unlock(mapping);
74963 - mutex_unlock(&mapping->i_mmap_mutex);
74964 + tmp = dup_vma(mm, oldmm, mpnt);
74965 + if (!tmp) {
74966 + retval = -ENOMEM;
74967 + goto out;
74968 }
74969
74970 /*
74971 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74972 if (retval)
74973 goto out;
74974 }
74975 +
74976 +#ifdef CONFIG_PAX_SEGMEXEC
74977 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
74978 + struct vm_area_struct *mpnt_m;
74979 +
74980 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
74981 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
74982 +
74983 + if (!mpnt->vm_mirror)
74984 + continue;
74985 +
74986 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
74987 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
74988 + mpnt->vm_mirror = mpnt_m;
74989 + } else {
74990 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
74991 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
74992 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
74993 + mpnt->vm_mirror->vm_mirror = mpnt;
74994 + }
74995 + }
74996 + BUG_ON(mpnt_m);
74997 + }
74998 +#endif
74999 +
75000 /* a new mm has just been created */
75001 arch_dup_mmap(oldmm, mm);
75002 retval = 0;
75003 @@ -472,14 +523,6 @@ out:
75004 up_write(&oldmm->mmap_sem);
75005 uprobe_end_dup_mmap();
75006 return retval;
75007 -fail_nomem_anon_vma_fork:
75008 - mpol_put(pol);
75009 -fail_nomem_policy:
75010 - kmem_cache_free(vm_area_cachep, tmp);
75011 -fail_nomem:
75012 - retval = -ENOMEM;
75013 - vm_unacct_memory(charge);
75014 - goto out;
75015 }
75016
75017 static inline int mm_alloc_pgd(struct mm_struct *mm)
75018 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75019 return ERR_PTR(err);
75020
75021 mm = get_task_mm(task);
75022 - if (mm && mm != current->mm &&
75023 - !ptrace_may_access(task, mode)) {
75024 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75025 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75026 mmput(mm);
75027 mm = ERR_PTR(-EACCES);
75028 }
75029 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75030 spin_unlock(&fs->lock);
75031 return -EAGAIN;
75032 }
75033 - fs->users++;
75034 + atomic_inc(&fs->users);
75035 spin_unlock(&fs->lock);
75036 return 0;
75037 }
75038 tsk->fs = copy_fs_struct(fs);
75039 if (!tsk->fs)
75040 return -ENOMEM;
75041 + /* Carry through gr_chroot_dentry and is_chrooted instead
75042 + of recomputing it here. Already copied when the task struct
75043 + is duplicated. This allows pivot_root to not be treated as
75044 + a chroot
75045 + */
75046 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75047 +
75048 return 0;
75049 }
75050
75051 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75052 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75053 #endif
75054 retval = -EAGAIN;
75055 +
75056 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75057 +
75058 if (atomic_read(&p->real_cred->user->processes) >=
75059 task_rlimit(p, RLIMIT_NPROC)) {
75060 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75061 @@ -1441,6 +1494,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75062 goto bad_fork_free_pid;
75063 }
75064
75065 + /* synchronizes with gr_set_acls()
75066 + we need to call this past the point of no return for fork()
75067 + */
75068 + gr_copy_label(p);
75069 +
75070 if (clone_flags & CLONE_THREAD) {
75071 current->signal->nr_threads++;
75072 atomic_inc(&current->signal->live);
75073 @@ -1524,6 +1582,8 @@ bad_fork_cleanup_count:
75074 bad_fork_free:
75075 free_task(p);
75076 fork_out:
75077 + gr_log_forkfail(retval);
75078 +
75079 return ERR_PTR(retval);
75080 }
75081
75082 @@ -1574,6 +1634,23 @@ long do_fork(unsigned long clone_flags,
75083 return -EINVAL;
75084 }
75085
75086 +#ifdef CONFIG_GRKERNSEC
75087 + if (clone_flags & CLONE_NEWUSER) {
75088 + /*
75089 + * This doesn't really inspire confidence:
75090 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75091 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75092 + * Increases kernel attack surface in areas developers
75093 + * previously cared little about ("low importance due
75094 + * to requiring "root" capability")
75095 + * To be removed when this code receives *proper* review
75096 + */
75097 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75098 + !capable(CAP_SETGID))
75099 + return -EPERM;
75100 + }
75101 +#endif
75102 +
75103 /*
75104 * Determine whether and which event to report to ptracer. When
75105 * called from kernel_thread or CLONE_UNTRACED is explicitly
75106 @@ -1608,6 +1685,8 @@ long do_fork(unsigned long clone_flags,
75107 if (clone_flags & CLONE_PARENT_SETTID)
75108 put_user(nr, parent_tidptr);
75109
75110 + gr_handle_brute_check();
75111 +
75112 if (clone_flags & CLONE_VFORK) {
75113 p->vfork_done = &vfork;
75114 init_completion(&vfork);
75115 @@ -1761,7 +1840,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75116 return 0;
75117
75118 /* don't need lock here; in the worst case we'll do useless copy */
75119 - if (fs->users == 1)
75120 + if (atomic_read(&fs->users) == 1)
75121 return 0;
75122
75123 *new_fsp = copy_fs_struct(fs);
75124 @@ -1873,7 +1952,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75125 fs = current->fs;
75126 spin_lock(&fs->lock);
75127 current->fs = new_fs;
75128 - if (--fs->users)
75129 + gr_set_chroot_entries(current, &current->fs->root);
75130 + if (atomic_dec_return(&fs->users))
75131 new_fs = NULL;
75132 else
75133 new_fs = fs;
75134 diff --git a/kernel/futex.c b/kernel/futex.c
75135 index b26dcfc..39e266a 100644
75136 --- a/kernel/futex.c
75137 +++ b/kernel/futex.c
75138 @@ -54,6 +54,7 @@
75139 #include <linux/mount.h>
75140 #include <linux/pagemap.h>
75141 #include <linux/syscalls.h>
75142 +#include <linux/ptrace.h>
75143 #include <linux/signal.h>
75144 #include <linux/export.h>
75145 #include <linux/magic.h>
75146 @@ -241,6 +242,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75147 struct page *page, *page_head;
75148 int err, ro = 0;
75149
75150 +#ifdef CONFIG_PAX_SEGMEXEC
75151 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75152 + return -EFAULT;
75153 +#endif
75154 +
75155 /*
75156 * The futex address must be "naturally" aligned.
75157 */
75158 @@ -2732,6 +2738,7 @@ static int __init futex_init(void)
75159 {
75160 u32 curval;
75161 int i;
75162 + mm_segment_t oldfs;
75163
75164 /*
75165 * This will fail and we want it. Some arch implementations do
75166 @@ -2743,8 +2750,11 @@ static int __init futex_init(void)
75167 * implementation, the non-functional ones will return
75168 * -ENOSYS.
75169 */
75170 + oldfs = get_fs();
75171 + set_fs(USER_DS);
75172 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75173 futex_cmpxchg_enabled = 1;
75174 + set_fs(oldfs);
75175
75176 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75177 plist_head_init(&futex_queues[i].chain);
75178 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75179 index f9f44fd..29885e4 100644
75180 --- a/kernel/futex_compat.c
75181 +++ b/kernel/futex_compat.c
75182 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75183 return 0;
75184 }
75185
75186 -static void __user *futex_uaddr(struct robust_list __user *entry,
75187 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75188 compat_long_t futex_offset)
75189 {
75190 compat_uptr_t base = ptr_to_compat(entry);
75191 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75192 index 9b22d03..6295b62 100644
75193 --- a/kernel/gcov/base.c
75194 +++ b/kernel/gcov/base.c
75195 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75196 }
75197
75198 #ifdef CONFIG_MODULES
75199 -static inline int within(void *addr, void *start, unsigned long size)
75200 -{
75201 - return ((addr >= start) && (addr < start + size));
75202 -}
75203 -
75204 /* Update list and generate events when modules are unloaded. */
75205 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75206 void *data)
75207 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75208 prev = NULL;
75209 /* Remove entries located in module from linked list. */
75210 for (info = gcov_info_head; info; info = info->next) {
75211 - if (within(info, mod->module_core, mod->core_size)) {
75212 + if (within_module_core_rw((unsigned long)info, mod)) {
75213 if (prev)
75214 prev->next = info->next;
75215 else
75216 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75217 index 7ef5556..8247f11 100644
75218 --- a/kernel/hrtimer.c
75219 +++ b/kernel/hrtimer.c
75220 @@ -1416,7 +1416,7 @@ void hrtimer_peek_ahead_timers(void)
75221 local_irq_restore(flags);
75222 }
75223
75224 -static void run_hrtimer_softirq(struct softirq_action *h)
75225 +static void run_hrtimer_softirq(void)
75226 {
75227 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75228
75229 @@ -1758,7 +1758,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75230 return NOTIFY_OK;
75231 }
75232
75233 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75234 +static struct notifier_block hrtimers_nb = {
75235 .notifier_call = hrtimer_cpu_notify,
75236 };
75237
75238 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
75239 index 55fcce6..0e4cf34 100644
75240 --- a/kernel/irq_work.c
75241 +++ b/kernel/irq_work.c
75242 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
75243 return NOTIFY_OK;
75244 }
75245
75246 -static struct notifier_block cpu_notify;
75247 +static struct notifier_block cpu_notify = {
75248 + .notifier_call = irq_work_cpu_notify,
75249 + .priority = 0,
75250 +};
75251
75252 static __init int irq_work_init_cpu_notifier(void)
75253 {
75254 - cpu_notify.notifier_call = irq_work_cpu_notify;
75255 - cpu_notify.priority = 0;
75256 register_cpu_notifier(&cpu_notify);
75257 return 0;
75258 }
75259 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75260 index 60f48fa..7f3a770 100644
75261 --- a/kernel/jump_label.c
75262 +++ b/kernel/jump_label.c
75263 @@ -13,6 +13,7 @@
75264 #include <linux/sort.h>
75265 #include <linux/err.h>
75266 #include <linux/static_key.h>
75267 +#include <linux/mm.h>
75268
75269 #ifdef HAVE_JUMP_LABEL
75270
75271 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75272
75273 size = (((unsigned long)stop - (unsigned long)start)
75274 / sizeof(struct jump_entry));
75275 + pax_open_kernel();
75276 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75277 + pax_close_kernel();
75278 }
75279
75280 static void jump_label_update(struct static_key *key, int enable);
75281 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75282 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75283 struct jump_entry *iter;
75284
75285 + pax_open_kernel();
75286 for (iter = iter_start; iter < iter_stop; iter++) {
75287 if (within_module_init(iter->code, mod))
75288 iter->code = 0;
75289 }
75290 + pax_close_kernel();
75291 }
75292
75293 static int
75294 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75295 index 2169fee..706ccca 100644
75296 --- a/kernel/kallsyms.c
75297 +++ b/kernel/kallsyms.c
75298 @@ -11,6 +11,9 @@
75299 * Changed the compression method from stem compression to "table lookup"
75300 * compression (see scripts/kallsyms.c for a more complete description)
75301 */
75302 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75303 +#define __INCLUDED_BY_HIDESYM 1
75304 +#endif
75305 #include <linux/kallsyms.h>
75306 #include <linux/module.h>
75307 #include <linux/init.h>
75308 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75309
75310 static inline int is_kernel_inittext(unsigned long addr)
75311 {
75312 + if (system_state != SYSTEM_BOOTING)
75313 + return 0;
75314 +
75315 if (addr >= (unsigned long)_sinittext
75316 && addr <= (unsigned long)_einittext)
75317 return 1;
75318 return 0;
75319 }
75320
75321 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75322 +#ifdef CONFIG_MODULES
75323 +static inline int is_module_text(unsigned long addr)
75324 +{
75325 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75326 + return 1;
75327 +
75328 + addr = ktla_ktva(addr);
75329 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75330 +}
75331 +#else
75332 +static inline int is_module_text(unsigned long addr)
75333 +{
75334 + return 0;
75335 +}
75336 +#endif
75337 +#endif
75338 +
75339 static inline int is_kernel_text(unsigned long addr)
75340 {
75341 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75342 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75343
75344 static inline int is_kernel(unsigned long addr)
75345 {
75346 +
75347 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75348 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75349 + return 1;
75350 +
75351 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75352 +#else
75353 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75354 +#endif
75355 +
75356 return 1;
75357 return in_gate_area_no_mm(addr);
75358 }
75359
75360 static int is_ksym_addr(unsigned long addr)
75361 {
75362 +
75363 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75364 + if (is_module_text(addr))
75365 + return 0;
75366 +#endif
75367 +
75368 if (all_var)
75369 return is_kernel(addr);
75370
75371 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75372
75373 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75374 {
75375 - iter->name[0] = '\0';
75376 iter->nameoff = get_symbol_offset(new_pos);
75377 iter->pos = new_pos;
75378 }
75379 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75380 {
75381 struct kallsym_iter *iter = m->private;
75382
75383 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75384 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75385 + return 0;
75386 +#endif
75387 +
75388 /* Some debugging symbols have no name. Ignore them. */
75389 if (!iter->name[0])
75390 return 0;
75391 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75392 */
75393 type = iter->exported ? toupper(iter->type) :
75394 tolower(iter->type);
75395 +
75396 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75397 type, iter->name, iter->module_name);
75398 } else
75399 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75400 struct kallsym_iter *iter;
75401 int ret;
75402
75403 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75404 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75405 if (!iter)
75406 return -ENOMEM;
75407 reset_iter(iter, 0);
75408 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75409 index e30ac0f..3528cac 100644
75410 --- a/kernel/kcmp.c
75411 +++ b/kernel/kcmp.c
75412 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75413 struct task_struct *task1, *task2;
75414 int ret;
75415
75416 +#ifdef CONFIG_GRKERNSEC
75417 + return -ENOSYS;
75418 +#endif
75419 +
75420 rcu_read_lock();
75421
75422 /*
75423 diff --git a/kernel/kexec.c b/kernel/kexec.c
75424 index ffd4e11..c3ff6bf 100644
75425 --- a/kernel/kexec.c
75426 +++ b/kernel/kexec.c
75427 @@ -1048,7 +1048,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75428 unsigned long flags)
75429 {
75430 struct compat_kexec_segment in;
75431 - struct kexec_segment out, __user *ksegments;
75432 + struct kexec_segment out;
75433 + struct kexec_segment __user *ksegments;
75434 unsigned long i, result;
75435
75436 /* Don't allow clients that don't understand the native
75437 diff --git a/kernel/kmod.c b/kernel/kmod.c
75438 index 8985c87..f539dbe 100644
75439 --- a/kernel/kmod.c
75440 +++ b/kernel/kmod.c
75441 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
75442 kfree(info->argv);
75443 }
75444
75445 -static int call_modprobe(char *module_name, int wait)
75446 +static int call_modprobe(char *module_name, char *module_param, int wait)
75447 {
75448 static char *envp[] = {
75449 "HOME=/",
75450 @@ -84,7 +84,7 @@ static int call_modprobe(char *module_name, int wait)
75451 NULL
75452 };
75453
75454 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
75455 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
75456 if (!argv)
75457 goto out;
75458
75459 @@ -96,7 +96,8 @@ static int call_modprobe(char *module_name, int wait)
75460 argv[1] = "-q";
75461 argv[2] = "--";
75462 argv[3] = module_name; /* check free_modprobe_argv() */
75463 - argv[4] = NULL;
75464 + argv[4] = module_param;
75465 + argv[5] = NULL;
75466
75467 return call_usermodehelper_fns(modprobe_path, argv, envp,
75468 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
75469 @@ -121,9 +122,8 @@ out:
75470 * If module auto-loading support is disabled then this function
75471 * becomes a no-operation.
75472 */
75473 -int __request_module(bool wait, const char *fmt, ...)
75474 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75475 {
75476 - va_list args;
75477 char module_name[MODULE_NAME_LEN];
75478 unsigned int max_modprobes;
75479 int ret;
75480 @@ -139,9 +139,7 @@ int __request_module(bool wait, const char *fmt, ...)
75481 */
75482 WARN_ON_ONCE(wait && current_is_async());
75483
75484 - va_start(args, fmt);
75485 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75486 - va_end(args);
75487 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75488 if (ret >= MODULE_NAME_LEN)
75489 return -ENAMETOOLONG;
75490
75491 @@ -149,6 +147,20 @@ int __request_module(bool wait, const char *fmt, ...)
75492 if (ret)
75493 return ret;
75494
75495 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75496 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75497 + /* hack to workaround consolekit/udisks stupidity */
75498 + read_lock(&tasklist_lock);
75499 + if (!strcmp(current->comm, "mount") &&
75500 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75501 + read_unlock(&tasklist_lock);
75502 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75503 + return -EPERM;
75504 + }
75505 + read_unlock(&tasklist_lock);
75506 + }
75507 +#endif
75508 +
75509 /* If modprobe needs a service that is in a module, we get a recursive
75510 * loop. Limit the number of running kmod threads to max_threads/2 or
75511 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75512 @@ -177,11 +189,52 @@ int __request_module(bool wait, const char *fmt, ...)
75513
75514 trace_module_request(module_name, wait, _RET_IP_);
75515
75516 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75517 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75518
75519 atomic_dec(&kmod_concurrent);
75520 return ret;
75521 }
75522 +
75523 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75524 +{
75525 + va_list args;
75526 + int ret;
75527 +
75528 + va_start(args, fmt);
75529 + ret = ____request_module(wait, module_param, fmt, args);
75530 + va_end(args);
75531 +
75532 + return ret;
75533 +}
75534 +
75535 +int __request_module(bool wait, const char *fmt, ...)
75536 +{
75537 + va_list args;
75538 + int ret;
75539 +
75540 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75541 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75542 + char module_param[MODULE_NAME_LEN];
75543 +
75544 + memset(module_param, 0, sizeof(module_param));
75545 +
75546 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75547 +
75548 + va_start(args, fmt);
75549 + ret = ____request_module(wait, module_param, fmt, args);
75550 + va_end(args);
75551 +
75552 + return ret;
75553 + }
75554 +#endif
75555 +
75556 + va_start(args, fmt);
75557 + ret = ____request_module(wait, NULL, fmt, args);
75558 + va_end(args);
75559 +
75560 + return ret;
75561 +}
75562 +
75563 EXPORT_SYMBOL(__request_module);
75564 #endif /* CONFIG_MODULES */
75565
75566 @@ -292,7 +345,7 @@ static int wait_for_helper(void *data)
75567 *
75568 * Thus the __user pointer cast is valid here.
75569 */
75570 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
75571 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
75572
75573 /*
75574 * If ret is 0, either ____call_usermodehelper failed and the
75575 @@ -649,7 +702,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
75576 static int proc_cap_handler(struct ctl_table *table, int write,
75577 void __user *buffer, size_t *lenp, loff_t *ppos)
75578 {
75579 - struct ctl_table t;
75580 + ctl_table_no_const t;
75581 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
75582 kernel_cap_t new_cap;
75583 int err, i;
75584 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
75585 index 3fed7f0..a3f95ed 100644
75586 --- a/kernel/kprobes.c
75587 +++ b/kernel/kprobes.c
75588 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
75589 * kernel image and loaded module images reside. This is required
75590 * so x86_64 can correctly handle the %rip-relative fixups.
75591 */
75592 - kip->insns = module_alloc(PAGE_SIZE);
75593 + kip->insns = module_alloc_exec(PAGE_SIZE);
75594 if (!kip->insns) {
75595 kfree(kip);
75596 return NULL;
75597 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
75598 */
75599 if (!list_is_singular(&kip->list)) {
75600 list_del(&kip->list);
75601 - module_free(NULL, kip->insns);
75602 + module_free_exec(NULL, kip->insns);
75603 kfree(kip);
75604 }
75605 return 1;
75606 @@ -2073,7 +2073,7 @@ static int __init init_kprobes(void)
75607 {
75608 int i, err = 0;
75609 unsigned long offset = 0, size = 0;
75610 - char *modname, namebuf[128];
75611 + char *modname, namebuf[KSYM_NAME_LEN];
75612 const char *symbol_name;
75613 void *addr;
75614 struct kprobe_blackpoint *kb;
75615 @@ -2158,11 +2158,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
75616 kprobe_type = "k";
75617
75618 if (sym)
75619 - seq_printf(pi, "%p %s %s+0x%x %s ",
75620 + seq_printf(pi, "%pK %s %s+0x%x %s ",
75621 p->addr, kprobe_type, sym, offset,
75622 (modname ? modname : " "));
75623 else
75624 - seq_printf(pi, "%p %s %p ",
75625 + seq_printf(pi, "%pK %s %pK ",
75626 p->addr, kprobe_type, p->addr);
75627
75628 if (!pp)
75629 @@ -2199,7 +2199,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
75630 const char *sym = NULL;
75631 unsigned int i = *(loff_t *) v;
75632 unsigned long offset = 0;
75633 - char *modname, namebuf[128];
75634 + char *modname, namebuf[KSYM_NAME_LEN];
75635
75636 head = &kprobe_table[i];
75637 preempt_disable();
75638 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
75639 index 6ada93c..dce7d5d 100644
75640 --- a/kernel/ksysfs.c
75641 +++ b/kernel/ksysfs.c
75642 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
75643 {
75644 if (count+1 > UEVENT_HELPER_PATH_LEN)
75645 return -ENOENT;
75646 + if (!capable(CAP_SYS_ADMIN))
75647 + return -EPERM;
75648 memcpy(uevent_helper, buf, count);
75649 uevent_helper[count] = '\0';
75650 if (count && uevent_helper[count-1] == '\n')
75651 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
75652 return count;
75653 }
75654
75655 -static struct bin_attribute notes_attr = {
75656 +static bin_attribute_no_const notes_attr __read_only = {
75657 .attr = {
75658 .name = "notes",
75659 .mode = S_IRUGO,
75660 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
75661 index 8a0efac..56f1e2d 100644
75662 --- a/kernel/lockdep.c
75663 +++ b/kernel/lockdep.c
75664 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
75665 end = (unsigned long) &_end,
75666 addr = (unsigned long) obj;
75667
75668 +#ifdef CONFIG_PAX_KERNEXEC
75669 + start = ktla_ktva(start);
75670 +#endif
75671 +
75672 /*
75673 * static variable?
75674 */
75675 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
75676 if (!static_obj(lock->key)) {
75677 debug_locks_off();
75678 printk("INFO: trying to register non-static key.\n");
75679 + printk("lock:%pS key:%pS.\n", lock, lock->key);
75680 printk("the code is fine but needs lockdep annotation.\n");
75681 printk("turning off the locking correctness validator.\n");
75682 dump_stack();
75683 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
75684 if (!class)
75685 return 0;
75686 }
75687 - atomic_inc((atomic_t *)&class->ops);
75688 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
75689 if (very_verbose(class)) {
75690 printk("\nacquire class [%p] %s", class->key, class->name);
75691 if (class->name_version > 1)
75692 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
75693 index b2c71c5..7b88d63 100644
75694 --- a/kernel/lockdep_proc.c
75695 +++ b/kernel/lockdep_proc.c
75696 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
75697 return 0;
75698 }
75699
75700 - seq_printf(m, "%p", class->key);
75701 + seq_printf(m, "%pK", class->key);
75702 #ifdef CONFIG_DEBUG_LOCKDEP
75703 seq_printf(m, " OPS:%8ld", class->ops);
75704 #endif
75705 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
75706
75707 list_for_each_entry(entry, &class->locks_after, entry) {
75708 if (entry->distance == 1) {
75709 - seq_printf(m, " -> [%p] ", entry->class->key);
75710 + seq_printf(m, " -> [%pK] ", entry->class->key);
75711 print_name(m, entry->class);
75712 seq_puts(m, "\n");
75713 }
75714 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
75715 if (!class->key)
75716 continue;
75717
75718 - seq_printf(m, "[%p] ", class->key);
75719 + seq_printf(m, "[%pK] ", class->key);
75720 print_name(m, class);
75721 seq_puts(m, "\n");
75722 }
75723 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75724 if (!i)
75725 seq_line(m, '-', 40-namelen, namelen);
75726
75727 - snprintf(ip, sizeof(ip), "[<%p>]",
75728 + snprintf(ip, sizeof(ip), "[<%pK>]",
75729 (void *)class->contention_point[i]);
75730 seq_printf(m, "%40s %14lu %29s %pS\n",
75731 name, stats->contention_point[i],
75732 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75733 if (!i)
75734 seq_line(m, '-', 40-namelen, namelen);
75735
75736 - snprintf(ip, sizeof(ip), "[<%p>]",
75737 + snprintf(ip, sizeof(ip), "[<%pK>]",
75738 (void *)class->contending_point[i]);
75739 seq_printf(m, "%40s %14lu %29s %pS\n",
75740 name, stats->contending_point[i],
75741 diff --git a/kernel/module.c b/kernel/module.c
75742 index 0925c9a..6b044ac 100644
75743 --- a/kernel/module.c
75744 +++ b/kernel/module.c
75745 @@ -61,6 +61,7 @@
75746 #include <linux/pfn.h>
75747 #include <linux/bsearch.h>
75748 #include <linux/fips.h>
75749 +#include <linux/grsecurity.h>
75750 #include <uapi/linux/module.h>
75751 #include "module-internal.h"
75752
75753 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
75754
75755 /* Bounds of module allocation, for speeding __module_address.
75756 * Protected by module_mutex. */
75757 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
75758 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
75759 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
75760
75761 int register_module_notifier(struct notifier_block * nb)
75762 {
75763 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75764 return true;
75765
75766 list_for_each_entry_rcu(mod, &modules, list) {
75767 - struct symsearch arr[] = {
75768 + struct symsearch modarr[] = {
75769 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
75770 NOT_GPL_ONLY, false },
75771 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
75772 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75773 if (mod->state == MODULE_STATE_UNFORMED)
75774 continue;
75775
75776 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
75777 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
75778 return true;
75779 }
75780 return false;
75781 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
75782 static int percpu_modalloc(struct module *mod,
75783 unsigned long size, unsigned long align)
75784 {
75785 - if (align > PAGE_SIZE) {
75786 + if (align-1 >= PAGE_SIZE) {
75787 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
75788 mod->name, align, PAGE_SIZE);
75789 align = PAGE_SIZE;
75790 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
75791 static ssize_t show_coresize(struct module_attribute *mattr,
75792 struct module_kobject *mk, char *buffer)
75793 {
75794 - return sprintf(buffer, "%u\n", mk->mod->core_size);
75795 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
75796 }
75797
75798 static struct module_attribute modinfo_coresize =
75799 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
75800 static ssize_t show_initsize(struct module_attribute *mattr,
75801 struct module_kobject *mk, char *buffer)
75802 {
75803 - return sprintf(buffer, "%u\n", mk->mod->init_size);
75804 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
75805 }
75806
75807 static struct module_attribute modinfo_initsize =
75808 @@ -1312,7 +1314,7 @@ resolve_symbol_wait(struct module *mod,
75809 */
75810 #ifdef CONFIG_SYSFS
75811
75812 -#ifdef CONFIG_KALLSYMS
75813 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75814 static inline bool sect_empty(const Elf_Shdr *sect)
75815 {
75816 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
75817 @@ -1452,7 +1454,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
75818 {
75819 unsigned int notes, loaded, i;
75820 struct module_notes_attrs *notes_attrs;
75821 - struct bin_attribute *nattr;
75822 + bin_attribute_no_const *nattr;
75823
75824 /* failed to create section attributes, so can't create notes */
75825 if (!mod->sect_attrs)
75826 @@ -1564,7 +1566,7 @@ static void del_usage_links(struct module *mod)
75827 static int module_add_modinfo_attrs(struct module *mod)
75828 {
75829 struct module_attribute *attr;
75830 - struct module_attribute *temp_attr;
75831 + module_attribute_no_const *temp_attr;
75832 int error = 0;
75833 int i;
75834
75835 @@ -1778,21 +1780,21 @@ static void set_section_ro_nx(void *base,
75836
75837 static void unset_module_core_ro_nx(struct module *mod)
75838 {
75839 - set_page_attributes(mod->module_core + mod->core_text_size,
75840 - mod->module_core + mod->core_size,
75841 + set_page_attributes(mod->module_core_rw,
75842 + mod->module_core_rw + mod->core_size_rw,
75843 set_memory_x);
75844 - set_page_attributes(mod->module_core,
75845 - mod->module_core + mod->core_ro_size,
75846 + set_page_attributes(mod->module_core_rx,
75847 + mod->module_core_rx + mod->core_size_rx,
75848 set_memory_rw);
75849 }
75850
75851 static void unset_module_init_ro_nx(struct module *mod)
75852 {
75853 - set_page_attributes(mod->module_init + mod->init_text_size,
75854 - mod->module_init + mod->init_size,
75855 + set_page_attributes(mod->module_init_rw,
75856 + mod->module_init_rw + mod->init_size_rw,
75857 set_memory_x);
75858 - set_page_attributes(mod->module_init,
75859 - mod->module_init + mod->init_ro_size,
75860 + set_page_attributes(mod->module_init_rx,
75861 + mod->module_init_rx + mod->init_size_rx,
75862 set_memory_rw);
75863 }
75864
75865 @@ -1805,14 +1807,14 @@ void set_all_modules_text_rw(void)
75866 list_for_each_entry_rcu(mod, &modules, list) {
75867 if (mod->state == MODULE_STATE_UNFORMED)
75868 continue;
75869 - if ((mod->module_core) && (mod->core_text_size)) {
75870 - set_page_attributes(mod->module_core,
75871 - mod->module_core + mod->core_text_size,
75872 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75873 + set_page_attributes(mod->module_core_rx,
75874 + mod->module_core_rx + mod->core_size_rx,
75875 set_memory_rw);
75876 }
75877 - if ((mod->module_init) && (mod->init_text_size)) {
75878 - set_page_attributes(mod->module_init,
75879 - mod->module_init + mod->init_text_size,
75880 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75881 + set_page_attributes(mod->module_init_rx,
75882 + mod->module_init_rx + mod->init_size_rx,
75883 set_memory_rw);
75884 }
75885 }
75886 @@ -1828,14 +1830,14 @@ void set_all_modules_text_ro(void)
75887 list_for_each_entry_rcu(mod, &modules, list) {
75888 if (mod->state == MODULE_STATE_UNFORMED)
75889 continue;
75890 - if ((mod->module_core) && (mod->core_text_size)) {
75891 - set_page_attributes(mod->module_core,
75892 - mod->module_core + mod->core_text_size,
75893 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75894 + set_page_attributes(mod->module_core_rx,
75895 + mod->module_core_rx + mod->core_size_rx,
75896 set_memory_ro);
75897 }
75898 - if ((mod->module_init) && (mod->init_text_size)) {
75899 - set_page_attributes(mod->module_init,
75900 - mod->module_init + mod->init_text_size,
75901 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75902 + set_page_attributes(mod->module_init_rx,
75903 + mod->module_init_rx + mod->init_size_rx,
75904 set_memory_ro);
75905 }
75906 }
75907 @@ -1881,16 +1883,19 @@ static void free_module(struct module *mod)
75908
75909 /* This may be NULL, but that's OK */
75910 unset_module_init_ro_nx(mod);
75911 - module_free(mod, mod->module_init);
75912 + module_free(mod, mod->module_init_rw);
75913 + module_free_exec(mod, mod->module_init_rx);
75914 kfree(mod->args);
75915 percpu_modfree(mod);
75916
75917 /* Free lock-classes: */
75918 - lockdep_free_key_range(mod->module_core, mod->core_size);
75919 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
75920 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
75921
75922 /* Finally, free the core (containing the module structure) */
75923 unset_module_core_ro_nx(mod);
75924 - module_free(mod, mod->module_core);
75925 + module_free_exec(mod, mod->module_core_rx);
75926 + module_free(mod, mod->module_core_rw);
75927
75928 #ifdef CONFIG_MPU
75929 update_protections(current->mm);
75930 @@ -1960,9 +1965,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75931 int ret = 0;
75932 const struct kernel_symbol *ksym;
75933
75934 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75935 + int is_fs_load = 0;
75936 + int register_filesystem_found = 0;
75937 + char *p;
75938 +
75939 + p = strstr(mod->args, "grsec_modharden_fs");
75940 + if (p) {
75941 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
75942 + /* copy \0 as well */
75943 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
75944 + is_fs_load = 1;
75945 + }
75946 +#endif
75947 +
75948 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
75949 const char *name = info->strtab + sym[i].st_name;
75950
75951 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75952 + /* it's a real shame this will never get ripped and copied
75953 + upstream! ;(
75954 + */
75955 + if (is_fs_load && !strcmp(name, "register_filesystem"))
75956 + register_filesystem_found = 1;
75957 +#endif
75958 +
75959 switch (sym[i].st_shndx) {
75960 case SHN_COMMON:
75961 /* We compiled with -fno-common. These are not
75962 @@ -1983,7 +2010,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75963 ksym = resolve_symbol_wait(mod, info, name);
75964 /* Ok if resolved. */
75965 if (ksym && !IS_ERR(ksym)) {
75966 + pax_open_kernel();
75967 sym[i].st_value = ksym->value;
75968 + pax_close_kernel();
75969 break;
75970 }
75971
75972 @@ -2002,11 +2031,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75973 secbase = (unsigned long)mod_percpu(mod);
75974 else
75975 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
75976 + pax_open_kernel();
75977 sym[i].st_value += secbase;
75978 + pax_close_kernel();
75979 break;
75980 }
75981 }
75982
75983 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75984 + if (is_fs_load && !register_filesystem_found) {
75985 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
75986 + ret = -EPERM;
75987 + }
75988 +#endif
75989 +
75990 return ret;
75991 }
75992
75993 @@ -2090,22 +2128,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
75994 || s->sh_entsize != ~0UL
75995 || strstarts(sname, ".init"))
75996 continue;
75997 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
75998 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75999 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76000 + else
76001 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76002 pr_debug("\t%s\n", sname);
76003 }
76004 - switch (m) {
76005 - case 0: /* executable */
76006 - mod->core_size = debug_align(mod->core_size);
76007 - mod->core_text_size = mod->core_size;
76008 - break;
76009 - case 1: /* RO: text and ro-data */
76010 - mod->core_size = debug_align(mod->core_size);
76011 - mod->core_ro_size = mod->core_size;
76012 - break;
76013 - case 3: /* whole core */
76014 - mod->core_size = debug_align(mod->core_size);
76015 - break;
76016 - }
76017 }
76018
76019 pr_debug("Init section allocation order:\n");
76020 @@ -2119,23 +2147,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76021 || s->sh_entsize != ~0UL
76022 || !strstarts(sname, ".init"))
76023 continue;
76024 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76025 - | INIT_OFFSET_MASK);
76026 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76027 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76028 + else
76029 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76030 + s->sh_entsize |= INIT_OFFSET_MASK;
76031 pr_debug("\t%s\n", sname);
76032 }
76033 - switch (m) {
76034 - case 0: /* executable */
76035 - mod->init_size = debug_align(mod->init_size);
76036 - mod->init_text_size = mod->init_size;
76037 - break;
76038 - case 1: /* RO: text and ro-data */
76039 - mod->init_size = debug_align(mod->init_size);
76040 - mod->init_ro_size = mod->init_size;
76041 - break;
76042 - case 3: /* whole init */
76043 - mod->init_size = debug_align(mod->init_size);
76044 - break;
76045 - }
76046 }
76047 }
76048
76049 @@ -2308,7 +2326,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76050
76051 /* Put symbol section at end of init part of module. */
76052 symsect->sh_flags |= SHF_ALLOC;
76053 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76054 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76055 info->index.sym) | INIT_OFFSET_MASK;
76056 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76057
76058 @@ -2325,13 +2343,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76059 }
76060
76061 /* Append room for core symbols at end of core part. */
76062 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76063 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76064 - mod->core_size += strtab_size;
76065 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76066 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76067 + mod->core_size_rx += strtab_size;
76068
76069 /* Put string table section at end of init part of module. */
76070 strsect->sh_flags |= SHF_ALLOC;
76071 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76072 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76073 info->index.str) | INIT_OFFSET_MASK;
76074 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76075 }
76076 @@ -2349,12 +2367,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76077 /* Make sure we get permanent strtab: don't use info->strtab. */
76078 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76079
76080 + pax_open_kernel();
76081 +
76082 /* Set types up while we still have access to sections. */
76083 for (i = 0; i < mod->num_symtab; i++)
76084 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76085
76086 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76087 - mod->core_strtab = s = mod->module_core + info->stroffs;
76088 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76089 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76090 src = mod->symtab;
76091 for (ndst = i = 0; i < mod->num_symtab; i++) {
76092 if (i == 0 ||
76093 @@ -2366,6 +2386,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76094 }
76095 }
76096 mod->core_num_syms = ndst;
76097 +
76098 + pax_close_kernel();
76099 }
76100 #else
76101 static inline void layout_symtab(struct module *mod, struct load_info *info)
76102 @@ -2399,17 +2421,33 @@ void * __weak module_alloc(unsigned long size)
76103 return vmalloc_exec(size);
76104 }
76105
76106 -static void *module_alloc_update_bounds(unsigned long size)
76107 +static void *module_alloc_update_bounds_rw(unsigned long size)
76108 {
76109 void *ret = module_alloc(size);
76110
76111 if (ret) {
76112 mutex_lock(&module_mutex);
76113 /* Update module bounds. */
76114 - if ((unsigned long)ret < module_addr_min)
76115 - module_addr_min = (unsigned long)ret;
76116 - if ((unsigned long)ret + size > module_addr_max)
76117 - module_addr_max = (unsigned long)ret + size;
76118 + if ((unsigned long)ret < module_addr_min_rw)
76119 + module_addr_min_rw = (unsigned long)ret;
76120 + if ((unsigned long)ret + size > module_addr_max_rw)
76121 + module_addr_max_rw = (unsigned long)ret + size;
76122 + mutex_unlock(&module_mutex);
76123 + }
76124 + return ret;
76125 +}
76126 +
76127 +static void *module_alloc_update_bounds_rx(unsigned long size)
76128 +{
76129 + void *ret = module_alloc_exec(size);
76130 +
76131 + if (ret) {
76132 + mutex_lock(&module_mutex);
76133 + /* Update module bounds. */
76134 + if ((unsigned long)ret < module_addr_min_rx)
76135 + module_addr_min_rx = (unsigned long)ret;
76136 + if ((unsigned long)ret + size > module_addr_max_rx)
76137 + module_addr_max_rx = (unsigned long)ret + size;
76138 mutex_unlock(&module_mutex);
76139 }
76140 return ret;
76141 @@ -2685,8 +2723,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76142 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76143 {
76144 const char *modmagic = get_modinfo(info, "vermagic");
76145 + const char *license = get_modinfo(info, "license");
76146 int err;
76147
76148 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76149 + if (!license || !license_is_gpl_compatible(license))
76150 + return -ENOEXEC;
76151 +#endif
76152 +
76153 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76154 modmagic = NULL;
76155
76156 @@ -2712,7 +2756,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76157 }
76158
76159 /* Set up license info based on the info section */
76160 - set_license(mod, get_modinfo(info, "license"));
76161 + set_license(mod, license);
76162
76163 return 0;
76164 }
76165 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
76166 void *ptr;
76167
76168 /* Do the allocs. */
76169 - ptr = module_alloc_update_bounds(mod->core_size);
76170 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76171 /*
76172 * The pointer to this block is stored in the module structure
76173 * which is inside the block. Just mark it as not being a
76174 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
76175 if (!ptr)
76176 return -ENOMEM;
76177
76178 - memset(ptr, 0, mod->core_size);
76179 - mod->module_core = ptr;
76180 + memset(ptr, 0, mod->core_size_rw);
76181 + mod->module_core_rw = ptr;
76182
76183 - if (mod->init_size) {
76184 - ptr = module_alloc_update_bounds(mod->init_size);
76185 + if (mod->init_size_rw) {
76186 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76187 /*
76188 * The pointer to this block is stored in the module structure
76189 * which is inside the block. This block doesn't need to be
76190 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
76191 */
76192 kmemleak_ignore(ptr);
76193 if (!ptr) {
76194 - module_free(mod, mod->module_core);
76195 + module_free(mod, mod->module_core_rw);
76196 return -ENOMEM;
76197 }
76198 - memset(ptr, 0, mod->init_size);
76199 - mod->module_init = ptr;
76200 + memset(ptr, 0, mod->init_size_rw);
76201 + mod->module_init_rw = ptr;
76202 } else
76203 - mod->module_init = NULL;
76204 + mod->module_init_rw = NULL;
76205 +
76206 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76207 + kmemleak_not_leak(ptr);
76208 + if (!ptr) {
76209 + if (mod->module_init_rw)
76210 + module_free(mod, mod->module_init_rw);
76211 + module_free(mod, mod->module_core_rw);
76212 + return -ENOMEM;
76213 + }
76214 +
76215 + pax_open_kernel();
76216 + memset(ptr, 0, mod->core_size_rx);
76217 + pax_close_kernel();
76218 + mod->module_core_rx = ptr;
76219 +
76220 + if (mod->init_size_rx) {
76221 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76222 + kmemleak_ignore(ptr);
76223 + if (!ptr && mod->init_size_rx) {
76224 + module_free_exec(mod, mod->module_core_rx);
76225 + if (mod->module_init_rw)
76226 + module_free(mod, mod->module_init_rw);
76227 + module_free(mod, mod->module_core_rw);
76228 + return -ENOMEM;
76229 + }
76230 +
76231 + pax_open_kernel();
76232 + memset(ptr, 0, mod->init_size_rx);
76233 + pax_close_kernel();
76234 + mod->module_init_rx = ptr;
76235 + } else
76236 + mod->module_init_rx = NULL;
76237
76238 /* Transfer each section which specifies SHF_ALLOC */
76239 pr_debug("final section addresses:\n");
76240 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
76241 if (!(shdr->sh_flags & SHF_ALLOC))
76242 continue;
76243
76244 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76245 - dest = mod->module_init
76246 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76247 - else
76248 - dest = mod->module_core + shdr->sh_entsize;
76249 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76250 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76251 + dest = mod->module_init_rw
76252 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76253 + else
76254 + dest = mod->module_init_rx
76255 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76256 + } else {
76257 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76258 + dest = mod->module_core_rw + shdr->sh_entsize;
76259 + else
76260 + dest = mod->module_core_rx + shdr->sh_entsize;
76261 + }
76262 +
76263 + if (shdr->sh_type != SHT_NOBITS) {
76264 +
76265 +#ifdef CONFIG_PAX_KERNEXEC
76266 +#ifdef CONFIG_X86_64
76267 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76268 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76269 +#endif
76270 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76271 + pax_open_kernel();
76272 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76273 + pax_close_kernel();
76274 + } else
76275 +#endif
76276
76277 - if (shdr->sh_type != SHT_NOBITS)
76278 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76279 + }
76280 /* Update sh_addr to point to copy in image. */
76281 - shdr->sh_addr = (unsigned long)dest;
76282 +
76283 +#ifdef CONFIG_PAX_KERNEXEC
76284 + if (shdr->sh_flags & SHF_EXECINSTR)
76285 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76286 + else
76287 +#endif
76288 +
76289 + shdr->sh_addr = (unsigned long)dest;
76290 pr_debug("\t0x%lx %s\n",
76291 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76292 }
76293 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
76294 * Do it before processing of module parameters, so the module
76295 * can provide parameter accessor functions of its own.
76296 */
76297 - if (mod->module_init)
76298 - flush_icache_range((unsigned long)mod->module_init,
76299 - (unsigned long)mod->module_init
76300 - + mod->init_size);
76301 - flush_icache_range((unsigned long)mod->module_core,
76302 - (unsigned long)mod->module_core + mod->core_size);
76303 + if (mod->module_init_rx)
76304 + flush_icache_range((unsigned long)mod->module_init_rx,
76305 + (unsigned long)mod->module_init_rx
76306 + + mod->init_size_rx);
76307 + flush_icache_range((unsigned long)mod->module_core_rx,
76308 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76309
76310 set_fs(old_fs);
76311 }
76312 @@ -2987,8 +3092,10 @@ out:
76313 static void module_deallocate(struct module *mod, struct load_info *info)
76314 {
76315 percpu_modfree(mod);
76316 - module_free(mod, mod->module_init);
76317 - module_free(mod, mod->module_core);
76318 + module_free_exec(mod, mod->module_init_rx);
76319 + module_free_exec(mod, mod->module_core_rx);
76320 + module_free(mod, mod->module_init_rw);
76321 + module_free(mod, mod->module_core_rw);
76322 }
76323
76324 int __weak module_finalize(const Elf_Ehdr *hdr,
76325 @@ -3001,7 +3108,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76326 static int post_relocation(struct module *mod, const struct load_info *info)
76327 {
76328 /* Sort exception table now relocations are done. */
76329 + pax_open_kernel();
76330 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76331 + pax_close_kernel();
76332
76333 /* Copy relocated percpu area over. */
76334 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76335 @@ -3055,16 +3164,16 @@ static int do_init_module(struct module *mod)
76336 MODULE_STATE_COMING, mod);
76337
76338 /* Set RO and NX regions for core */
76339 - set_section_ro_nx(mod->module_core,
76340 - mod->core_text_size,
76341 - mod->core_ro_size,
76342 - mod->core_size);
76343 + set_section_ro_nx(mod->module_core_rx,
76344 + mod->core_size_rx,
76345 + mod->core_size_rx,
76346 + mod->core_size_rx);
76347
76348 /* Set RO and NX regions for init */
76349 - set_section_ro_nx(mod->module_init,
76350 - mod->init_text_size,
76351 - mod->init_ro_size,
76352 - mod->init_size);
76353 + set_section_ro_nx(mod->module_init_rx,
76354 + mod->init_size_rx,
76355 + mod->init_size_rx,
76356 + mod->init_size_rx);
76357
76358 do_mod_ctors(mod);
76359 /* Start the module */
76360 @@ -3126,11 +3235,12 @@ static int do_init_module(struct module *mod)
76361 mod->strtab = mod->core_strtab;
76362 #endif
76363 unset_module_init_ro_nx(mod);
76364 - module_free(mod, mod->module_init);
76365 - mod->module_init = NULL;
76366 - mod->init_size = 0;
76367 - mod->init_ro_size = 0;
76368 - mod->init_text_size = 0;
76369 + module_free(mod, mod->module_init_rw);
76370 + module_free_exec(mod, mod->module_init_rx);
76371 + mod->module_init_rw = NULL;
76372 + mod->module_init_rx = NULL;
76373 + mod->init_size_rw = 0;
76374 + mod->init_size_rx = 0;
76375 mutex_unlock(&module_mutex);
76376 wake_up_all(&module_wq);
76377
76378 @@ -3257,9 +3367,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
76379 if (err)
76380 goto free_unload;
76381
76382 + /* Now copy in args */
76383 + mod->args = strndup_user(uargs, ~0UL >> 1);
76384 + if (IS_ERR(mod->args)) {
76385 + err = PTR_ERR(mod->args);
76386 + goto free_unload;
76387 + }
76388 +
76389 /* Set up MODINFO_ATTR fields */
76390 setup_modinfo(mod, info);
76391
76392 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76393 + {
76394 + char *p, *p2;
76395 +
76396 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76397 + 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);
76398 + err = -EPERM;
76399 + goto free_modinfo;
76400 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76401 + p += sizeof("grsec_modharden_normal") - 1;
76402 + p2 = strstr(p, "_");
76403 + if (p2) {
76404 + *p2 = '\0';
76405 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76406 + *p2 = '_';
76407 + }
76408 + err = -EPERM;
76409 + goto free_modinfo;
76410 + }
76411 + }
76412 +#endif
76413 +
76414 /* Fix up syms, so that st_value is a pointer to location. */
76415 err = simplify_symbols(mod, info);
76416 if (err < 0)
76417 @@ -3275,13 +3414,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
76418
76419 flush_module_icache(mod);
76420
76421 - /* Now copy in args */
76422 - mod->args = strndup_user(uargs, ~0UL >> 1);
76423 - if (IS_ERR(mod->args)) {
76424 - err = PTR_ERR(mod->args);
76425 - goto free_arch_cleanup;
76426 - }
76427 -
76428 dynamic_debug_setup(info->debug, info->num_debug);
76429
76430 /* Finally it's fully formed, ready to start executing. */
76431 @@ -3316,11 +3448,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
76432 ddebug_cleanup:
76433 dynamic_debug_remove(info->debug);
76434 synchronize_sched();
76435 - kfree(mod->args);
76436 - free_arch_cleanup:
76437 module_arch_cleanup(mod);
76438 free_modinfo:
76439 free_modinfo(mod);
76440 + kfree(mod->args);
76441 free_unload:
76442 module_unload_free(mod);
76443 unlink_mod:
76444 @@ -3403,10 +3534,16 @@ static const char *get_ksymbol(struct module *mod,
76445 unsigned long nextval;
76446
76447 /* At worse, next value is at end of module */
76448 - if (within_module_init(addr, mod))
76449 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
76450 + if (within_module_init_rx(addr, mod))
76451 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
76452 + else if (within_module_init_rw(addr, mod))
76453 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
76454 + else if (within_module_core_rx(addr, mod))
76455 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
76456 + else if (within_module_core_rw(addr, mod))
76457 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
76458 else
76459 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
76460 + return NULL;
76461
76462 /* Scan for closest preceding symbol, and next symbol. (ELF
76463 starts real symbols at 1). */
76464 @@ -3659,7 +3796,7 @@ static int m_show(struct seq_file *m, void *p)
76465 return 0;
76466
76467 seq_printf(m, "%s %u",
76468 - mod->name, mod->init_size + mod->core_size);
76469 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
76470 print_unload_info(m, mod);
76471
76472 /* Informative for users. */
76473 @@ -3668,7 +3805,7 @@ static int m_show(struct seq_file *m, void *p)
76474 mod->state == MODULE_STATE_COMING ? "Loading":
76475 "Live");
76476 /* Used by oprofile and other similar tools. */
76477 - seq_printf(m, " 0x%pK", mod->module_core);
76478 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76479
76480 /* Taints info */
76481 if (mod->taints)
76482 @@ -3704,7 +3841,17 @@ static const struct file_operations proc_modules_operations = {
76483
76484 static int __init proc_modules_init(void)
76485 {
76486 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76487 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76488 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76489 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76490 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76491 +#else
76492 proc_create("modules", 0, NULL, &proc_modules_operations);
76493 +#endif
76494 +#else
76495 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76496 +#endif
76497 return 0;
76498 }
76499 module_init(proc_modules_init);
76500 @@ -3765,14 +3912,14 @@ struct module *__module_address(unsigned long addr)
76501 {
76502 struct module *mod;
76503
76504 - if (addr < module_addr_min || addr > module_addr_max)
76505 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76506 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76507 return NULL;
76508
76509 list_for_each_entry_rcu(mod, &modules, list) {
76510 if (mod->state == MODULE_STATE_UNFORMED)
76511 continue;
76512 - if (within_module_core(addr, mod)
76513 - || within_module_init(addr, mod))
76514 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76515 return mod;
76516 }
76517 return NULL;
76518 @@ -3807,11 +3954,20 @@ bool is_module_text_address(unsigned long addr)
76519 */
76520 struct module *__module_text_address(unsigned long addr)
76521 {
76522 - struct module *mod = __module_address(addr);
76523 + struct module *mod;
76524 +
76525 +#ifdef CONFIG_X86_32
76526 + addr = ktla_ktva(addr);
76527 +#endif
76528 +
76529 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76530 + return NULL;
76531 +
76532 + mod = __module_address(addr);
76533 +
76534 if (mod) {
76535 /* Make sure it's within the text section. */
76536 - if (!within(addr, mod->module_init, mod->init_text_size)
76537 - && !within(addr, mod->module_core, mod->core_text_size))
76538 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76539 mod = NULL;
76540 }
76541 return mod;
76542 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76543 index 7e3443f..b2a1e6b 100644
76544 --- a/kernel/mutex-debug.c
76545 +++ b/kernel/mutex-debug.c
76546 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76547 }
76548
76549 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76550 - struct thread_info *ti)
76551 + struct task_struct *task)
76552 {
76553 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76554
76555 /* Mark the current thread as blocked on the lock: */
76556 - ti->task->blocked_on = waiter;
76557 + task->blocked_on = waiter;
76558 }
76559
76560 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76561 - struct thread_info *ti)
76562 + struct task_struct *task)
76563 {
76564 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76565 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76566 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76567 - ti->task->blocked_on = NULL;
76568 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
76569 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
76570 + task->blocked_on = NULL;
76571
76572 list_del_init(&waiter->list);
76573 waiter->task = NULL;
76574 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
76575 index 0799fd3..d06ae3b 100644
76576 --- a/kernel/mutex-debug.h
76577 +++ b/kernel/mutex-debug.h
76578 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
76579 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
76580 extern void debug_mutex_add_waiter(struct mutex *lock,
76581 struct mutex_waiter *waiter,
76582 - struct thread_info *ti);
76583 + struct task_struct *task);
76584 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76585 - struct thread_info *ti);
76586 + struct task_struct *task);
76587 extern void debug_mutex_unlock(struct mutex *lock);
76588 extern void debug_mutex_init(struct mutex *lock, const char *name,
76589 struct lock_class_key *key);
76590 diff --git a/kernel/mutex.c b/kernel/mutex.c
76591 index 52f2301..73f7528 100644
76592 --- a/kernel/mutex.c
76593 +++ b/kernel/mutex.c
76594 @@ -199,7 +199,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76595 spin_lock_mutex(&lock->wait_lock, flags);
76596
76597 debug_mutex_lock_common(lock, &waiter);
76598 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
76599 + debug_mutex_add_waiter(lock, &waiter, task);
76600
76601 /* add waiting tasks to the end of the waitqueue (FIFO): */
76602 list_add_tail(&waiter.list, &lock->wait_list);
76603 @@ -228,8 +228,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76604 * TASK_UNINTERRUPTIBLE case.)
76605 */
76606 if (unlikely(signal_pending_state(state, task))) {
76607 - mutex_remove_waiter(lock, &waiter,
76608 - task_thread_info(task));
76609 + mutex_remove_waiter(lock, &waiter, task);
76610 mutex_release(&lock->dep_map, 1, ip);
76611 spin_unlock_mutex(&lock->wait_lock, flags);
76612
76613 @@ -248,7 +247,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76614 done:
76615 lock_acquired(&lock->dep_map, ip);
76616 /* got the lock - rejoice! */
76617 - mutex_remove_waiter(lock, &waiter, current_thread_info());
76618 + mutex_remove_waiter(lock, &waiter, task);
76619 mutex_set_owner(lock);
76620
76621 /* set it to 0 if there are no waiters left: */
76622 diff --git a/kernel/notifier.c b/kernel/notifier.c
76623 index 2d5cc4c..d9ea600 100644
76624 --- a/kernel/notifier.c
76625 +++ b/kernel/notifier.c
76626 @@ -5,6 +5,7 @@
76627 #include <linux/rcupdate.h>
76628 #include <linux/vmalloc.h>
76629 #include <linux/reboot.h>
76630 +#include <linux/mm.h>
76631
76632 /*
76633 * Notifier list for kernel code which wants to be called
76634 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
76635 while ((*nl) != NULL) {
76636 if (n->priority > (*nl)->priority)
76637 break;
76638 - nl = &((*nl)->next);
76639 + nl = (struct notifier_block **)&((*nl)->next);
76640 }
76641 - n->next = *nl;
76642 + pax_open_kernel();
76643 + *(const void **)&n->next = *nl;
76644 rcu_assign_pointer(*nl, n);
76645 + pax_close_kernel();
76646 return 0;
76647 }
76648
76649 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
76650 return 0;
76651 if (n->priority > (*nl)->priority)
76652 break;
76653 - nl = &((*nl)->next);
76654 + nl = (struct notifier_block **)&((*nl)->next);
76655 }
76656 - n->next = *nl;
76657 + pax_open_kernel();
76658 + *(const void **)&n->next = *nl;
76659 rcu_assign_pointer(*nl, n);
76660 + pax_close_kernel();
76661 return 0;
76662 }
76663
76664 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
76665 {
76666 while ((*nl) != NULL) {
76667 if ((*nl) == n) {
76668 + pax_open_kernel();
76669 rcu_assign_pointer(*nl, n->next);
76670 + pax_close_kernel();
76671 return 0;
76672 }
76673 - nl = &((*nl)->next);
76674 + nl = (struct notifier_block **)&((*nl)->next);
76675 }
76676 return -ENOENT;
76677 }
76678 diff --git a/kernel/panic.c b/kernel/panic.c
76679 index 7c57cc9..28f1b3f 100644
76680 --- a/kernel/panic.c
76681 +++ b/kernel/panic.c
76682 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
76683 const char *board;
76684
76685 printk(KERN_WARNING "------------[ cut here ]------------\n");
76686 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
76687 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
76688 board = dmi_get_system_info(DMI_PRODUCT_NAME);
76689 if (board)
76690 printk(KERN_WARNING "Hardware name: %s\n", board);
76691 @@ -459,7 +459,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
76692 */
76693 void __stack_chk_fail(void)
76694 {
76695 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
76696 + dump_stack();
76697 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
76698 __builtin_return_address(0));
76699 }
76700 EXPORT_SYMBOL(__stack_chk_fail);
76701 diff --git a/kernel/pid.c b/kernel/pid.c
76702 index 047dc62..418d74b 100644
76703 --- a/kernel/pid.c
76704 +++ b/kernel/pid.c
76705 @@ -33,6 +33,7 @@
76706 #include <linux/rculist.h>
76707 #include <linux/bootmem.h>
76708 #include <linux/hash.h>
76709 +#include <linux/security.h>
76710 #include <linux/pid_namespace.h>
76711 #include <linux/init_task.h>
76712 #include <linux/syscalls.h>
76713 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
76714
76715 int pid_max = PID_MAX_DEFAULT;
76716
76717 -#define RESERVED_PIDS 300
76718 +#define RESERVED_PIDS 500
76719
76720 int pid_max_min = RESERVED_PIDS + 1;
76721 int pid_max_max = PID_MAX_LIMIT;
76722 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
76723 */
76724 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
76725 {
76726 + struct task_struct *task;
76727 +
76728 rcu_lockdep_assert(rcu_read_lock_held(),
76729 "find_task_by_pid_ns() needs rcu_read_lock()"
76730 " protection");
76731 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76732 +
76733 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76734 +
76735 + if (gr_pid_is_chrooted(task))
76736 + return NULL;
76737 +
76738 + return task;
76739 }
76740
76741 struct task_struct *find_task_by_vpid(pid_t vnr)
76742 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
76743 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
76744 }
76745
76746 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
76747 +{
76748 + rcu_lockdep_assert(rcu_read_lock_held(),
76749 + "find_task_by_pid_ns() needs rcu_read_lock()"
76750 + " protection");
76751 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
76752 +}
76753 +
76754 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
76755 {
76756 struct pid *pid;
76757 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
76758 index bea15bd..789f3d0 100644
76759 --- a/kernel/pid_namespace.c
76760 +++ b/kernel/pid_namespace.c
76761 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
76762 void __user *buffer, size_t *lenp, loff_t *ppos)
76763 {
76764 struct pid_namespace *pid_ns = task_active_pid_ns(current);
76765 - struct ctl_table tmp = *table;
76766 + ctl_table_no_const tmp = *table;
76767
76768 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
76769 return -EPERM;
76770 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
76771 index 8fd709c..542bf4b 100644
76772 --- a/kernel/posix-cpu-timers.c
76773 +++ b/kernel/posix-cpu-timers.c
76774 @@ -1592,14 +1592,14 @@ struct k_clock clock_posix_cpu = {
76775
76776 static __init int init_posix_cpu_timers(void)
76777 {
76778 - struct k_clock process = {
76779 + static struct k_clock process = {
76780 .clock_getres = process_cpu_clock_getres,
76781 .clock_get = process_cpu_clock_get,
76782 .timer_create = process_cpu_timer_create,
76783 .nsleep = process_cpu_nsleep,
76784 .nsleep_restart = process_cpu_nsleep_restart,
76785 };
76786 - struct k_clock thread = {
76787 + static struct k_clock thread = {
76788 .clock_getres = thread_cpu_clock_getres,
76789 .clock_get = thread_cpu_clock_get,
76790 .timer_create = thread_cpu_timer_create,
76791 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
76792 index 6edbb2c..334f085 100644
76793 --- a/kernel/posix-timers.c
76794 +++ b/kernel/posix-timers.c
76795 @@ -43,6 +43,7 @@
76796 #include <linux/idr.h>
76797 #include <linux/posix-clock.h>
76798 #include <linux/posix-timers.h>
76799 +#include <linux/grsecurity.h>
76800 #include <linux/syscalls.h>
76801 #include <linux/wait.h>
76802 #include <linux/workqueue.h>
76803 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
76804 * which we beg off on and pass to do_sys_settimeofday().
76805 */
76806
76807 -static struct k_clock posix_clocks[MAX_CLOCKS];
76808 +static struct k_clock *posix_clocks[MAX_CLOCKS];
76809
76810 /*
76811 * These ones are defined below.
76812 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
76813 */
76814 static __init int init_posix_timers(void)
76815 {
76816 - struct k_clock clock_realtime = {
76817 + static struct k_clock clock_realtime = {
76818 .clock_getres = hrtimer_get_res,
76819 .clock_get = posix_clock_realtime_get,
76820 .clock_set = posix_clock_realtime_set,
76821 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
76822 .timer_get = common_timer_get,
76823 .timer_del = common_timer_del,
76824 };
76825 - struct k_clock clock_monotonic = {
76826 + static struct k_clock clock_monotonic = {
76827 .clock_getres = hrtimer_get_res,
76828 .clock_get = posix_ktime_get_ts,
76829 .nsleep = common_nsleep,
76830 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
76831 .timer_get = common_timer_get,
76832 .timer_del = common_timer_del,
76833 };
76834 - struct k_clock clock_monotonic_raw = {
76835 + static struct k_clock clock_monotonic_raw = {
76836 .clock_getres = hrtimer_get_res,
76837 .clock_get = posix_get_monotonic_raw,
76838 };
76839 - struct k_clock clock_realtime_coarse = {
76840 + static struct k_clock clock_realtime_coarse = {
76841 .clock_getres = posix_get_coarse_res,
76842 .clock_get = posix_get_realtime_coarse,
76843 };
76844 - struct k_clock clock_monotonic_coarse = {
76845 + static struct k_clock clock_monotonic_coarse = {
76846 .clock_getres = posix_get_coarse_res,
76847 .clock_get = posix_get_monotonic_coarse,
76848 };
76849 - struct k_clock clock_boottime = {
76850 + static struct k_clock clock_boottime = {
76851 .clock_getres = hrtimer_get_res,
76852 .clock_get = posix_get_boottime,
76853 .nsleep = common_nsleep,
76854 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
76855 return;
76856 }
76857
76858 - posix_clocks[clock_id] = *new_clock;
76859 + posix_clocks[clock_id] = new_clock;
76860 }
76861 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
76862
76863 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
76864 return (id & CLOCKFD_MASK) == CLOCKFD ?
76865 &clock_posix_dynamic : &clock_posix_cpu;
76866
76867 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
76868 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
76869 return NULL;
76870 - return &posix_clocks[id];
76871 + return posix_clocks[id];
76872 }
76873
76874 static int common_timer_create(struct k_itimer *new_timer)
76875 @@ -964,6 +965,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
76876 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
76877 return -EFAULT;
76878
76879 + /* only the CLOCK_REALTIME clock can be set, all other clocks
76880 + have their clock_set fptr set to a nosettime dummy function
76881 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
76882 + call common_clock_set, which calls do_sys_settimeofday, which
76883 + we hook
76884 + */
76885 +
76886 return kc->clock_set(which_clock, &new_tp);
76887 }
76888
76889 diff --git a/kernel/power/process.c b/kernel/power/process.c
76890 index 98088e0..aaf95c0 100644
76891 --- a/kernel/power/process.c
76892 +++ b/kernel/power/process.c
76893 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
76894 u64 elapsed_csecs64;
76895 unsigned int elapsed_csecs;
76896 bool wakeup = false;
76897 + bool timedout = false;
76898
76899 do_gettimeofday(&start);
76900
76901 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
76902
76903 while (true) {
76904 todo = 0;
76905 + if (time_after(jiffies, end_time))
76906 + timedout = true;
76907 read_lock(&tasklist_lock);
76908 do_each_thread(g, p) {
76909 if (p == current || !freeze_task(p))
76910 continue;
76911
76912 - if (!freezer_should_skip(p))
76913 + if (!freezer_should_skip(p)) {
76914 todo++;
76915 + if (timedout) {
76916 + printk(KERN_ERR "Task refusing to freeze:\n");
76917 + sched_show_task(p);
76918 + }
76919 + }
76920 } while_each_thread(g, p);
76921 read_unlock(&tasklist_lock);
76922
76923 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
76924 todo += wq_busy;
76925 }
76926
76927 - if (!todo || time_after(jiffies, end_time))
76928 + if (!todo || timedout)
76929 break;
76930
76931 if (pm_wakeup_pending()) {
76932 diff --git a/kernel/printk.c b/kernel/printk.c
76933 index abbdd9e..f294251 100644
76934 --- a/kernel/printk.c
76935 +++ b/kernel/printk.c
76936 @@ -615,11 +615,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
76937 return ret;
76938 }
76939
76940 +static int check_syslog_permissions(int type, bool from_file);
76941 +
76942 static int devkmsg_open(struct inode *inode, struct file *file)
76943 {
76944 struct devkmsg_user *user;
76945 int err;
76946
76947 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
76948 + if (err)
76949 + return err;
76950 +
76951 /* write-only does not need any file context */
76952 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
76953 return 0;
76954 @@ -828,7 +834,7 @@ static int syslog_action_restricted(int type)
76955 if (dmesg_restrict)
76956 return 1;
76957 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
76958 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76959 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76960 }
76961
76962 static int check_syslog_permissions(int type, bool from_file)
76963 @@ -840,6 +846,11 @@ static int check_syslog_permissions(int type, bool from_file)
76964 if (from_file && type != SYSLOG_ACTION_OPEN)
76965 return 0;
76966
76967 +#ifdef CONFIG_GRKERNSEC_DMESG
76968 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
76969 + return -EPERM;
76970 +#endif
76971 +
76972 if (syslog_action_restricted(type)) {
76973 if (capable(CAP_SYSLOG))
76974 return 0;
76975 diff --git a/kernel/profile.c b/kernel/profile.c
76976 index dc3384e..0de5b49 100644
76977 --- a/kernel/profile.c
76978 +++ b/kernel/profile.c
76979 @@ -37,7 +37,7 @@ struct profile_hit {
76980 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
76981 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
76982
76983 -static atomic_t *prof_buffer;
76984 +static atomic_unchecked_t *prof_buffer;
76985 static unsigned long prof_len, prof_shift;
76986
76987 int prof_on __read_mostly;
76988 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
76989 hits[i].pc = 0;
76990 continue;
76991 }
76992 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76993 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76994 hits[i].hits = hits[i].pc = 0;
76995 }
76996 }
76997 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76998 * Add the current hit(s) and flush the write-queue out
76999 * to the global buffer:
77000 */
77001 - atomic_add(nr_hits, &prof_buffer[pc]);
77002 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77003 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77004 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77005 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77006 hits[i].pc = hits[i].hits = 0;
77007 }
77008 out:
77009 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77010 {
77011 unsigned long pc;
77012 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77013 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77014 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77015 }
77016 #endif /* !CONFIG_SMP */
77017
77018 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77019 return -EFAULT;
77020 buf++; p++; count--; read++;
77021 }
77022 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77023 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77024 if (copy_to_user(buf, (void *)pnt, count))
77025 return -EFAULT;
77026 read += count;
77027 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77028 }
77029 #endif
77030 profile_discard_flip_buffers();
77031 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77032 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77033 return count;
77034 }
77035
77036 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77037 index acbd284..00bb0c9 100644
77038 --- a/kernel/ptrace.c
77039 +++ b/kernel/ptrace.c
77040 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77041 if (seize)
77042 flags |= PT_SEIZED;
77043 rcu_read_lock();
77044 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77045 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77046 flags |= PT_PTRACE_CAP;
77047 rcu_read_unlock();
77048 task->ptrace = flags;
77049 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77050 break;
77051 return -EIO;
77052 }
77053 - if (copy_to_user(dst, buf, retval))
77054 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77055 return -EFAULT;
77056 copied += retval;
77057 src += retval;
77058 @@ -726,7 +726,7 @@ int ptrace_request(struct task_struct *child, long request,
77059 bool seized = child->ptrace & PT_SEIZED;
77060 int ret = -EIO;
77061 siginfo_t siginfo, *si;
77062 - void __user *datavp = (void __user *) data;
77063 + void __user *datavp = (__force void __user *) data;
77064 unsigned long __user *datalp = datavp;
77065 unsigned long flags;
77066
77067 @@ -928,14 +928,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77068 goto out;
77069 }
77070
77071 + if (gr_handle_ptrace(child, request)) {
77072 + ret = -EPERM;
77073 + goto out_put_task_struct;
77074 + }
77075 +
77076 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77077 ret = ptrace_attach(child, request, addr, data);
77078 /*
77079 * Some architectures need to do book-keeping after
77080 * a ptrace attach.
77081 */
77082 - if (!ret)
77083 + if (!ret) {
77084 arch_ptrace_attach(child);
77085 + gr_audit_ptrace(child);
77086 + }
77087 goto out_put_task_struct;
77088 }
77089
77090 @@ -963,7 +970,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77091 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77092 if (copied != sizeof(tmp))
77093 return -EIO;
77094 - return put_user(tmp, (unsigned long __user *)data);
77095 + return put_user(tmp, (__force unsigned long __user *)data);
77096 }
77097
77098 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77099 @@ -1057,7 +1064,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77100 }
77101
77102 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77103 - compat_long_t addr, compat_long_t data)
77104 + compat_ulong_t addr, compat_ulong_t data)
77105 {
77106 struct task_struct *child;
77107 long ret;
77108 @@ -1073,14 +1080,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77109 goto out;
77110 }
77111
77112 + if (gr_handle_ptrace(child, request)) {
77113 + ret = -EPERM;
77114 + goto out_put_task_struct;
77115 + }
77116 +
77117 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77118 ret = ptrace_attach(child, request, addr, data);
77119 /*
77120 * Some architectures need to do book-keeping after
77121 * a ptrace attach.
77122 */
77123 - if (!ret)
77124 + if (!ret) {
77125 arch_ptrace_attach(child);
77126 + gr_audit_ptrace(child);
77127 + }
77128 goto out_put_task_struct;
77129 }
77130
77131 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
77132 index 48ab703..07561d4 100644
77133 --- a/kernel/rcupdate.c
77134 +++ b/kernel/rcupdate.c
77135 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
77136 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77137 */
77138 if (till_stall_check < 3) {
77139 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77140 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77141 till_stall_check = 3;
77142 } else if (till_stall_check > 300) {
77143 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77144 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77145 till_stall_check = 300;
77146 }
77147 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77148 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77149 index a0714a5..2ab5e34 100644
77150 --- a/kernel/rcutiny.c
77151 +++ b/kernel/rcutiny.c
77152 @@ -46,7 +46,7 @@
77153 struct rcu_ctrlblk;
77154 static void invoke_rcu_callbacks(void);
77155 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77156 -static void rcu_process_callbacks(struct softirq_action *unused);
77157 +static void rcu_process_callbacks(void);
77158 static void __call_rcu(struct rcu_head *head,
77159 void (*func)(struct rcu_head *rcu),
77160 struct rcu_ctrlblk *rcp);
77161 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77162 rcu_is_callbacks_kthread()));
77163 }
77164
77165 -static void rcu_process_callbacks(struct softirq_action *unused)
77166 +static void rcu_process_callbacks(void)
77167 {
77168 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77169 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77170 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77171 index 8a23300..4255818 100644
77172 --- a/kernel/rcutiny_plugin.h
77173 +++ b/kernel/rcutiny_plugin.h
77174 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
77175 have_rcu_kthread_work = morework;
77176 local_irq_restore(flags);
77177 if (work)
77178 - rcu_process_callbacks(NULL);
77179 + rcu_process_callbacks();
77180 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77181 }
77182
77183 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77184 index e1f3a8c..42c94a2 100644
77185 --- a/kernel/rcutorture.c
77186 +++ b/kernel/rcutorture.c
77187 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77188 { 0 };
77189 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77190 { 0 };
77191 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77192 -static atomic_t n_rcu_torture_alloc;
77193 -static atomic_t n_rcu_torture_alloc_fail;
77194 -static atomic_t n_rcu_torture_free;
77195 -static atomic_t n_rcu_torture_mberror;
77196 -static atomic_t n_rcu_torture_error;
77197 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77198 +static atomic_unchecked_t n_rcu_torture_alloc;
77199 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77200 +static atomic_unchecked_t n_rcu_torture_free;
77201 +static atomic_unchecked_t n_rcu_torture_mberror;
77202 +static atomic_unchecked_t n_rcu_torture_error;
77203 static long n_rcu_torture_barrier_error;
77204 static long n_rcu_torture_boost_ktrerror;
77205 static long n_rcu_torture_boost_rterror;
77206 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
77207
77208 spin_lock_bh(&rcu_torture_lock);
77209 if (list_empty(&rcu_torture_freelist)) {
77210 - atomic_inc(&n_rcu_torture_alloc_fail);
77211 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77212 spin_unlock_bh(&rcu_torture_lock);
77213 return NULL;
77214 }
77215 - atomic_inc(&n_rcu_torture_alloc);
77216 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77217 p = rcu_torture_freelist.next;
77218 list_del_init(p);
77219 spin_unlock_bh(&rcu_torture_lock);
77220 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
77221 static void
77222 rcu_torture_free(struct rcu_torture *p)
77223 {
77224 - atomic_inc(&n_rcu_torture_free);
77225 + atomic_inc_unchecked(&n_rcu_torture_free);
77226 spin_lock_bh(&rcu_torture_lock);
77227 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77228 spin_unlock_bh(&rcu_torture_lock);
77229 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
77230 i = rp->rtort_pipe_count;
77231 if (i > RCU_TORTURE_PIPE_LEN)
77232 i = RCU_TORTURE_PIPE_LEN;
77233 - atomic_inc(&rcu_torture_wcount[i]);
77234 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77235 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77236 rp->rtort_mbtest = 0;
77237 rcu_torture_free(rp);
77238 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77239 i = rp->rtort_pipe_count;
77240 if (i > RCU_TORTURE_PIPE_LEN)
77241 i = RCU_TORTURE_PIPE_LEN;
77242 - atomic_inc(&rcu_torture_wcount[i]);
77243 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77244 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77245 rp->rtort_mbtest = 0;
77246 list_del(&rp->rtort_free);
77247 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
77248 i = old_rp->rtort_pipe_count;
77249 if (i > RCU_TORTURE_PIPE_LEN)
77250 i = RCU_TORTURE_PIPE_LEN;
77251 - atomic_inc(&rcu_torture_wcount[i]);
77252 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77253 old_rp->rtort_pipe_count++;
77254 cur_ops->deferred_free(old_rp);
77255 }
77256 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
77257 return;
77258 }
77259 if (p->rtort_mbtest == 0)
77260 - atomic_inc(&n_rcu_torture_mberror);
77261 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77262 spin_lock(&rand_lock);
77263 cur_ops->read_delay(&rand);
77264 n_rcu_torture_timers++;
77265 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
77266 continue;
77267 }
77268 if (p->rtort_mbtest == 0)
77269 - atomic_inc(&n_rcu_torture_mberror);
77270 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77271 cur_ops->read_delay(&rand);
77272 preempt_disable();
77273 pipe_count = p->rtort_pipe_count;
77274 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
77275 rcu_torture_current,
77276 rcu_torture_current_version,
77277 list_empty(&rcu_torture_freelist),
77278 - atomic_read(&n_rcu_torture_alloc),
77279 - atomic_read(&n_rcu_torture_alloc_fail),
77280 - atomic_read(&n_rcu_torture_free));
77281 + atomic_read_unchecked(&n_rcu_torture_alloc),
77282 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77283 + atomic_read_unchecked(&n_rcu_torture_free));
77284 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77285 - atomic_read(&n_rcu_torture_mberror),
77286 + atomic_read_unchecked(&n_rcu_torture_mberror),
77287 n_rcu_torture_boost_ktrerror,
77288 n_rcu_torture_boost_rterror);
77289 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77290 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
77291 n_barrier_attempts,
77292 n_rcu_torture_barrier_error);
77293 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77294 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77295 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77296 n_rcu_torture_barrier_error != 0 ||
77297 n_rcu_torture_boost_ktrerror != 0 ||
77298 n_rcu_torture_boost_rterror != 0 ||
77299 n_rcu_torture_boost_failure != 0 ||
77300 i > 1) {
77301 cnt += sprintf(&page[cnt], "!!! ");
77302 - atomic_inc(&n_rcu_torture_error);
77303 + atomic_inc_unchecked(&n_rcu_torture_error);
77304 WARN_ON_ONCE(1);
77305 }
77306 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77307 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
77308 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77309 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77310 cnt += sprintf(&page[cnt], " %d",
77311 - atomic_read(&rcu_torture_wcount[i]));
77312 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77313 }
77314 cnt += sprintf(&page[cnt], "\n");
77315 if (cur_ops->stats)
77316 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
77317
77318 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77319
77320 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77321 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77322 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77323 else if (n_online_successes != n_online_attempts ||
77324 n_offline_successes != n_offline_attempts)
77325 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
77326
77327 rcu_torture_current = NULL;
77328 rcu_torture_current_version = 0;
77329 - atomic_set(&n_rcu_torture_alloc, 0);
77330 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77331 - atomic_set(&n_rcu_torture_free, 0);
77332 - atomic_set(&n_rcu_torture_mberror, 0);
77333 - atomic_set(&n_rcu_torture_error, 0);
77334 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77335 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77336 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77337 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77338 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77339 n_rcu_torture_barrier_error = 0;
77340 n_rcu_torture_boost_ktrerror = 0;
77341 n_rcu_torture_boost_rterror = 0;
77342 n_rcu_torture_boost_failure = 0;
77343 n_rcu_torture_boosts = 0;
77344 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77345 - atomic_set(&rcu_torture_wcount[i], 0);
77346 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77347 for_each_possible_cpu(cpu) {
77348 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77349 per_cpu(rcu_torture_count, cpu)[i] = 0;
77350 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77351 index 5b8ad82..17274d1 100644
77352 --- a/kernel/rcutree.c
77353 +++ b/kernel/rcutree.c
77354 @@ -353,9 +353,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77355 rcu_prepare_for_idle(smp_processor_id());
77356 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77357 smp_mb__before_atomic_inc(); /* See above. */
77358 - atomic_inc(&rdtp->dynticks);
77359 + atomic_inc_unchecked(&rdtp->dynticks);
77360 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77361 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77362 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77363
77364 /*
77365 * It is illegal to enter an extended quiescent state while
77366 @@ -491,10 +491,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77367 int user)
77368 {
77369 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77370 - atomic_inc(&rdtp->dynticks);
77371 + atomic_inc_unchecked(&rdtp->dynticks);
77372 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77373 smp_mb__after_atomic_inc(); /* See above. */
77374 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77375 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77376 rcu_cleanup_after_idle(smp_processor_id());
77377 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77378 if (!user && !is_idle_task(current)) {
77379 @@ -633,14 +633,14 @@ void rcu_nmi_enter(void)
77380 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77381
77382 if (rdtp->dynticks_nmi_nesting == 0 &&
77383 - (atomic_read(&rdtp->dynticks) & 0x1))
77384 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77385 return;
77386 rdtp->dynticks_nmi_nesting++;
77387 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77388 - atomic_inc(&rdtp->dynticks);
77389 + atomic_inc_unchecked(&rdtp->dynticks);
77390 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77391 smp_mb__after_atomic_inc(); /* See above. */
77392 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77393 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77394 }
77395
77396 /**
77397 @@ -659,9 +659,9 @@ void rcu_nmi_exit(void)
77398 return;
77399 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77400 smp_mb__before_atomic_inc(); /* See above. */
77401 - atomic_inc(&rdtp->dynticks);
77402 + atomic_inc_unchecked(&rdtp->dynticks);
77403 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77404 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77405 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77406 }
77407
77408 /**
77409 @@ -675,7 +675,7 @@ int rcu_is_cpu_idle(void)
77410 int ret;
77411
77412 preempt_disable();
77413 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77414 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77415 preempt_enable();
77416 return ret;
77417 }
77418 @@ -743,7 +743,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
77419 */
77420 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77421 {
77422 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77423 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77424 return (rdp->dynticks_snap & 0x1) == 0;
77425 }
77426
77427 @@ -758,7 +758,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77428 unsigned int curr;
77429 unsigned int snap;
77430
77431 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77432 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77433 snap = (unsigned int)rdp->dynticks_snap;
77434
77435 /*
77436 @@ -1698,7 +1698,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77437 rsp->qlen += rdp->qlen;
77438 rdp->n_cbs_orphaned += rdp->qlen;
77439 rdp->qlen_lazy = 0;
77440 - ACCESS_ONCE(rdp->qlen) = 0;
77441 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77442 }
77443
77444 /*
77445 @@ -1944,7 +1944,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77446 }
77447 smp_mb(); /* List handling before counting for rcu_barrier(). */
77448 rdp->qlen_lazy -= count_lazy;
77449 - ACCESS_ONCE(rdp->qlen) -= count;
77450 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77451 rdp->n_cbs_invoked += count;
77452
77453 /* Reinstate batch limit if we have worked down the excess. */
77454 @@ -2137,7 +2137,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77455 /*
77456 * Do RCU core processing for the current CPU.
77457 */
77458 -static void rcu_process_callbacks(struct softirq_action *unused)
77459 +static void rcu_process_callbacks(void)
77460 {
77461 struct rcu_state *rsp;
77462
77463 @@ -2260,7 +2260,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
77464 local_irq_restore(flags);
77465 return;
77466 }
77467 - ACCESS_ONCE(rdp->qlen)++;
77468 + ACCESS_ONCE_RW(rdp->qlen)++;
77469 if (lazy)
77470 rdp->qlen_lazy++;
77471 else
77472 @@ -2469,11 +2469,11 @@ void synchronize_sched_expedited(void)
77473 * counter wrap on a 32-bit system. Quite a few more CPUs would of
77474 * course be required on a 64-bit system.
77475 */
77476 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77477 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77478 (ulong)atomic_long_read(&rsp->expedited_done) +
77479 ULONG_MAX / 8)) {
77480 synchronize_sched();
77481 - atomic_long_inc(&rsp->expedited_wrap);
77482 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77483 return;
77484 }
77485
77486 @@ -2481,7 +2481,7 @@ void synchronize_sched_expedited(void)
77487 * Take a ticket. Note that atomic_inc_return() implies a
77488 * full memory barrier.
77489 */
77490 - snap = atomic_long_inc_return(&rsp->expedited_start);
77491 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77492 firstsnap = snap;
77493 get_online_cpus();
77494 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77495 @@ -2494,14 +2494,14 @@ void synchronize_sched_expedited(void)
77496 synchronize_sched_expedited_cpu_stop,
77497 NULL) == -EAGAIN) {
77498 put_online_cpus();
77499 - atomic_long_inc(&rsp->expedited_tryfail);
77500 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77501
77502 /* Check to see if someone else did our work for us. */
77503 s = atomic_long_read(&rsp->expedited_done);
77504 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77505 /* ensure test happens before caller kfree */
77506 smp_mb__before_atomic_inc(); /* ^^^ */
77507 - atomic_long_inc(&rsp->expedited_workdone1);
77508 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77509 return;
77510 }
77511
77512 @@ -2510,7 +2510,7 @@ void synchronize_sched_expedited(void)
77513 udelay(trycount * num_online_cpus());
77514 } else {
77515 wait_rcu_gp(call_rcu_sched);
77516 - atomic_long_inc(&rsp->expedited_normal);
77517 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77518 return;
77519 }
77520
77521 @@ -2519,7 +2519,7 @@ void synchronize_sched_expedited(void)
77522 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77523 /* ensure test happens before caller kfree */
77524 smp_mb__before_atomic_inc(); /* ^^^ */
77525 - atomic_long_inc(&rsp->expedited_workdone2);
77526 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77527 return;
77528 }
77529
77530 @@ -2531,10 +2531,10 @@ void synchronize_sched_expedited(void)
77531 * period works for us.
77532 */
77533 get_online_cpus();
77534 - snap = atomic_long_read(&rsp->expedited_start);
77535 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77536 smp_mb(); /* ensure read is before try_stop_cpus(). */
77537 }
77538 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77539 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77540
77541 /*
77542 * Everyone up to our most recent fetch is covered by our grace
77543 @@ -2543,16 +2543,16 @@ void synchronize_sched_expedited(void)
77544 * than we did already did their update.
77545 */
77546 do {
77547 - atomic_long_inc(&rsp->expedited_done_tries);
77548 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77549 s = atomic_long_read(&rsp->expedited_done);
77550 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77551 /* ensure test happens before caller kfree */
77552 smp_mb__before_atomic_inc(); /* ^^^ */
77553 - atomic_long_inc(&rsp->expedited_done_lost);
77554 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77555 break;
77556 }
77557 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77558 - atomic_long_inc(&rsp->expedited_done_exit);
77559 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77560
77561 put_online_cpus();
77562 }
77563 @@ -2726,7 +2726,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77564 * ACCESS_ONCE() to prevent the compiler from speculating
77565 * the increment to precede the early-exit check.
77566 */
77567 - ACCESS_ONCE(rsp->n_barrier_done)++;
77568 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77569 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77570 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77571 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
77572 @@ -2776,7 +2776,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77573
77574 /* Increment ->n_barrier_done to prevent duplicate work. */
77575 smp_mb(); /* Keep increment after above mechanism. */
77576 - ACCESS_ONCE(rsp->n_barrier_done)++;
77577 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77578 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
77579 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
77580 smp_mb(); /* Keep increment before caller's subsequent code. */
77581 @@ -2821,10 +2821,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
77582 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
77583 init_callback_list(rdp);
77584 rdp->qlen_lazy = 0;
77585 - ACCESS_ONCE(rdp->qlen) = 0;
77586 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77587 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
77588 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
77589 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
77590 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
77591 rdp->cpu = cpu;
77592 rdp->rsp = rsp;
77593 rcu_boot_init_nocb_percpu_data(rdp);
77594 @@ -2857,8 +2857,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
77595 rdp->blimit = blimit;
77596 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
77597 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
77598 - atomic_set(&rdp->dynticks->dynticks,
77599 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
77600 + atomic_set_unchecked(&rdp->dynticks->dynticks,
77601 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
77602 rcu_prepare_for_idle_init(cpu);
77603 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
77604
77605 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
77606 index c896b50..c357252 100644
77607 --- a/kernel/rcutree.h
77608 +++ b/kernel/rcutree.h
77609 @@ -86,7 +86,7 @@ struct rcu_dynticks {
77610 long long dynticks_nesting; /* Track irq/process nesting level. */
77611 /* Process level is worth LLONG_MAX/2. */
77612 int dynticks_nmi_nesting; /* Track NMI nesting level. */
77613 - atomic_t dynticks; /* Even value for idle, else odd. */
77614 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
77615 #ifdef CONFIG_RCU_FAST_NO_HZ
77616 int dyntick_drain; /* Prepare-for-idle state variable. */
77617 unsigned long dyntick_holdoff;
77618 @@ -416,17 +416,17 @@ struct rcu_state {
77619 /* _rcu_barrier(). */
77620 /* End of fields guarded by barrier_mutex. */
77621
77622 - atomic_long_t expedited_start; /* Starting ticket. */
77623 - atomic_long_t expedited_done; /* Done ticket. */
77624 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
77625 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
77626 - atomic_long_t expedited_workdone1; /* # done by others #1. */
77627 - atomic_long_t expedited_workdone2; /* # done by others #2. */
77628 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
77629 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
77630 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
77631 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
77632 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
77633 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
77634 + atomic_long_t expedited_done; /* Done ticket. */
77635 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
77636 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
77637 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
77638 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
77639 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
77640 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
77641 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
77642 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
77643 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
77644
77645 unsigned long jiffies_force_qs; /* Time at which to invoke */
77646 /* force_quiescent_state(). */
77647 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
77648 index c1cc7e1..f62e436 100644
77649 --- a/kernel/rcutree_plugin.h
77650 +++ b/kernel/rcutree_plugin.h
77651 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
77652
77653 /* Clean up and exit. */
77654 smp_mb(); /* ensure expedited GP seen before counter increment. */
77655 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
77656 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
77657 unlock_mb_ret:
77658 mutex_unlock(&sync_rcu_preempt_exp_mutex);
77659 mb_ret:
77660 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
77661 free_cpumask_var(cm);
77662 }
77663
77664 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
77665 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
77666 .store = &rcu_cpu_kthread_task,
77667 .thread_should_run = rcu_cpu_kthread_should_run,
77668 .thread_fn = rcu_cpu_kthread,
77669 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
77670 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
77671 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
77672 cpu, ticks_value, ticks_title,
77673 - atomic_read(&rdtp->dynticks) & 0xfff,
77674 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
77675 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
77676 fast_no_hz);
77677 }
77678 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
77679
77680 /* Enqueue the callback on the nocb list and update counts. */
77681 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
77682 - ACCESS_ONCE(*old_rhpp) = rhp;
77683 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
77684 atomic_long_add(rhcount, &rdp->nocb_q_count);
77685 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
77686
77687 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
77688 * Extract queued callbacks, update counts, and wait
77689 * for a grace period to elapse.
77690 */
77691 - ACCESS_ONCE(rdp->nocb_head) = NULL;
77692 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
77693 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
77694 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
77695 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
77696 - ACCESS_ONCE(rdp->nocb_p_count) += c;
77697 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
77698 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
77699 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
77700 wait_rcu_gp(rdp->rsp->call_remote);
77701
77702 /* Each pass through the following loop invokes a callback. */
77703 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
77704 list = next;
77705 }
77706 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
77707 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
77708 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
77709 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
77710 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
77711 rdp->n_nocbs_invoked += c;
77712 }
77713 return 0;
77714 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
77715 rdp = per_cpu_ptr(rsp->rda, cpu);
77716 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
77717 BUG_ON(IS_ERR(t));
77718 - ACCESS_ONCE(rdp->nocb_kthread) = t;
77719 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
77720 }
77721 }
77722
77723 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
77724 index 93f8e8f..cf812ae 100644
77725 --- a/kernel/rcutree_trace.c
77726 +++ b/kernel/rcutree_trace.c
77727 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
77728 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
77729 rdp->passed_quiesce, rdp->qs_pending);
77730 seq_printf(m, " dt=%d/%llx/%d df=%lu",
77731 - atomic_read(&rdp->dynticks->dynticks),
77732 + atomic_read_unchecked(&rdp->dynticks->dynticks),
77733 rdp->dynticks->dynticks_nesting,
77734 rdp->dynticks->dynticks_nmi_nesting,
77735 rdp->dynticks_fqs);
77736 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
77737 struct rcu_state *rsp = (struct rcu_state *)m->private;
77738
77739 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",
77740 - atomic_long_read(&rsp->expedited_start),
77741 + atomic_long_read_unchecked(&rsp->expedited_start),
77742 atomic_long_read(&rsp->expedited_done),
77743 - atomic_long_read(&rsp->expedited_wrap),
77744 - atomic_long_read(&rsp->expedited_tryfail),
77745 - atomic_long_read(&rsp->expedited_workdone1),
77746 - atomic_long_read(&rsp->expedited_workdone2),
77747 - atomic_long_read(&rsp->expedited_normal),
77748 - atomic_long_read(&rsp->expedited_stoppedcpus),
77749 - atomic_long_read(&rsp->expedited_done_tries),
77750 - atomic_long_read(&rsp->expedited_done_lost),
77751 - atomic_long_read(&rsp->expedited_done_exit));
77752 + atomic_long_read_unchecked(&rsp->expedited_wrap),
77753 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
77754 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
77755 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
77756 + atomic_long_read_unchecked(&rsp->expedited_normal),
77757 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
77758 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
77759 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
77760 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
77761 return 0;
77762 }
77763
77764 diff --git a/kernel/resource.c b/kernel/resource.c
77765 index 73f35d4..4684fc4 100644
77766 --- a/kernel/resource.c
77767 +++ b/kernel/resource.c
77768 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
77769
77770 static int __init ioresources_init(void)
77771 {
77772 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
77773 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77774 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
77775 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
77776 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77777 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
77778 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
77779 +#endif
77780 +#else
77781 proc_create("ioports", 0, NULL, &proc_ioports_operations);
77782 proc_create("iomem", 0, NULL, &proc_iomem_operations);
77783 +#endif
77784 return 0;
77785 }
77786 __initcall(ioresources_init);
77787 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
77788 index 7890b10..8b68605f 100644
77789 --- a/kernel/rtmutex-tester.c
77790 +++ b/kernel/rtmutex-tester.c
77791 @@ -21,7 +21,7 @@
77792 #define MAX_RT_TEST_MUTEXES 8
77793
77794 static spinlock_t rttest_lock;
77795 -static atomic_t rttest_event;
77796 +static atomic_unchecked_t rttest_event;
77797
77798 struct test_thread_data {
77799 int opcode;
77800 @@ -62,7 +62,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77801
77802 case RTTEST_LOCKCONT:
77803 td->mutexes[td->opdata] = 1;
77804 - td->event = atomic_add_return(1, &rttest_event);
77805 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77806 return 0;
77807
77808 case RTTEST_RESET:
77809 @@ -75,7 +75,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77810 return 0;
77811
77812 case RTTEST_RESETEVENT:
77813 - atomic_set(&rttest_event, 0);
77814 + atomic_set_unchecked(&rttest_event, 0);
77815 return 0;
77816
77817 default:
77818 @@ -92,9 +92,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77819 return ret;
77820
77821 td->mutexes[id] = 1;
77822 - td->event = atomic_add_return(1, &rttest_event);
77823 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77824 rt_mutex_lock(&mutexes[id]);
77825 - td->event = atomic_add_return(1, &rttest_event);
77826 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77827 td->mutexes[id] = 4;
77828 return 0;
77829
77830 @@ -105,9 +105,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77831 return ret;
77832
77833 td->mutexes[id] = 1;
77834 - td->event = atomic_add_return(1, &rttest_event);
77835 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77836 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
77837 - td->event = atomic_add_return(1, &rttest_event);
77838 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77839 td->mutexes[id] = ret ? 0 : 4;
77840 return ret ? -EINTR : 0;
77841
77842 @@ -116,9 +116,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77843 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
77844 return ret;
77845
77846 - td->event = atomic_add_return(1, &rttest_event);
77847 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77848 rt_mutex_unlock(&mutexes[id]);
77849 - td->event = atomic_add_return(1, &rttest_event);
77850 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77851 td->mutexes[id] = 0;
77852 return 0;
77853
77854 @@ -165,7 +165,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77855 break;
77856
77857 td->mutexes[dat] = 2;
77858 - td->event = atomic_add_return(1, &rttest_event);
77859 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77860 break;
77861
77862 default:
77863 @@ -185,7 +185,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77864 return;
77865
77866 td->mutexes[dat] = 3;
77867 - td->event = atomic_add_return(1, &rttest_event);
77868 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77869 break;
77870
77871 case RTTEST_LOCKNOWAIT:
77872 @@ -197,7 +197,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77873 return;
77874
77875 td->mutexes[dat] = 1;
77876 - td->event = atomic_add_return(1, &rttest_event);
77877 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77878 return;
77879
77880 default:
77881 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
77882 index 64de5f8..7735e12 100644
77883 --- a/kernel/sched/auto_group.c
77884 +++ b/kernel/sched/auto_group.c
77885 @@ -11,7 +11,7 @@
77886
77887 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
77888 static struct autogroup autogroup_default;
77889 -static atomic_t autogroup_seq_nr;
77890 +static atomic_unchecked_t autogroup_seq_nr;
77891
77892 void __init autogroup_init(struct task_struct *init_task)
77893 {
77894 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
77895
77896 kref_init(&ag->kref);
77897 init_rwsem(&ag->lock);
77898 - ag->id = atomic_inc_return(&autogroup_seq_nr);
77899 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
77900 ag->tg = tg;
77901 #ifdef CONFIG_RT_GROUP_SCHED
77902 /*
77903 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
77904 index 67d0465..4cf9361 100644
77905 --- a/kernel/sched/core.c
77906 +++ b/kernel/sched/core.c
77907 @@ -3406,7 +3406,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
77908 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77909 * positive (at least 1, or number of jiffies left till timeout) if completed.
77910 */
77911 -long __sched
77912 +long __sched __intentional_overflow(-1)
77913 wait_for_completion_interruptible_timeout(struct completion *x,
77914 unsigned long timeout)
77915 {
77916 @@ -3423,7 +3423,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
77917 *
77918 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
77919 */
77920 -int __sched wait_for_completion_killable(struct completion *x)
77921 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
77922 {
77923 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
77924 if (t == -ERESTARTSYS)
77925 @@ -3444,7 +3444,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
77926 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77927 * positive (at least 1, or number of jiffies left till timeout) if completed.
77928 */
77929 -long __sched
77930 +long __sched __intentional_overflow(-1)
77931 wait_for_completion_killable_timeout(struct completion *x,
77932 unsigned long timeout)
77933 {
77934 @@ -3670,6 +3670,8 @@ int can_nice(const struct task_struct *p, const int nice)
77935 /* convert nice value [19,-20] to rlimit style value [1,40] */
77936 int nice_rlim = 20 - nice;
77937
77938 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
77939 +
77940 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
77941 capable(CAP_SYS_NICE));
77942 }
77943 @@ -3703,7 +3705,8 @@ SYSCALL_DEFINE1(nice, int, increment)
77944 if (nice > 19)
77945 nice = 19;
77946
77947 - if (increment < 0 && !can_nice(current, nice))
77948 + if (increment < 0 && (!can_nice(current, nice) ||
77949 + gr_handle_chroot_nice()))
77950 return -EPERM;
77951
77952 retval = security_task_setnice(current, nice);
77953 @@ -3857,6 +3860,7 @@ recheck:
77954 unsigned long rlim_rtprio =
77955 task_rlimit(p, RLIMIT_RTPRIO);
77956
77957 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
77958 /* can't set/change the rt policy */
77959 if (policy != p->policy && !rlim_rtprio)
77960 return -EPERM;
77961 @@ -4954,7 +4958,7 @@ static void migrate_tasks(unsigned int dead_cpu)
77962
77963 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
77964
77965 -static struct ctl_table sd_ctl_dir[] = {
77966 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
77967 {
77968 .procname = "sched_domain",
77969 .mode = 0555,
77970 @@ -4971,17 +4975,17 @@ static struct ctl_table sd_ctl_root[] = {
77971 {}
77972 };
77973
77974 -static struct ctl_table *sd_alloc_ctl_entry(int n)
77975 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
77976 {
77977 - struct ctl_table *entry =
77978 + ctl_table_no_const *entry =
77979 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
77980
77981 return entry;
77982 }
77983
77984 -static void sd_free_ctl_entry(struct ctl_table **tablep)
77985 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
77986 {
77987 - struct ctl_table *entry;
77988 + ctl_table_no_const *entry;
77989
77990 /*
77991 * In the intermediate directories, both the child directory and
77992 @@ -4989,22 +4993,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
77993 * will always be set. In the lowest directory the names are
77994 * static strings and all have proc handlers.
77995 */
77996 - for (entry = *tablep; entry->mode; entry++) {
77997 - if (entry->child)
77998 - sd_free_ctl_entry(&entry->child);
77999 + for (entry = tablep; entry->mode; entry++) {
78000 + if (entry->child) {
78001 + sd_free_ctl_entry(entry->child);
78002 + pax_open_kernel();
78003 + entry->child = NULL;
78004 + pax_close_kernel();
78005 + }
78006 if (entry->proc_handler == NULL)
78007 kfree(entry->procname);
78008 }
78009
78010 - kfree(*tablep);
78011 - *tablep = NULL;
78012 + kfree(tablep);
78013 }
78014
78015 static int min_load_idx = 0;
78016 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78017
78018 static void
78019 -set_table_entry(struct ctl_table *entry,
78020 +set_table_entry(ctl_table_no_const *entry,
78021 const char *procname, void *data, int maxlen,
78022 umode_t mode, proc_handler *proc_handler,
78023 bool load_idx)
78024 @@ -5024,7 +5031,7 @@ set_table_entry(struct ctl_table *entry,
78025 static struct ctl_table *
78026 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78027 {
78028 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78029 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78030
78031 if (table == NULL)
78032 return NULL;
78033 @@ -5059,9 +5066,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78034 return table;
78035 }
78036
78037 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78038 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78039 {
78040 - struct ctl_table *entry, *table;
78041 + ctl_table_no_const *entry, *table;
78042 struct sched_domain *sd;
78043 int domain_num = 0, i;
78044 char buf[32];
78045 @@ -5088,11 +5095,13 @@ static struct ctl_table_header *sd_sysctl_header;
78046 static void register_sched_domain_sysctl(void)
78047 {
78048 int i, cpu_num = num_possible_cpus();
78049 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78050 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78051 char buf[32];
78052
78053 WARN_ON(sd_ctl_dir[0].child);
78054 + pax_open_kernel();
78055 sd_ctl_dir[0].child = entry;
78056 + pax_close_kernel();
78057
78058 if (entry == NULL)
78059 return;
78060 @@ -5115,8 +5124,12 @@ static void unregister_sched_domain_sysctl(void)
78061 if (sd_sysctl_header)
78062 unregister_sysctl_table(sd_sysctl_header);
78063 sd_sysctl_header = NULL;
78064 - if (sd_ctl_dir[0].child)
78065 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78066 + if (sd_ctl_dir[0].child) {
78067 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78068 + pax_open_kernel();
78069 + sd_ctl_dir[0].child = NULL;
78070 + pax_close_kernel();
78071 + }
78072 }
78073 #else
78074 static void register_sched_domain_sysctl(void)
78075 @@ -5215,7 +5228,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78076 * happens before everything else. This has to be lower priority than
78077 * the notifier in the perf_event subsystem, though.
78078 */
78079 -static struct notifier_block __cpuinitdata migration_notifier = {
78080 +static struct notifier_block migration_notifier = {
78081 .notifier_call = migration_call,
78082 .priority = CPU_PRI_MIGRATION,
78083 };
78084 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78085 index 7a33e59..2f7730c 100644
78086 --- a/kernel/sched/fair.c
78087 +++ b/kernel/sched/fair.c
78088 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78089
78090 static void reset_ptenuma_scan(struct task_struct *p)
78091 {
78092 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78093 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78094 p->mm->numa_scan_offset = 0;
78095 }
78096
78097 @@ -5654,7 +5654,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78098 * run_rebalance_domains is triggered when needed from the scheduler tick.
78099 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78100 */
78101 -static void run_rebalance_domains(struct softirq_action *h)
78102 +static void run_rebalance_domains(void)
78103 {
78104 int this_cpu = smp_processor_id();
78105 struct rq *this_rq = cpu_rq(this_cpu);
78106 diff --git a/kernel/signal.c b/kernel/signal.c
78107 index 598dc06..471310a 100644
78108 --- a/kernel/signal.c
78109 +++ b/kernel/signal.c
78110 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78111
78112 int print_fatal_signals __read_mostly;
78113
78114 -static void __user *sig_handler(struct task_struct *t, int sig)
78115 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78116 {
78117 return t->sighand->action[sig - 1].sa.sa_handler;
78118 }
78119
78120 -static int sig_handler_ignored(void __user *handler, int sig)
78121 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78122 {
78123 /* Is it explicitly or implicitly ignored? */
78124 return handler == SIG_IGN ||
78125 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78126
78127 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78128 {
78129 - void __user *handler;
78130 + __sighandler_t handler;
78131
78132 handler = sig_handler(t, sig);
78133
78134 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78135 atomic_inc(&user->sigpending);
78136 rcu_read_unlock();
78137
78138 + if (!override_rlimit)
78139 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78140 +
78141 if (override_rlimit ||
78142 atomic_read(&user->sigpending) <=
78143 task_rlimit(t, RLIMIT_SIGPENDING)) {
78144 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78145
78146 int unhandled_signal(struct task_struct *tsk, int sig)
78147 {
78148 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78149 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78150 if (is_global_init(tsk))
78151 return 1;
78152 if (handler != SIG_IGN && handler != SIG_DFL)
78153 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78154 }
78155 }
78156
78157 + /* allow glibc communication via tgkill to other threads in our
78158 + thread group */
78159 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78160 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78161 + && gr_handle_signal(t, sig))
78162 + return -EPERM;
78163 +
78164 return security_task_kill(t, info, sig, 0);
78165 }
78166
78167 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78168 return send_signal(sig, info, p, 1);
78169 }
78170
78171 -static int
78172 +int
78173 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78174 {
78175 return send_signal(sig, info, t, 0);
78176 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78177 unsigned long int flags;
78178 int ret, blocked, ignored;
78179 struct k_sigaction *action;
78180 + int is_unhandled = 0;
78181
78182 spin_lock_irqsave(&t->sighand->siglock, flags);
78183 action = &t->sighand->action[sig-1];
78184 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78185 }
78186 if (action->sa.sa_handler == SIG_DFL)
78187 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78188 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78189 + is_unhandled = 1;
78190 ret = specific_send_sig_info(sig, info, t);
78191 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78192
78193 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78194 + normal operation */
78195 + if (is_unhandled) {
78196 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78197 + gr_handle_crash(t, sig);
78198 + }
78199 +
78200 return ret;
78201 }
78202
78203 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78204 ret = check_kill_permission(sig, info, p);
78205 rcu_read_unlock();
78206
78207 - if (!ret && sig)
78208 + if (!ret && sig) {
78209 ret = do_send_sig_info(sig, info, p, true);
78210 + if (!ret)
78211 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78212 + }
78213
78214 return ret;
78215 }
78216 @@ -2923,7 +2946,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78217 int error = -ESRCH;
78218
78219 rcu_read_lock();
78220 - p = find_task_by_vpid(pid);
78221 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78222 + /* allow glibc communication via tgkill to other threads in our
78223 + thread group */
78224 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78225 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78226 + p = find_task_by_vpid_unrestricted(pid);
78227 + else
78228 +#endif
78229 + p = find_task_by_vpid(pid);
78230 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78231 error = check_kill_permission(sig, info, p);
78232 /*
78233 @@ -3237,8 +3268,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78234 }
78235 seg = get_fs();
78236 set_fs(KERNEL_DS);
78237 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78238 - (stack_t __force __user *) &uoss,
78239 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78240 + (stack_t __force_user *) &uoss,
78241 compat_user_stack_pointer());
78242 set_fs(seg);
78243 if (ret >= 0 && uoss_ptr) {
78244 diff --git a/kernel/smp.c b/kernel/smp.c
78245 index 8e451f3..8322029 100644
78246 --- a/kernel/smp.c
78247 +++ b/kernel/smp.c
78248 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78249 return NOTIFY_OK;
78250 }
78251
78252 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78253 +static struct notifier_block hotplug_cfd_notifier = {
78254 .notifier_call = hotplug_cfd,
78255 };
78256
78257 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78258 index 02fc5c9..e54c335 100644
78259 --- a/kernel/smpboot.c
78260 +++ b/kernel/smpboot.c
78261 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78262 }
78263 smpboot_unpark_thread(plug_thread, cpu);
78264 }
78265 - list_add(&plug_thread->list, &hotplug_threads);
78266 + pax_list_add(&plug_thread->list, &hotplug_threads);
78267 out:
78268 mutex_unlock(&smpboot_threads_lock);
78269 return ret;
78270 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78271 {
78272 get_online_cpus();
78273 mutex_lock(&smpboot_threads_lock);
78274 - list_del(&plug_thread->list);
78275 + pax_list_del(&plug_thread->list);
78276 smpboot_destroy_threads(plug_thread);
78277 mutex_unlock(&smpboot_threads_lock);
78278 put_online_cpus();
78279 diff --git a/kernel/softirq.c b/kernel/softirq.c
78280 index 14d7758..012121f 100644
78281 --- a/kernel/softirq.c
78282 +++ b/kernel/softirq.c
78283 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78284 EXPORT_SYMBOL(irq_stat);
78285 #endif
78286
78287 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78288 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78289
78290 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78291
78292 -char *softirq_to_name[NR_SOFTIRQS] = {
78293 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78294 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78295 "TASKLET", "SCHED", "HRTIMER", "RCU"
78296 };
78297 @@ -244,7 +244,7 @@ restart:
78298 kstat_incr_softirqs_this_cpu(vec_nr);
78299
78300 trace_softirq_entry(vec_nr);
78301 - h->action(h);
78302 + h->action();
78303 trace_softirq_exit(vec_nr);
78304 if (unlikely(prev_count != preempt_count())) {
78305 printk(KERN_ERR "huh, entered softirq %u %s %p"
78306 @@ -389,7 +389,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78307 or_softirq_pending(1UL << nr);
78308 }
78309
78310 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78311 +void __init open_softirq(int nr, void (*action)(void))
78312 {
78313 softirq_vec[nr].action = action;
78314 }
78315 @@ -445,7 +445,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78316
78317 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78318
78319 -static void tasklet_action(struct softirq_action *a)
78320 +static void tasklet_action(void)
78321 {
78322 struct tasklet_struct *list;
78323
78324 @@ -480,7 +480,7 @@ static void tasklet_action(struct softirq_action *a)
78325 }
78326 }
78327
78328 -static void tasklet_hi_action(struct softirq_action *a)
78329 +static void tasklet_hi_action(void)
78330 {
78331 struct tasklet_struct *list;
78332
78333 @@ -716,7 +716,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78334 return NOTIFY_OK;
78335 }
78336
78337 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78338 +static struct notifier_block remote_softirq_cpu_notifier = {
78339 .notifier_call = remote_softirq_cpu_notify,
78340 };
78341
78342 @@ -833,11 +833,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78343 return NOTIFY_OK;
78344 }
78345
78346 -static struct notifier_block __cpuinitdata cpu_nfb = {
78347 +static struct notifier_block cpu_nfb = {
78348 .notifier_call = cpu_callback
78349 };
78350
78351 -static struct smp_hotplug_thread softirq_threads = {
78352 +static struct smp_hotplug_thread softirq_threads __read_only = {
78353 .store = &ksoftirqd,
78354 .thread_should_run = ksoftirqd_should_run,
78355 .thread_fn = run_ksoftirqd,
78356 diff --git a/kernel/srcu.c b/kernel/srcu.c
78357 index 01d5ccb..cdcbee6 100644
78358 --- a/kernel/srcu.c
78359 +++ b/kernel/srcu.c
78360 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78361
78362 idx = ACCESS_ONCE(sp->completed) & 0x1;
78363 preempt_disable();
78364 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78365 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78366 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78367 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78368 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78369 preempt_enable();
78370 return idx;
78371 }
78372 diff --git a/kernel/sys.c b/kernel/sys.c
78373 index 0da73cf..a22106a 100644
78374 --- a/kernel/sys.c
78375 +++ b/kernel/sys.c
78376 @@ -158,6 +158,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78377 error = -EACCES;
78378 goto out;
78379 }
78380 +
78381 + if (gr_handle_chroot_setpriority(p, niceval)) {
78382 + error = -EACCES;
78383 + goto out;
78384 + }
78385 +
78386 no_nice = security_task_setnice(p, niceval);
78387 if (no_nice) {
78388 error = no_nice;
78389 @@ -598,6 +604,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78390 goto error;
78391 }
78392
78393 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78394 + goto error;
78395 +
78396 if (rgid != (gid_t) -1 ||
78397 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78398 new->sgid = new->egid;
78399 @@ -633,6 +642,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78400 old = current_cred();
78401
78402 retval = -EPERM;
78403 +
78404 + if (gr_check_group_change(kgid, kgid, kgid))
78405 + goto error;
78406 +
78407 if (nsown_capable(CAP_SETGID))
78408 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78409 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78410 @@ -650,7 +663,7 @@ error:
78411 /*
78412 * change the user struct in a credentials set to match the new UID
78413 */
78414 -static int set_user(struct cred *new)
78415 +int set_user(struct cred *new)
78416 {
78417 struct user_struct *new_user;
78418
78419 @@ -730,6 +743,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78420 goto error;
78421 }
78422
78423 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78424 + goto error;
78425 +
78426 if (!uid_eq(new->uid, old->uid)) {
78427 retval = set_user(new);
78428 if (retval < 0)
78429 @@ -780,6 +796,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78430 old = current_cred();
78431
78432 retval = -EPERM;
78433 +
78434 + if (gr_check_crash_uid(kuid))
78435 + goto error;
78436 + if (gr_check_user_change(kuid, kuid, kuid))
78437 + goto error;
78438 +
78439 if (nsown_capable(CAP_SETUID)) {
78440 new->suid = new->uid = kuid;
78441 if (!uid_eq(kuid, old->uid)) {
78442 @@ -849,6 +871,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78443 goto error;
78444 }
78445
78446 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78447 + goto error;
78448 +
78449 if (ruid != (uid_t) -1) {
78450 new->uid = kruid;
78451 if (!uid_eq(kruid, old->uid)) {
78452 @@ -931,6 +956,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78453 goto error;
78454 }
78455
78456 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78457 + goto error;
78458 +
78459 if (rgid != (gid_t) -1)
78460 new->gid = krgid;
78461 if (egid != (gid_t) -1)
78462 @@ -992,12 +1020,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78463 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
78464 nsown_capable(CAP_SETUID)) {
78465 if (!uid_eq(kuid, old->fsuid)) {
78466 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78467 + goto error;
78468 +
78469 new->fsuid = kuid;
78470 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
78471 goto change_okay;
78472 }
78473 }
78474
78475 +error:
78476 abort_creds(new);
78477 return old_fsuid;
78478
78479 @@ -1030,12 +1062,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78480 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78481 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78482 nsown_capable(CAP_SETGID)) {
78483 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78484 + goto error;
78485 +
78486 if (!gid_eq(kgid, old->fsgid)) {
78487 new->fsgid = kgid;
78488 goto change_okay;
78489 }
78490 }
78491
78492 +error:
78493 abort_creds(new);
78494 return old_fsgid;
78495
78496 @@ -1343,19 +1379,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78497 return -EFAULT;
78498
78499 down_read(&uts_sem);
78500 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78501 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78502 __OLD_UTS_LEN);
78503 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78504 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78505 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78506 __OLD_UTS_LEN);
78507 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78508 - error |= __copy_to_user(&name->release, &utsname()->release,
78509 + error |= __copy_to_user(name->release, &utsname()->release,
78510 __OLD_UTS_LEN);
78511 error |= __put_user(0, name->release + __OLD_UTS_LEN);
78512 - error |= __copy_to_user(&name->version, &utsname()->version,
78513 + error |= __copy_to_user(name->version, &utsname()->version,
78514 __OLD_UTS_LEN);
78515 error |= __put_user(0, name->version + __OLD_UTS_LEN);
78516 - error |= __copy_to_user(&name->machine, &utsname()->machine,
78517 + error |= __copy_to_user(name->machine, &utsname()->machine,
78518 __OLD_UTS_LEN);
78519 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
78520 up_read(&uts_sem);
78521 @@ -1557,6 +1593,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
78522 */
78523 new_rlim->rlim_cur = 1;
78524 }
78525 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
78526 + is changed to a lower value. Since tasks can be created by the same
78527 + user in between this limit change and an execve by this task, force
78528 + a recheck only for this task by setting PF_NPROC_EXCEEDED
78529 + */
78530 + if (resource == RLIMIT_NPROC)
78531 + tsk->flags |= PF_NPROC_EXCEEDED;
78532 }
78533 if (!retval) {
78534 if (old_rlim)
78535 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
78536 index afc1dc6..5e28bbf 100644
78537 --- a/kernel/sysctl.c
78538 +++ b/kernel/sysctl.c
78539 @@ -93,7 +93,6 @@
78540
78541
78542 #if defined(CONFIG_SYSCTL)
78543 -
78544 /* External variables not in a header file. */
78545 extern int sysctl_overcommit_memory;
78546 extern int sysctl_overcommit_ratio;
78547 @@ -178,10 +177,8 @@ static int proc_taint(struct ctl_table *table, int write,
78548 void __user *buffer, size_t *lenp, loff_t *ppos);
78549 #endif
78550
78551 -#ifdef CONFIG_PRINTK
78552 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78553 void __user *buffer, size_t *lenp, loff_t *ppos);
78554 -#endif
78555
78556 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
78557 void __user *buffer, size_t *lenp, loff_t *ppos);
78558 @@ -212,6 +209,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
78559
78560 #endif
78561
78562 +extern struct ctl_table grsecurity_table[];
78563 +
78564 static struct ctl_table kern_table[];
78565 static struct ctl_table vm_table[];
78566 static struct ctl_table fs_table[];
78567 @@ -226,6 +225,20 @@ extern struct ctl_table epoll_table[];
78568 int sysctl_legacy_va_layout;
78569 #endif
78570
78571 +#ifdef CONFIG_PAX_SOFTMODE
78572 +static ctl_table pax_table[] = {
78573 + {
78574 + .procname = "softmode",
78575 + .data = &pax_softmode,
78576 + .maxlen = sizeof(unsigned int),
78577 + .mode = 0600,
78578 + .proc_handler = &proc_dointvec,
78579 + },
78580 +
78581 + { }
78582 +};
78583 +#endif
78584 +
78585 /* The default sysctl tables: */
78586
78587 static struct ctl_table sysctl_base_table[] = {
78588 @@ -274,6 +287,22 @@ static int max_extfrag_threshold = 1000;
78589 #endif
78590
78591 static struct ctl_table kern_table[] = {
78592 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
78593 + {
78594 + .procname = "grsecurity",
78595 + .mode = 0500,
78596 + .child = grsecurity_table,
78597 + },
78598 +#endif
78599 +
78600 +#ifdef CONFIG_PAX_SOFTMODE
78601 + {
78602 + .procname = "pax",
78603 + .mode = 0500,
78604 + .child = pax_table,
78605 + },
78606 +#endif
78607 +
78608 {
78609 .procname = "sched_child_runs_first",
78610 .data = &sysctl_sched_child_runs_first,
78611 @@ -608,7 +637,7 @@ static struct ctl_table kern_table[] = {
78612 .data = &modprobe_path,
78613 .maxlen = KMOD_PATH_LEN,
78614 .mode = 0644,
78615 - .proc_handler = proc_dostring,
78616 + .proc_handler = proc_dostring_modpriv,
78617 },
78618 {
78619 .procname = "modules_disabled",
78620 @@ -775,16 +804,20 @@ static struct ctl_table kern_table[] = {
78621 .extra1 = &zero,
78622 .extra2 = &one,
78623 },
78624 +#endif
78625 {
78626 .procname = "kptr_restrict",
78627 .data = &kptr_restrict,
78628 .maxlen = sizeof(int),
78629 .mode = 0644,
78630 .proc_handler = proc_dointvec_minmax_sysadmin,
78631 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78632 + .extra1 = &two,
78633 +#else
78634 .extra1 = &zero,
78635 +#endif
78636 .extra2 = &two,
78637 },
78638 -#endif
78639 {
78640 .procname = "ngroups_max",
78641 .data = &ngroups_max,
78642 @@ -1026,8 +1059,8 @@ static struct ctl_table kern_table[] = {
78643 */
78644 {
78645 .procname = "perf_event_paranoid",
78646 - .data = &sysctl_perf_event_paranoid,
78647 - .maxlen = sizeof(sysctl_perf_event_paranoid),
78648 + .data = &sysctl_perf_event_legitimately_concerned,
78649 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
78650 .mode = 0644,
78651 .proc_handler = proc_dointvec,
78652 },
78653 @@ -1283,6 +1316,13 @@ static struct ctl_table vm_table[] = {
78654 .proc_handler = proc_dointvec_minmax,
78655 .extra1 = &zero,
78656 },
78657 + {
78658 + .procname = "heap_stack_gap",
78659 + .data = &sysctl_heap_stack_gap,
78660 + .maxlen = sizeof(sysctl_heap_stack_gap),
78661 + .mode = 0644,
78662 + .proc_handler = proc_doulongvec_minmax,
78663 + },
78664 #else
78665 {
78666 .procname = "nr_trim_pages",
78667 @@ -1733,6 +1773,16 @@ int proc_dostring(struct ctl_table *table, int write,
78668 buffer, lenp, ppos);
78669 }
78670
78671 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78672 + void __user *buffer, size_t *lenp, loff_t *ppos)
78673 +{
78674 + if (write && !capable(CAP_SYS_MODULE))
78675 + return -EPERM;
78676 +
78677 + return _proc_do_string(table->data, table->maxlen, write,
78678 + buffer, lenp, ppos);
78679 +}
78680 +
78681 static size_t proc_skip_spaces(char **buf)
78682 {
78683 size_t ret;
78684 @@ -1838,6 +1888,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
78685 len = strlen(tmp);
78686 if (len > *size)
78687 len = *size;
78688 + if (len > sizeof(tmp))
78689 + len = sizeof(tmp);
78690 if (copy_to_user(*buf, tmp, len))
78691 return -EFAULT;
78692 *size -= len;
78693 @@ -2002,7 +2054,7 @@ int proc_dointvec(struct ctl_table *table, int write,
78694 static int proc_taint(struct ctl_table *table, int write,
78695 void __user *buffer, size_t *lenp, loff_t *ppos)
78696 {
78697 - struct ctl_table t;
78698 + ctl_table_no_const t;
78699 unsigned long tmptaint = get_taint();
78700 int err;
78701
78702 @@ -2030,7 +2082,6 @@ static int proc_taint(struct ctl_table *table, int write,
78703 return err;
78704 }
78705
78706 -#ifdef CONFIG_PRINTK
78707 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78708 void __user *buffer, size_t *lenp, loff_t *ppos)
78709 {
78710 @@ -2039,7 +2090,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78711
78712 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
78713 }
78714 -#endif
78715
78716 struct do_proc_dointvec_minmax_conv_param {
78717 int *min;
78718 @@ -2186,8 +2236,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
78719 *i = val;
78720 } else {
78721 val = convdiv * (*i) / convmul;
78722 - if (!first)
78723 + if (!first) {
78724 err = proc_put_char(&buffer, &left, '\t');
78725 + if (err)
78726 + break;
78727 + }
78728 err = proc_put_long(&buffer, &left, val, false);
78729 if (err)
78730 break;
78731 @@ -2579,6 +2632,12 @@ int proc_dostring(struct ctl_table *table, int write,
78732 return -ENOSYS;
78733 }
78734
78735 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78736 + void __user *buffer, size_t *lenp, loff_t *ppos)
78737 +{
78738 + return -ENOSYS;
78739 +}
78740 +
78741 int proc_dointvec(struct ctl_table *table, int write,
78742 void __user *buffer, size_t *lenp, loff_t *ppos)
78743 {
78744 @@ -2635,5 +2694,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
78745 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
78746 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
78747 EXPORT_SYMBOL(proc_dostring);
78748 +EXPORT_SYMBOL(proc_dostring_modpriv);
78749 EXPORT_SYMBOL(proc_doulongvec_minmax);
78750 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
78751 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
78752 index 145bb4d..b2aa969 100644
78753 --- a/kernel/taskstats.c
78754 +++ b/kernel/taskstats.c
78755 @@ -28,9 +28,12 @@
78756 #include <linux/fs.h>
78757 #include <linux/file.h>
78758 #include <linux/pid_namespace.h>
78759 +#include <linux/grsecurity.h>
78760 #include <net/genetlink.h>
78761 #include <linux/atomic.h>
78762
78763 +extern int gr_is_taskstats_denied(int pid);
78764 +
78765 /*
78766 * Maximum length of a cpumask that can be specified in
78767 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
78768 @@ -570,6 +573,9 @@ err:
78769
78770 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
78771 {
78772 + if (gr_is_taskstats_denied(current->pid))
78773 + return -EACCES;
78774 +
78775 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
78776 return cmd_attr_register_cpumask(info);
78777 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
78778 diff --git a/kernel/time.c b/kernel/time.c
78779 index f8342a4..288f13b 100644
78780 --- a/kernel/time.c
78781 +++ b/kernel/time.c
78782 @@ -171,6 +171,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
78783 return error;
78784
78785 if (tz) {
78786 + /* we log in do_settimeofday called below, so don't log twice
78787 + */
78788 + if (!tv)
78789 + gr_log_timechange();
78790 +
78791 sys_tz = *tz;
78792 update_vsyscall_tz();
78793 if (firsttime) {
78794 @@ -501,7 +506,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
78795 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
78796 * value to a scaled second value.
78797 */
78798 -unsigned long
78799 +unsigned long __intentional_overflow(-1)
78800 timespec_to_jiffies(const struct timespec *value)
78801 {
78802 unsigned long sec = value->tv_sec;
78803 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
78804 index f11d83b..d016d91 100644
78805 --- a/kernel/time/alarmtimer.c
78806 +++ b/kernel/time/alarmtimer.c
78807 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
78808 struct platform_device *pdev;
78809 int error = 0;
78810 int i;
78811 - struct k_clock alarm_clock = {
78812 + static struct k_clock alarm_clock = {
78813 .clock_getres = alarm_clock_getres,
78814 .clock_get = alarm_clock_get,
78815 .timer_create = alarm_timer_create,
78816 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
78817 index 90ad470..1814e9a 100644
78818 --- a/kernel/time/tick-broadcast.c
78819 +++ b/kernel/time/tick-broadcast.c
78820 @@ -138,7 +138,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
78821 * then clear the broadcast bit.
78822 */
78823 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
78824 - int cpu = smp_processor_id();
78825 + cpu = smp_processor_id();
78826 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
78827 tick_broadcast_clear_oneshot(cpu);
78828 } else {
78829 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
78830 index 9a0bc98..fceb7d0 100644
78831 --- a/kernel/time/timekeeping.c
78832 +++ b/kernel/time/timekeeping.c
78833 @@ -15,6 +15,7 @@
78834 #include <linux/init.h>
78835 #include <linux/mm.h>
78836 #include <linux/sched.h>
78837 +#include <linux/grsecurity.h>
78838 #include <linux/syscore_ops.h>
78839 #include <linux/clocksource.h>
78840 #include <linux/jiffies.h>
78841 @@ -448,6 +449,8 @@ int do_settimeofday(const struct timespec *tv)
78842 if (!timespec_valid_strict(tv))
78843 return -EINVAL;
78844
78845 + gr_log_timechange();
78846 +
78847 write_seqlock_irqsave(&tk->lock, flags);
78848
78849 timekeeping_forward_now(tk);
78850 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
78851 index af5a7e9..715611a 100644
78852 --- a/kernel/time/timer_list.c
78853 +++ b/kernel/time/timer_list.c
78854 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
78855
78856 static void print_name_offset(struct seq_file *m, void *sym)
78857 {
78858 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78859 + SEQ_printf(m, "<%p>", NULL);
78860 +#else
78861 char symname[KSYM_NAME_LEN];
78862
78863 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
78864 SEQ_printf(m, "<%pK>", sym);
78865 else
78866 SEQ_printf(m, "%s", symname);
78867 +#endif
78868 }
78869
78870 static void
78871 @@ -112,7 +116,11 @@ next_one:
78872 static void
78873 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
78874 {
78875 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78876 + SEQ_printf(m, " .base: %p\n", NULL);
78877 +#else
78878 SEQ_printf(m, " .base: %pK\n", base);
78879 +#endif
78880 SEQ_printf(m, " .index: %d\n",
78881 base->index);
78882 SEQ_printf(m, " .resolution: %Lu nsecs\n",
78883 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
78884 {
78885 struct proc_dir_entry *pe;
78886
78887 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78888 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
78889 +#else
78890 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
78891 +#endif
78892 if (!pe)
78893 return -ENOMEM;
78894 return 0;
78895 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
78896 index 0b537f2..40d6c20 100644
78897 --- a/kernel/time/timer_stats.c
78898 +++ b/kernel/time/timer_stats.c
78899 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
78900 static unsigned long nr_entries;
78901 static struct entry entries[MAX_ENTRIES];
78902
78903 -static atomic_t overflow_count;
78904 +static atomic_unchecked_t overflow_count;
78905
78906 /*
78907 * The entries are in a hash-table, for fast lookup:
78908 @@ -140,7 +140,7 @@ static void reset_entries(void)
78909 nr_entries = 0;
78910 memset(entries, 0, sizeof(entries));
78911 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
78912 - atomic_set(&overflow_count, 0);
78913 + atomic_set_unchecked(&overflow_count, 0);
78914 }
78915
78916 static struct entry *alloc_entry(void)
78917 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78918 if (likely(entry))
78919 entry->count++;
78920 else
78921 - atomic_inc(&overflow_count);
78922 + atomic_inc_unchecked(&overflow_count);
78923
78924 out_unlock:
78925 raw_spin_unlock_irqrestore(lock, flags);
78926 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78927
78928 static void print_name_offset(struct seq_file *m, unsigned long addr)
78929 {
78930 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78931 + seq_printf(m, "<%p>", NULL);
78932 +#else
78933 char symname[KSYM_NAME_LEN];
78934
78935 if (lookup_symbol_name(addr, symname) < 0)
78936 - seq_printf(m, "<%p>", (void *)addr);
78937 + seq_printf(m, "<%pK>", (void *)addr);
78938 else
78939 seq_printf(m, "%s", symname);
78940 +#endif
78941 }
78942
78943 static int tstats_show(struct seq_file *m, void *v)
78944 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
78945
78946 seq_puts(m, "Timer Stats Version: v0.2\n");
78947 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
78948 - if (atomic_read(&overflow_count))
78949 + if (atomic_read_unchecked(&overflow_count))
78950 seq_printf(m, "Overflow: %d entries\n",
78951 - atomic_read(&overflow_count));
78952 + atomic_read_unchecked(&overflow_count));
78953
78954 for (i = 0; i < nr_entries; i++) {
78955 entry = entries + i;
78956 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
78957 {
78958 struct proc_dir_entry *pe;
78959
78960 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78961 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
78962 +#else
78963 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
78964 +#endif
78965 if (!pe)
78966 return -ENOMEM;
78967 return 0;
78968 diff --git a/kernel/timer.c b/kernel/timer.c
78969 index 1b399c8..90e1849 100644
78970 --- a/kernel/timer.c
78971 +++ b/kernel/timer.c
78972 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
78973 /*
78974 * This function runs timers and the timer-tq in bottom half context.
78975 */
78976 -static void run_timer_softirq(struct softirq_action *h)
78977 +static void run_timer_softirq(void)
78978 {
78979 struct tvec_base *base = __this_cpu_read(tvec_bases);
78980
78981 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
78982 *
78983 * In all cases the return value is guaranteed to be non-negative.
78984 */
78985 -signed long __sched schedule_timeout(signed long timeout)
78986 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
78987 {
78988 struct timer_list timer;
78989 unsigned long expire;
78990 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
78991 return NOTIFY_OK;
78992 }
78993
78994 -static struct notifier_block __cpuinitdata timers_nb = {
78995 +static struct notifier_block timers_nb = {
78996 .notifier_call = timer_cpu_notify,
78997 };
78998
78999 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79000 index 5a0f781..1497f95 100644
79001 --- a/kernel/trace/blktrace.c
79002 +++ b/kernel/trace/blktrace.c
79003 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79004 struct blk_trace *bt = filp->private_data;
79005 char buf[16];
79006
79007 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79008 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79009
79010 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79011 }
79012 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79013 return 1;
79014
79015 bt = buf->chan->private_data;
79016 - atomic_inc(&bt->dropped);
79017 + atomic_inc_unchecked(&bt->dropped);
79018 return 0;
79019 }
79020
79021 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79022
79023 bt->dir = dir;
79024 bt->dev = dev;
79025 - atomic_set(&bt->dropped, 0);
79026 + atomic_set_unchecked(&bt->dropped, 0);
79027
79028 ret = -EIO;
79029 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79030 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79031 index 0a0e2a6..943495e 100644
79032 --- a/kernel/trace/ftrace.c
79033 +++ b/kernel/trace/ftrace.c
79034 @@ -1909,12 +1909,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79035 if (unlikely(ftrace_disabled))
79036 return 0;
79037
79038 + ret = ftrace_arch_code_modify_prepare();
79039 + FTRACE_WARN_ON(ret);
79040 + if (ret)
79041 + return 0;
79042 +
79043 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79044 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79045 if (ret) {
79046 ftrace_bug(ret, ip);
79047 - return 0;
79048 }
79049 - return 1;
79050 + return ret ? 0 : 1;
79051 }
79052
79053 /*
79054 @@ -2986,7 +2991,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79055
79056 int
79057 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79058 - void *data)
79059 + void *data)
79060 {
79061 struct ftrace_func_probe *entry;
79062 struct ftrace_page *pg;
79063 @@ -3854,8 +3859,10 @@ static int ftrace_process_locs(struct module *mod,
79064 if (!count)
79065 return 0;
79066
79067 + pax_open_kernel();
79068 sort(start, count, sizeof(*start),
79069 ftrace_cmp_ips, ftrace_swap_ips);
79070 + pax_close_kernel();
79071
79072 start_pg = ftrace_allocate_pages(count);
79073 if (!start_pg)
79074 @@ -4574,8 +4581,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79075 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79076
79077 static int ftrace_graph_active;
79078 -static struct notifier_block ftrace_suspend_notifier;
79079 -
79080 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79081 {
79082 return 0;
79083 @@ -4719,6 +4724,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79084 return NOTIFY_DONE;
79085 }
79086
79087 +static struct notifier_block ftrace_suspend_notifier = {
79088 + .notifier_call = ftrace_suspend_notifier_call
79089 +};
79090 +
79091 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79092 trace_func_graph_ent_t entryfunc)
79093 {
79094 @@ -4732,7 +4741,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79095 goto out;
79096 }
79097
79098 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79099 register_pm_notifier(&ftrace_suspend_notifier);
79100
79101 ftrace_graph_active++;
79102 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79103 index 6989df2..c2265cf 100644
79104 --- a/kernel/trace/ring_buffer.c
79105 +++ b/kernel/trace/ring_buffer.c
79106 @@ -349,9 +349,9 @@ struct buffer_data_page {
79107 */
79108 struct buffer_page {
79109 struct list_head list; /* list of buffer pages */
79110 - local_t write; /* index for next write */
79111 + local_unchecked_t write; /* index for next write */
79112 unsigned read; /* index for next read */
79113 - local_t entries; /* entries on this page */
79114 + local_unchecked_t entries; /* entries on this page */
79115 unsigned long real_end; /* real end of data */
79116 struct buffer_data_page *page; /* Actual data page */
79117 };
79118 @@ -464,8 +464,8 @@ struct ring_buffer_per_cpu {
79119 unsigned long last_overrun;
79120 local_t entries_bytes;
79121 local_t entries;
79122 - local_t overrun;
79123 - local_t commit_overrun;
79124 + local_unchecked_t overrun;
79125 + local_unchecked_t commit_overrun;
79126 local_t dropped_events;
79127 local_t committing;
79128 local_t commits;
79129 @@ -864,8 +864,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79130 *
79131 * We add a counter to the write field to denote this.
79132 */
79133 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79134 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79135 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79136 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79137
79138 /*
79139 * Just make sure we have seen our old_write and synchronize
79140 @@ -893,8 +893,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79141 * cmpxchg to only update if an interrupt did not already
79142 * do it for us. If the cmpxchg fails, we don't care.
79143 */
79144 - (void)local_cmpxchg(&next_page->write, old_write, val);
79145 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79146 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79147 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79148
79149 /*
79150 * No need to worry about races with clearing out the commit.
79151 @@ -1253,12 +1253,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79152
79153 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79154 {
79155 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79156 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79157 }
79158
79159 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79160 {
79161 - return local_read(&bpage->write) & RB_WRITE_MASK;
79162 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79163 }
79164
79165 static int
79166 @@ -1353,7 +1353,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79167 * bytes consumed in ring buffer from here.
79168 * Increment overrun to account for the lost events.
79169 */
79170 - local_add(page_entries, &cpu_buffer->overrun);
79171 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79172 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79173 }
79174
79175 @@ -1909,7 +1909,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79176 * it is our responsibility to update
79177 * the counters.
79178 */
79179 - local_add(entries, &cpu_buffer->overrun);
79180 + local_add_unchecked(entries, &cpu_buffer->overrun);
79181 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79182
79183 /*
79184 @@ -2059,7 +2059,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79185 if (tail == BUF_PAGE_SIZE)
79186 tail_page->real_end = 0;
79187
79188 - local_sub(length, &tail_page->write);
79189 + local_sub_unchecked(length, &tail_page->write);
79190 return;
79191 }
79192
79193 @@ -2094,7 +2094,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79194 rb_event_set_padding(event);
79195
79196 /* Set the write back to the previous setting */
79197 - local_sub(length, &tail_page->write);
79198 + local_sub_unchecked(length, &tail_page->write);
79199 return;
79200 }
79201
79202 @@ -2106,7 +2106,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79203
79204 /* Set write to end of buffer */
79205 length = (tail + length) - BUF_PAGE_SIZE;
79206 - local_sub(length, &tail_page->write);
79207 + local_sub_unchecked(length, &tail_page->write);
79208 }
79209
79210 /*
79211 @@ -2132,7 +2132,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79212 * about it.
79213 */
79214 if (unlikely(next_page == commit_page)) {
79215 - local_inc(&cpu_buffer->commit_overrun);
79216 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79217 goto out_reset;
79218 }
79219
79220 @@ -2188,7 +2188,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79221 cpu_buffer->tail_page) &&
79222 (cpu_buffer->commit_page ==
79223 cpu_buffer->reader_page))) {
79224 - local_inc(&cpu_buffer->commit_overrun);
79225 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79226 goto out_reset;
79227 }
79228 }
79229 @@ -2236,7 +2236,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79230 length += RB_LEN_TIME_EXTEND;
79231
79232 tail_page = cpu_buffer->tail_page;
79233 - write = local_add_return(length, &tail_page->write);
79234 + write = local_add_return_unchecked(length, &tail_page->write);
79235
79236 /* set write to only the index of the write */
79237 write &= RB_WRITE_MASK;
79238 @@ -2253,7 +2253,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79239 kmemcheck_annotate_bitfield(event, bitfield);
79240 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79241
79242 - local_inc(&tail_page->entries);
79243 + local_inc_unchecked(&tail_page->entries);
79244
79245 /*
79246 * If this is the first commit on the page, then update
79247 @@ -2286,7 +2286,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79248
79249 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79250 unsigned long write_mask =
79251 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79252 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79253 unsigned long event_length = rb_event_length(event);
79254 /*
79255 * This is on the tail page. It is possible that
79256 @@ -2296,7 +2296,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79257 */
79258 old_index += write_mask;
79259 new_index += write_mask;
79260 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79261 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79262 if (index == old_index) {
79263 /* update counters */
79264 local_sub(event_length, &cpu_buffer->entries_bytes);
79265 @@ -2670,7 +2670,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79266
79267 /* Do the likely case first */
79268 if (likely(bpage->page == (void *)addr)) {
79269 - local_dec(&bpage->entries);
79270 + local_dec_unchecked(&bpage->entries);
79271 return;
79272 }
79273
79274 @@ -2682,7 +2682,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79275 start = bpage;
79276 do {
79277 if (bpage->page == (void *)addr) {
79278 - local_dec(&bpage->entries);
79279 + local_dec_unchecked(&bpage->entries);
79280 return;
79281 }
79282 rb_inc_page(cpu_buffer, &bpage);
79283 @@ -2964,7 +2964,7 @@ static inline unsigned long
79284 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79285 {
79286 return local_read(&cpu_buffer->entries) -
79287 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79288 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79289 }
79290
79291 /**
79292 @@ -3053,7 +3053,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79293 return 0;
79294
79295 cpu_buffer = buffer->buffers[cpu];
79296 - ret = local_read(&cpu_buffer->overrun);
79297 + ret = local_read_unchecked(&cpu_buffer->overrun);
79298
79299 return ret;
79300 }
79301 @@ -3076,7 +3076,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79302 return 0;
79303
79304 cpu_buffer = buffer->buffers[cpu];
79305 - ret = local_read(&cpu_buffer->commit_overrun);
79306 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79307
79308 return ret;
79309 }
79310 @@ -3161,7 +3161,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79311 /* if you care about this being correct, lock the buffer */
79312 for_each_buffer_cpu(buffer, cpu) {
79313 cpu_buffer = buffer->buffers[cpu];
79314 - overruns += local_read(&cpu_buffer->overrun);
79315 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79316 }
79317
79318 return overruns;
79319 @@ -3337,8 +3337,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79320 /*
79321 * Reset the reader page to size zero.
79322 */
79323 - local_set(&cpu_buffer->reader_page->write, 0);
79324 - local_set(&cpu_buffer->reader_page->entries, 0);
79325 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79326 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79327 local_set(&cpu_buffer->reader_page->page->commit, 0);
79328 cpu_buffer->reader_page->real_end = 0;
79329
79330 @@ -3372,7 +3372,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79331 * want to compare with the last_overrun.
79332 */
79333 smp_mb();
79334 - overwrite = local_read(&(cpu_buffer->overrun));
79335 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79336
79337 /*
79338 * Here's the tricky part.
79339 @@ -3942,8 +3942,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79340
79341 cpu_buffer->head_page
79342 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79343 - local_set(&cpu_buffer->head_page->write, 0);
79344 - local_set(&cpu_buffer->head_page->entries, 0);
79345 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79346 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79347 local_set(&cpu_buffer->head_page->page->commit, 0);
79348
79349 cpu_buffer->head_page->read = 0;
79350 @@ -3953,14 +3953,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79351
79352 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79353 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79354 - local_set(&cpu_buffer->reader_page->write, 0);
79355 - local_set(&cpu_buffer->reader_page->entries, 0);
79356 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79357 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79358 local_set(&cpu_buffer->reader_page->page->commit, 0);
79359 cpu_buffer->reader_page->read = 0;
79360
79361 local_set(&cpu_buffer->entries_bytes, 0);
79362 - local_set(&cpu_buffer->overrun, 0);
79363 - local_set(&cpu_buffer->commit_overrun, 0);
79364 + local_set_unchecked(&cpu_buffer->overrun, 0);
79365 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79366 local_set(&cpu_buffer->dropped_events, 0);
79367 local_set(&cpu_buffer->entries, 0);
79368 local_set(&cpu_buffer->committing, 0);
79369 @@ -4364,8 +4364,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79370 rb_init_page(bpage);
79371 bpage = reader->page;
79372 reader->page = *data_page;
79373 - local_set(&reader->write, 0);
79374 - local_set(&reader->entries, 0);
79375 + local_set_unchecked(&reader->write, 0);
79376 + local_set_unchecked(&reader->entries, 0);
79377 reader->read = 0;
79378 *data_page = bpage;
79379
79380 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79381 index 3f28192..a29e8b0 100644
79382 --- a/kernel/trace/trace.c
79383 +++ b/kernel/trace/trace.c
79384 @@ -2893,7 +2893,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
79385 return 0;
79386 }
79387
79388 -int set_tracer_flag(unsigned int mask, int enabled)
79389 +int set_tracer_flag(unsigned long mask, int enabled)
79390 {
79391 /* do nothing if flag is already set */
79392 if (!!(trace_flags & mask) == !!enabled)
79393 @@ -4637,10 +4637,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79394 };
79395 #endif
79396
79397 -static struct dentry *d_tracer;
79398 -
79399 struct dentry *tracing_init_dentry(void)
79400 {
79401 + static struct dentry *d_tracer;
79402 static int once;
79403
79404 if (d_tracer)
79405 @@ -4660,10 +4659,9 @@ struct dentry *tracing_init_dentry(void)
79406 return d_tracer;
79407 }
79408
79409 -static struct dentry *d_percpu;
79410 -
79411 static struct dentry *tracing_dentry_percpu(void)
79412 {
79413 + static struct dentry *d_percpu;
79414 static int once;
79415 struct dentry *d_tracer;
79416
79417 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
79418 index 2081971..09f861e 100644
79419 --- a/kernel/trace/trace.h
79420 +++ b/kernel/trace/trace.h
79421 @@ -948,7 +948,7 @@ extern const char *__stop___trace_bprintk_fmt[];
79422 void trace_printk_init_buffers(void);
79423 void trace_printk_start_comm(void);
79424 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
79425 -int set_tracer_flag(unsigned int mask, int enabled);
79426 +int set_tracer_flag(unsigned long mask, int enabled);
79427
79428 #undef FTRACE_ENTRY
79429 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
79430 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79431 index 57e9b28..eebe41c 100644
79432 --- a/kernel/trace/trace_events.c
79433 +++ b/kernel/trace/trace_events.c
79434 @@ -1329,10 +1329,6 @@ static LIST_HEAD(ftrace_module_file_list);
79435 struct ftrace_module_file_ops {
79436 struct list_head list;
79437 struct module *mod;
79438 - struct file_operations id;
79439 - struct file_operations enable;
79440 - struct file_operations format;
79441 - struct file_operations filter;
79442 };
79443
79444 static struct ftrace_module_file_ops *
79445 @@ -1353,17 +1349,12 @@ trace_create_file_ops(struct module *mod)
79446
79447 file_ops->mod = mod;
79448
79449 - file_ops->id = ftrace_event_id_fops;
79450 - file_ops->id.owner = mod;
79451 -
79452 - file_ops->enable = ftrace_enable_fops;
79453 - file_ops->enable.owner = mod;
79454 -
79455 - file_ops->filter = ftrace_event_filter_fops;
79456 - file_ops->filter.owner = mod;
79457 -
79458 - file_ops->format = ftrace_event_format_fops;
79459 - file_ops->format.owner = mod;
79460 + pax_open_kernel();
79461 + mod->trace_id.owner = mod;
79462 + mod->trace_enable.owner = mod;
79463 + mod->trace_filter.owner = mod;
79464 + mod->trace_format.owner = mod;
79465 + pax_close_kernel();
79466
79467 list_add(&file_ops->list, &ftrace_module_file_list);
79468
79469 @@ -1387,8 +1378,8 @@ static void trace_module_add_events(struct module *mod)
79470
79471 for_each_event(call, start, end) {
79472 __trace_add_event_call(*call, mod,
79473 - &file_ops->id, &file_ops->enable,
79474 - &file_ops->filter, &file_ops->format);
79475 + &mod->trace_id, &mod->trace_enable,
79476 + &mod->trace_filter, &mod->trace_format);
79477 }
79478 }
79479
79480 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
79481 index fd3c8aa..5f324a6 100644
79482 --- a/kernel/trace/trace_mmiotrace.c
79483 +++ b/kernel/trace/trace_mmiotrace.c
79484 @@ -24,7 +24,7 @@ struct header_iter {
79485 static struct trace_array *mmio_trace_array;
79486 static bool overrun_detected;
79487 static unsigned long prev_overruns;
79488 -static atomic_t dropped_count;
79489 +static atomic_unchecked_t dropped_count;
79490
79491 static void mmio_reset_data(struct trace_array *tr)
79492 {
79493 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
79494
79495 static unsigned long count_overruns(struct trace_iterator *iter)
79496 {
79497 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
79498 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
79499 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
79500
79501 if (over > prev_overruns)
79502 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
79503 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
79504 sizeof(*entry), 0, pc);
79505 if (!event) {
79506 - atomic_inc(&dropped_count);
79507 + atomic_inc_unchecked(&dropped_count);
79508 return;
79509 }
79510 entry = ring_buffer_event_data(event);
79511 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
79512 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
79513 sizeof(*entry), 0, pc);
79514 if (!event) {
79515 - atomic_inc(&dropped_count);
79516 + atomic_inc_unchecked(&dropped_count);
79517 return;
79518 }
79519 entry = ring_buffer_event_data(event);
79520 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
79521 index 697e88d..1a79993 100644
79522 --- a/kernel/trace/trace_output.c
79523 +++ b/kernel/trace/trace_output.c
79524 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
79525
79526 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
79527 if (!IS_ERR(p)) {
79528 - p = mangle_path(s->buffer + s->len, p, "\n");
79529 + p = mangle_path(s->buffer + s->len, p, "\n\\");
79530 if (p) {
79531 s->len = p - s->buffer;
79532 return 1;
79533 @@ -851,14 +851,16 @@ int register_ftrace_event(struct trace_event *event)
79534 goto out;
79535 }
79536
79537 + pax_open_kernel();
79538 if (event->funcs->trace == NULL)
79539 - event->funcs->trace = trace_nop_print;
79540 + *(void **)&event->funcs->trace = trace_nop_print;
79541 if (event->funcs->raw == NULL)
79542 - event->funcs->raw = trace_nop_print;
79543 + *(void **)&event->funcs->raw = trace_nop_print;
79544 if (event->funcs->hex == NULL)
79545 - event->funcs->hex = trace_nop_print;
79546 + *(void **)&event->funcs->hex = trace_nop_print;
79547 if (event->funcs->binary == NULL)
79548 - event->funcs->binary = trace_nop_print;
79549 + *(void **)&event->funcs->binary = trace_nop_print;
79550 + pax_close_kernel();
79551
79552 key = event->type & (EVENT_HASHSIZE - 1);
79553
79554 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
79555 index b20428c..4845a10 100644
79556 --- a/kernel/trace/trace_stack.c
79557 +++ b/kernel/trace/trace_stack.c
79558 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
79559 return;
79560
79561 /* we do not handle interrupt stacks yet */
79562 - if (!object_is_on_stack(stack))
79563 + if (!object_starts_on_stack(stack))
79564 return;
79565
79566 local_irq_save(flags);
79567 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
79568 index e134d8f..a018cdd 100644
79569 --- a/kernel/user_namespace.c
79570 +++ b/kernel/user_namespace.c
79571 @@ -853,7 +853,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
79572 if (atomic_read(&current->mm->mm_users) > 1)
79573 return -EINVAL;
79574
79575 - if (current->fs->users != 1)
79576 + if (atomic_read(&current->fs->users) != 1)
79577 return -EINVAL;
79578
79579 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
79580 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
79581 index 4f69f9a..7c6f8f8 100644
79582 --- a/kernel/utsname_sysctl.c
79583 +++ b/kernel/utsname_sysctl.c
79584 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
79585 static int proc_do_uts_string(ctl_table *table, int write,
79586 void __user *buffer, size_t *lenp, loff_t *ppos)
79587 {
79588 - struct ctl_table uts_table;
79589 + ctl_table_no_const uts_table;
79590 int r;
79591 memcpy(&uts_table, table, sizeof(uts_table));
79592 uts_table.data = get_uts(table, write);
79593 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
79594 index 4a94467..80a6f9c 100644
79595 --- a/kernel/watchdog.c
79596 +++ b/kernel/watchdog.c
79597 @@ -526,7 +526,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
79598 }
79599 #endif /* CONFIG_SYSCTL */
79600
79601 -static struct smp_hotplug_thread watchdog_threads = {
79602 +static struct smp_hotplug_thread watchdog_threads __read_only = {
79603 .store = &softlockup_watchdog,
79604 .thread_should_run = watchdog_should_run,
79605 .thread_fn = watchdog,
79606 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
79607 index 28be08c..47bab92 100644
79608 --- a/lib/Kconfig.debug
79609 +++ b/lib/Kconfig.debug
79610 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
79611
79612 config DEBUG_LOCK_ALLOC
79613 bool "Lock debugging: detect incorrect freeing of live locks"
79614 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79615 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79616 select DEBUG_SPINLOCK
79617 select DEBUG_MUTEXES
79618 select LOCKDEP
79619 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
79620
79621 config PROVE_LOCKING
79622 bool "Lock debugging: prove locking correctness"
79623 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79624 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79625 select LOCKDEP
79626 select DEBUG_SPINLOCK
79627 select DEBUG_MUTEXES
79628 @@ -614,7 +614,7 @@ config LOCKDEP
79629
79630 config LOCK_STAT
79631 bool "Lock usage statistics"
79632 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79633 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79634 select LOCKDEP
79635 select DEBUG_SPINLOCK
79636 select DEBUG_MUTEXES
79637 @@ -1282,6 +1282,7 @@ config LATENCYTOP
79638 depends on DEBUG_KERNEL
79639 depends on STACKTRACE_SUPPORT
79640 depends on PROC_FS
79641 + depends on !GRKERNSEC_HIDESYM
79642 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
79643 select KALLSYMS
79644 select KALLSYMS_ALL
79645 @@ -1310,7 +1311,7 @@ config INTERVAL_TREE_TEST
79646
79647 config PROVIDE_OHCI1394_DMA_INIT
79648 bool "Remote debugging over FireWire early on boot"
79649 - depends on PCI && X86
79650 + depends on PCI && X86 && !GRKERNSEC
79651 help
79652 If you want to debug problems which hang or crash the kernel early
79653 on boot and the crashing machine has a FireWire port, you can use
79654 @@ -1339,7 +1340,7 @@ config PROVIDE_OHCI1394_DMA_INIT
79655
79656 config FIREWIRE_OHCI_REMOTE_DMA
79657 bool "Remote debugging over FireWire with firewire-ohci"
79658 - depends on FIREWIRE_OHCI
79659 + depends on FIREWIRE_OHCI && !GRKERNSEC
79660 help
79661 This option lets you use the FireWire bus for remote debugging
79662 with help of the firewire-ohci driver. It enables unfiltered
79663 diff --git a/lib/Makefile b/lib/Makefile
79664 index 6e2cc56..9b13738 100644
79665 --- a/lib/Makefile
79666 +++ b/lib/Makefile
79667 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
79668
79669 obj-$(CONFIG_BTREE) += btree.o
79670 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
79671 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
79672 +obj-y += list_debug.o
79673 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
79674
79675 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
79676 diff --git a/lib/bitmap.c b/lib/bitmap.c
79677 index 06f7e4f..f3cf2b0 100644
79678 --- a/lib/bitmap.c
79679 +++ b/lib/bitmap.c
79680 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
79681 {
79682 int c, old_c, totaldigits, ndigits, nchunks, nbits;
79683 u32 chunk;
79684 - const char __user __force *ubuf = (const char __user __force *)buf;
79685 + const char __user *ubuf = (const char __force_user *)buf;
79686
79687 bitmap_zero(maskp, nmaskbits);
79688
79689 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
79690 {
79691 if (!access_ok(VERIFY_READ, ubuf, ulen))
79692 return -EFAULT;
79693 - return __bitmap_parse((const char __force *)ubuf,
79694 + return __bitmap_parse((const char __force_kernel *)ubuf,
79695 ulen, 1, maskp, nmaskbits);
79696
79697 }
79698 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
79699 {
79700 unsigned a, b;
79701 int c, old_c, totaldigits;
79702 - const char __user __force *ubuf = (const char __user __force *)buf;
79703 + const char __user *ubuf = (const char __force_user *)buf;
79704 int exp_digit, in_range;
79705
79706 totaldigits = c = 0;
79707 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
79708 {
79709 if (!access_ok(VERIFY_READ, ubuf, ulen))
79710 return -EFAULT;
79711 - return __bitmap_parselist((const char __force *)ubuf,
79712 + return __bitmap_parselist((const char __force_kernel *)ubuf,
79713 ulen, 1, maskp, nmaskbits);
79714 }
79715 EXPORT_SYMBOL(bitmap_parselist_user);
79716 diff --git a/lib/bug.c b/lib/bug.c
79717 index 1686034..a9c00c8 100644
79718 --- a/lib/bug.c
79719 +++ b/lib/bug.c
79720 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
79721 return BUG_TRAP_TYPE_NONE;
79722
79723 bug = find_bug(bugaddr);
79724 + if (!bug)
79725 + return BUG_TRAP_TYPE_NONE;
79726
79727 file = NULL;
79728 line = 0;
79729 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
79730 index 37061ed..da83f48 100644
79731 --- a/lib/debugobjects.c
79732 +++ b/lib/debugobjects.c
79733 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
79734 if (limit > 4)
79735 return;
79736
79737 - is_on_stack = object_is_on_stack(addr);
79738 + is_on_stack = object_starts_on_stack(addr);
79739 if (is_on_stack == onstack)
79740 return;
79741
79742 diff --git a/lib/devres.c b/lib/devres.c
79743 index 8235331..5881053 100644
79744 --- a/lib/devres.c
79745 +++ b/lib/devres.c
79746 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
79747 void devm_iounmap(struct device *dev, void __iomem *addr)
79748 {
79749 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
79750 - (void *)addr));
79751 + (void __force *)addr));
79752 iounmap(addr);
79753 }
79754 EXPORT_SYMBOL(devm_iounmap);
79755 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
79756 {
79757 ioport_unmap(addr);
79758 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
79759 - devm_ioport_map_match, (void *)addr));
79760 + devm_ioport_map_match, (void __force *)addr));
79761 }
79762 EXPORT_SYMBOL(devm_ioport_unmap);
79763 #endif /* CONFIG_HAS_IOPORT */
79764 diff --git a/lib/div64.c b/lib/div64.c
79765 index a163b6c..9618fa5 100644
79766 --- a/lib/div64.c
79767 +++ b/lib/div64.c
79768 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
79769 EXPORT_SYMBOL(__div64_32);
79770
79771 #ifndef div_s64_rem
79772 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79773 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79774 {
79775 u64 quotient;
79776
79777 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
79778 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
79779 */
79780 #ifndef div64_u64
79781 -u64 div64_u64(u64 dividend, u64 divisor)
79782 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
79783 {
79784 u32 high = divisor >> 32;
79785 u64 quot;
79786 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
79787 index d87a17a..ac0d79a 100644
79788 --- a/lib/dma-debug.c
79789 +++ b/lib/dma-debug.c
79790 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
79791
79792 void dma_debug_add_bus(struct bus_type *bus)
79793 {
79794 - struct notifier_block *nb;
79795 + notifier_block_no_const *nb;
79796
79797 if (global_disable)
79798 return;
79799 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
79800
79801 static void check_for_stack(struct device *dev, void *addr)
79802 {
79803 - if (object_is_on_stack(addr))
79804 + if (object_starts_on_stack(addr))
79805 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
79806 "stack [addr=%p]\n", addr);
79807 }
79808 diff --git a/lib/inflate.c b/lib/inflate.c
79809 index 013a761..c28f3fc 100644
79810 --- a/lib/inflate.c
79811 +++ b/lib/inflate.c
79812 @@ -269,7 +269,7 @@ static void free(void *where)
79813 malloc_ptr = free_mem_ptr;
79814 }
79815 #else
79816 -#define malloc(a) kmalloc(a, GFP_KERNEL)
79817 +#define malloc(a) kmalloc((a), GFP_KERNEL)
79818 #define free(a) kfree(a)
79819 #endif
79820
79821 diff --git a/lib/ioremap.c b/lib/ioremap.c
79822 index 0c9216c..863bd89 100644
79823 --- a/lib/ioremap.c
79824 +++ b/lib/ioremap.c
79825 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
79826 unsigned long next;
79827
79828 phys_addr -= addr;
79829 - pmd = pmd_alloc(&init_mm, pud, addr);
79830 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
79831 if (!pmd)
79832 return -ENOMEM;
79833 do {
79834 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
79835 unsigned long next;
79836
79837 phys_addr -= addr;
79838 - pud = pud_alloc(&init_mm, pgd, addr);
79839 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
79840 if (!pud)
79841 return -ENOMEM;
79842 do {
79843 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
79844 index bd2bea9..6b3c95e 100644
79845 --- a/lib/is_single_threaded.c
79846 +++ b/lib/is_single_threaded.c
79847 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
79848 struct task_struct *p, *t;
79849 bool ret;
79850
79851 + if (!mm)
79852 + return true;
79853 +
79854 if (atomic_read(&task->signal->live) != 1)
79855 return false;
79856
79857 diff --git a/lib/kobject.c b/lib/kobject.c
79858 index a654866..a4fd13d 100644
79859 --- a/lib/kobject.c
79860 +++ b/lib/kobject.c
79861 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
79862
79863
79864 static DEFINE_SPINLOCK(kobj_ns_type_lock);
79865 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
79866 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
79867
79868 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79869 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79870 {
79871 enum kobj_ns_type type = ops->type;
79872 int error;
79873 diff --git a/lib/list_debug.c b/lib/list_debug.c
79874 index c24c2f7..06e070b 100644
79875 --- a/lib/list_debug.c
79876 +++ b/lib/list_debug.c
79877 @@ -11,7 +11,9 @@
79878 #include <linux/bug.h>
79879 #include <linux/kernel.h>
79880 #include <linux/rculist.h>
79881 +#include <linux/mm.h>
79882
79883 +#ifdef CONFIG_DEBUG_LIST
79884 /*
79885 * Insert a new entry between two known consecutive entries.
79886 *
79887 @@ -19,21 +21,32 @@
79888 * the prev/next entries already!
79889 */
79890
79891 -void __list_add(struct list_head *new,
79892 - struct list_head *prev,
79893 - struct list_head *next)
79894 +static bool __list_add_debug(struct list_head *new,
79895 + struct list_head *prev,
79896 + struct list_head *next)
79897 {
79898 - WARN(next->prev != prev,
79899 + if (WARN(next->prev != prev,
79900 "list_add corruption. next->prev should be "
79901 "prev (%p), but was %p. (next=%p).\n",
79902 - prev, next->prev, next);
79903 - WARN(prev->next != next,
79904 + prev, next->prev, next) ||
79905 + WARN(prev->next != next,
79906 "list_add corruption. prev->next should be "
79907 "next (%p), but was %p. (prev=%p).\n",
79908 - next, prev->next, prev);
79909 - WARN(new == prev || new == next,
79910 - "list_add double add: new=%p, prev=%p, next=%p.\n",
79911 - new, prev, next);
79912 + next, prev->next, prev) ||
79913 + WARN(new == prev || new == next,
79914 + "list_add double add: new=%p, prev=%p, next=%p.\n",
79915 + new, prev, next))
79916 + return false;
79917 + return true;
79918 +}
79919 +
79920 +void __list_add(struct list_head *new,
79921 + struct list_head *prev,
79922 + struct list_head *next)
79923 +{
79924 + if (!__list_add_debug(new, prev, next))
79925 + return;
79926 +
79927 next->prev = new;
79928 new->next = next;
79929 new->prev = prev;
79930 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
79931 }
79932 EXPORT_SYMBOL(__list_add);
79933
79934 -void __list_del_entry(struct list_head *entry)
79935 +static bool __list_del_entry_debug(struct list_head *entry)
79936 {
79937 struct list_head *prev, *next;
79938
79939 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
79940 WARN(next->prev != entry,
79941 "list_del corruption. next->prev should be %p, "
79942 "but was %p\n", entry, next->prev))
79943 + return false;
79944 + return true;
79945 +}
79946 +
79947 +void __list_del_entry(struct list_head *entry)
79948 +{
79949 + if (!__list_del_entry_debug(entry))
79950 return;
79951
79952 - __list_del(prev, next);
79953 + __list_del(entry->prev, entry->next);
79954 }
79955 EXPORT_SYMBOL(__list_del_entry);
79956
79957 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
79958 void __list_add_rcu(struct list_head *new,
79959 struct list_head *prev, struct list_head *next)
79960 {
79961 - WARN(next->prev != prev,
79962 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
79963 - prev, next->prev, next);
79964 - WARN(prev->next != next,
79965 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
79966 - next, prev->next, prev);
79967 + if (!__list_add_debug(new, prev, next))
79968 + return;
79969 +
79970 new->next = next;
79971 new->prev = prev;
79972 rcu_assign_pointer(list_next_rcu(prev), new);
79973 next->prev = new;
79974 }
79975 EXPORT_SYMBOL(__list_add_rcu);
79976 +#endif
79977 +
79978 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
79979 +{
79980 +#ifdef CONFIG_DEBUG_LIST
79981 + if (!__list_add_debug(new, prev, next))
79982 + return;
79983 +#endif
79984 +
79985 + pax_open_kernel();
79986 + next->prev = new;
79987 + new->next = next;
79988 + new->prev = prev;
79989 + prev->next = new;
79990 + pax_close_kernel();
79991 +}
79992 +EXPORT_SYMBOL(__pax_list_add);
79993 +
79994 +void pax_list_del(struct list_head *entry)
79995 +{
79996 +#ifdef CONFIG_DEBUG_LIST
79997 + if (!__list_del_entry_debug(entry))
79998 + return;
79999 +#endif
80000 +
80001 + pax_open_kernel();
80002 + __list_del(entry->prev, entry->next);
80003 + entry->next = LIST_POISON1;
80004 + entry->prev = LIST_POISON2;
80005 + pax_close_kernel();
80006 +}
80007 +EXPORT_SYMBOL(pax_list_del);
80008 +
80009 +void pax_list_del_init(struct list_head *entry)
80010 +{
80011 + pax_open_kernel();
80012 + __list_del(entry->prev, entry->next);
80013 + INIT_LIST_HEAD(entry);
80014 + pax_close_kernel();
80015 +}
80016 +EXPORT_SYMBOL(pax_list_del_init);
80017 +
80018 +void __pax_list_add_rcu(struct list_head *new,
80019 + struct list_head *prev, struct list_head *next)
80020 +{
80021 +#ifdef CONFIG_DEBUG_LIST
80022 + if (!__list_add_debug(new, prev, next))
80023 + return;
80024 +#endif
80025 +
80026 + pax_open_kernel();
80027 + new->next = next;
80028 + new->prev = prev;
80029 + rcu_assign_pointer(list_next_rcu(prev), new);
80030 + next->prev = new;
80031 + pax_close_kernel();
80032 +}
80033 +EXPORT_SYMBOL(__pax_list_add_rcu);
80034 +
80035 +void pax_list_del_rcu(struct list_head *entry)
80036 +{
80037 +#ifdef CONFIG_DEBUG_LIST
80038 + if (!__list_del_entry_debug(entry))
80039 + return;
80040 +#endif
80041 +
80042 + pax_open_kernel();
80043 + __list_del(entry->prev, entry->next);
80044 + entry->next = LIST_POISON1;
80045 + entry->prev = LIST_POISON2;
80046 + pax_close_kernel();
80047 +}
80048 +EXPORT_SYMBOL(pax_list_del_rcu);
80049 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80050 index e796429..6e38f9f 100644
80051 --- a/lib/radix-tree.c
80052 +++ b/lib/radix-tree.c
80053 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80054 int nr;
80055 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80056 };
80057 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80058 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80059
80060 static inline void *ptr_to_indirect(void *ptr)
80061 {
80062 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80063 index bb2b201..46abaf9 100644
80064 --- a/lib/strncpy_from_user.c
80065 +++ b/lib/strncpy_from_user.c
80066 @@ -21,7 +21,7 @@
80067 */
80068 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80069 {
80070 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80071 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80072 long res = 0;
80073
80074 /*
80075 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80076 index a28df52..3d55877 100644
80077 --- a/lib/strnlen_user.c
80078 +++ b/lib/strnlen_user.c
80079 @@ -26,7 +26,7 @@
80080 */
80081 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80082 {
80083 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80084 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80085 long align, res = 0;
80086 unsigned long c;
80087
80088 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80089 index d23762e..e21eab2 100644
80090 --- a/lib/swiotlb.c
80091 +++ b/lib/swiotlb.c
80092 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80093
80094 void
80095 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80096 - dma_addr_t dev_addr)
80097 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80098 {
80099 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80100
80101 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80102 index 0d62fd7..b7bc911 100644
80103 --- a/lib/vsprintf.c
80104 +++ b/lib/vsprintf.c
80105 @@ -16,6 +16,9 @@
80106 * - scnprintf and vscnprintf
80107 */
80108
80109 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80110 +#define __INCLUDED_BY_HIDESYM 1
80111 +#endif
80112 #include <stdarg.h>
80113 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80114 #include <linux/types.h>
80115 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80116 return number(buf, end, *(const netdev_features_t *)addr, spec);
80117 }
80118
80119 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80120 +int kptr_restrict __read_mostly = 2;
80121 +#else
80122 int kptr_restrict __read_mostly;
80123 +#endif
80124
80125 /*
80126 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80127 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80128 * - 'S' For symbolic direct pointers with offset
80129 * - 's' For symbolic direct pointers without offset
80130 * - 'B' For backtraced symbolic direct pointers with offset
80131 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80132 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80133 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80134 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80135 * - 'M' For a 6-byte MAC address, it prints the address in the
80136 @@ -1044,12 +1053,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80137
80138 if (!ptr && *fmt != 'K') {
80139 /*
80140 - * Print (null) with the same width as a pointer so it makes
80141 + * Print (nil) with the same width as a pointer so it makes
80142 * tabular output look nice.
80143 */
80144 if (spec.field_width == -1)
80145 spec.field_width = default_width;
80146 - return string(buf, end, "(null)", spec);
80147 + return string(buf, end, "(nil)", spec);
80148 }
80149
80150 switch (*fmt) {
80151 @@ -1059,6 +1068,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80152 /* Fallthrough */
80153 case 'S':
80154 case 's':
80155 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80156 + break;
80157 +#else
80158 + return symbol_string(buf, end, ptr, spec, *fmt);
80159 +#endif
80160 + case 'A':
80161 case 'B':
80162 return symbol_string(buf, end, ptr, spec, *fmt);
80163 case 'R':
80164 @@ -1099,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80165 va_end(va);
80166 return buf;
80167 }
80168 + case 'P':
80169 + break;
80170 case 'K':
80171 /*
80172 * %pK cannot be used in IRQ context because its test
80173 @@ -1128,6 +1145,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80174 return number(buf, end,
80175 (unsigned long long) *((phys_addr_t *)ptr), spec);
80176 }
80177 +
80178 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80179 + /* 'P' = approved pointers to copy to userland,
80180 + as in the /proc/kallsyms case, as we make it display nothing
80181 + for non-root users, and the real contents for root users
80182 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80183 + above
80184 + */
80185 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80186 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80187 + dump_stack();
80188 + ptr = NULL;
80189 + }
80190 +#endif
80191 +
80192 spec.flags |= SMALL;
80193 if (spec.field_width == -1) {
80194 spec.field_width = default_width;
80195 @@ -1849,11 +1881,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80196 typeof(type) value; \
80197 if (sizeof(type) == 8) { \
80198 args = PTR_ALIGN(args, sizeof(u32)); \
80199 - *(u32 *)&value = *(u32 *)args; \
80200 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80201 + *(u32 *)&value = *(const u32 *)args; \
80202 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80203 } else { \
80204 args = PTR_ALIGN(args, sizeof(type)); \
80205 - value = *(typeof(type) *)args; \
80206 + value = *(const typeof(type) *)args; \
80207 } \
80208 args += sizeof(type); \
80209 value; \
80210 @@ -1916,7 +1948,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80211 case FORMAT_TYPE_STR: {
80212 const char *str_arg = args;
80213 args += strlen(str_arg) + 1;
80214 - str = string(str, end, (char *)str_arg, spec);
80215 + str = string(str, end, str_arg, spec);
80216 break;
80217 }
80218
80219 diff --git a/localversion-grsec b/localversion-grsec
80220 new file mode 100644
80221 index 0000000..7cd6065
80222 --- /dev/null
80223 +++ b/localversion-grsec
80224 @@ -0,0 +1 @@
80225 +-grsec
80226 diff --git a/mm/Kconfig b/mm/Kconfig
80227 index 3bea74f..e821c99 100644
80228 --- a/mm/Kconfig
80229 +++ b/mm/Kconfig
80230 @@ -311,10 +311,10 @@ config KSM
80231 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80232
80233 config DEFAULT_MMAP_MIN_ADDR
80234 - int "Low address space to protect from user allocation"
80235 + int "Low address space to protect from user allocation"
80236 depends on MMU
80237 - default 4096
80238 - help
80239 + default 65536
80240 + help
80241 This is the portion of low virtual memory which should be protected
80242 from userspace allocation. Keeping a user from writing to low pages
80243 can help reduce the impact of kernel NULL pointer bugs.
80244 @@ -345,7 +345,7 @@ config MEMORY_FAILURE
80245
80246 config HWPOISON_INJECT
80247 tristate "HWPoison pages injector"
80248 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80249 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80250 select PROC_PAGE_MONITOR
80251
80252 config NOMMU_INITIAL_TRIM_EXCESS
80253 diff --git a/mm/filemap.c b/mm/filemap.c
80254 index e1979fd..dda5120 100644
80255 --- a/mm/filemap.c
80256 +++ b/mm/filemap.c
80257 @@ -1748,7 +1748,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80258 struct address_space *mapping = file->f_mapping;
80259
80260 if (!mapping->a_ops->readpage)
80261 - return -ENOEXEC;
80262 + return -ENODEV;
80263 file_accessed(file);
80264 vma->vm_ops = &generic_file_vm_ops;
80265 return 0;
80266 @@ -2088,6 +2088,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80267 *pos = i_size_read(inode);
80268
80269 if (limit != RLIM_INFINITY) {
80270 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80271 if (*pos >= limit) {
80272 send_sig(SIGXFSZ, current, 0);
80273 return -EFBIG;
80274 diff --git a/mm/fremap.c b/mm/fremap.c
80275 index 87da359..3f41cb1 100644
80276 --- a/mm/fremap.c
80277 +++ b/mm/fremap.c
80278 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80279 retry:
80280 vma = find_vma(mm, start);
80281
80282 +#ifdef CONFIG_PAX_SEGMEXEC
80283 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80284 + goto out;
80285 +#endif
80286 +
80287 /*
80288 * Make sure the vma is shared, that it supports prefaulting,
80289 * and that the remapped range is valid and fully within
80290 diff --git a/mm/highmem.c b/mm/highmem.c
80291 index b32b70c..e512eb0 100644
80292 --- a/mm/highmem.c
80293 +++ b/mm/highmem.c
80294 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80295 * So no dangers, even with speculative execution.
80296 */
80297 page = pte_page(pkmap_page_table[i]);
80298 + pax_open_kernel();
80299 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80300 -
80301 + pax_close_kernel();
80302 set_page_address(page, NULL);
80303 need_flush = 1;
80304 }
80305 @@ -198,9 +199,11 @@ start:
80306 }
80307 }
80308 vaddr = PKMAP_ADDR(last_pkmap_nr);
80309 +
80310 + pax_open_kernel();
80311 set_pte_at(&init_mm, vaddr,
80312 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80313 -
80314 + pax_close_kernel();
80315 pkmap_count[last_pkmap_nr] = 1;
80316 set_page_address(page, (void *)vaddr);
80317
80318 diff --git a/mm/huge_memory.c b/mm/huge_memory.c
80319 index e2f7f5aa..a4510d4 100644
80320 --- a/mm/huge_memory.c
80321 +++ b/mm/huge_memory.c
80322 @@ -2318,7 +2318,12 @@ static void collapse_huge_page(struct mm_struct *mm,
80323 pte_unmap(pte);
80324 spin_lock(&mm->page_table_lock);
80325 BUG_ON(!pmd_none(*pmd));
80326 - set_pmd_at(mm, address, pmd, _pmd);
80327 + /*
80328 + * We can only use set_pmd_at when establishing
80329 + * hugepmds and never for establishing regular pmds that
80330 + * points to regular pagetables. Use pmd_populate for that
80331 + */
80332 + pmd_populate(mm, pmd, pmd_pgtable(_pmd));
80333 spin_unlock(&mm->page_table_lock);
80334 anon_vma_unlock_write(vma->anon_vma);
80335 goto out;
80336 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80337 index 1a12f5b..a85b8fc 100644
80338 --- a/mm/hugetlb.c
80339 +++ b/mm/hugetlb.c
80340 @@ -2005,15 +2005,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80341 struct hstate *h = &default_hstate;
80342 unsigned long tmp;
80343 int ret;
80344 + ctl_table_no_const hugetlb_table;
80345
80346 tmp = h->max_huge_pages;
80347
80348 if (write && h->order >= MAX_ORDER)
80349 return -EINVAL;
80350
80351 - table->data = &tmp;
80352 - table->maxlen = sizeof(unsigned long);
80353 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80354 + hugetlb_table = *table;
80355 + hugetlb_table.data = &tmp;
80356 + hugetlb_table.maxlen = sizeof(unsigned long);
80357 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80358 if (ret)
80359 goto out;
80360
80361 @@ -2070,15 +2072,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80362 struct hstate *h = &default_hstate;
80363 unsigned long tmp;
80364 int ret;
80365 + ctl_table_no_const hugetlb_table;
80366
80367 tmp = h->nr_overcommit_huge_pages;
80368
80369 if (write && h->order >= MAX_ORDER)
80370 return -EINVAL;
80371
80372 - table->data = &tmp;
80373 - table->maxlen = sizeof(unsigned long);
80374 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80375 + hugetlb_table = *table;
80376 + hugetlb_table.data = &tmp;
80377 + hugetlb_table.maxlen = sizeof(unsigned long);
80378 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80379 if (ret)
80380 goto out;
80381
80382 @@ -2512,6 +2516,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80383 return 1;
80384 }
80385
80386 +#ifdef CONFIG_PAX_SEGMEXEC
80387 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80388 +{
80389 + struct mm_struct *mm = vma->vm_mm;
80390 + struct vm_area_struct *vma_m;
80391 + unsigned long address_m;
80392 + pte_t *ptep_m;
80393 +
80394 + vma_m = pax_find_mirror_vma(vma);
80395 + if (!vma_m)
80396 + return;
80397 +
80398 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80399 + address_m = address + SEGMEXEC_TASK_SIZE;
80400 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80401 + get_page(page_m);
80402 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80403 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
80404 +}
80405 +#endif
80406 +
80407 /*
80408 * Hugetlb_cow() should be called with page lock of the original hugepage held.
80409 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
80410 @@ -2630,6 +2655,11 @@ retry_avoidcopy:
80411 make_huge_pte(vma, new_page, 1));
80412 page_remove_rmap(old_page);
80413 hugepage_add_new_anon_rmap(new_page, vma, address);
80414 +
80415 +#ifdef CONFIG_PAX_SEGMEXEC
80416 + pax_mirror_huge_pte(vma, address, new_page);
80417 +#endif
80418 +
80419 /* Make the old page be freed below */
80420 new_page = old_page;
80421 }
80422 @@ -2788,6 +2818,10 @@ retry:
80423 && (vma->vm_flags & VM_SHARED)));
80424 set_huge_pte_at(mm, address, ptep, new_pte);
80425
80426 +#ifdef CONFIG_PAX_SEGMEXEC
80427 + pax_mirror_huge_pte(vma, address, page);
80428 +#endif
80429 +
80430 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
80431 /* Optimization, do the COW without a second fault */
80432 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
80433 @@ -2817,6 +2851,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80434 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
80435 struct hstate *h = hstate_vma(vma);
80436
80437 +#ifdef CONFIG_PAX_SEGMEXEC
80438 + struct vm_area_struct *vma_m;
80439 +#endif
80440 +
80441 address &= huge_page_mask(h);
80442
80443 ptep = huge_pte_offset(mm, address);
80444 @@ -2830,6 +2868,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80445 VM_FAULT_SET_HINDEX(hstate_index(h));
80446 }
80447
80448 +#ifdef CONFIG_PAX_SEGMEXEC
80449 + vma_m = pax_find_mirror_vma(vma);
80450 + if (vma_m) {
80451 + unsigned long address_m;
80452 +
80453 + if (vma->vm_start > vma_m->vm_start) {
80454 + address_m = address;
80455 + address -= SEGMEXEC_TASK_SIZE;
80456 + vma = vma_m;
80457 + h = hstate_vma(vma);
80458 + } else
80459 + address_m = address + SEGMEXEC_TASK_SIZE;
80460 +
80461 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
80462 + return VM_FAULT_OOM;
80463 + address_m &= HPAGE_MASK;
80464 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
80465 + }
80466 +#endif
80467 +
80468 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
80469 if (!ptep)
80470 return VM_FAULT_OOM;
80471 diff --git a/mm/internal.h b/mm/internal.h
80472 index 8562de0..7fdfe92 100644
80473 --- a/mm/internal.h
80474 +++ b/mm/internal.h
80475 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
80476 * in mm/page_alloc.c
80477 */
80478 extern void __free_pages_bootmem(struct page *page, unsigned int order);
80479 +extern void free_compound_page(struct page *page);
80480 extern void prep_compound_page(struct page *page, unsigned long order);
80481 #ifdef CONFIG_MEMORY_FAILURE
80482 extern bool is_free_buddy_page(struct page *page);
80483 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
80484 index c8d7f31..2dbeffd 100644
80485 --- a/mm/kmemleak.c
80486 +++ b/mm/kmemleak.c
80487 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
80488
80489 for (i = 0; i < object->trace_len; i++) {
80490 void *ptr = (void *)object->trace[i];
80491 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
80492 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
80493 }
80494 }
80495
80496 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
80497 return -ENOMEM;
80498 }
80499
80500 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
80501 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
80502 &kmemleak_fops);
80503 if (!dentry)
80504 pr_warning("Failed to create the debugfs kmemleak file\n");
80505 diff --git a/mm/maccess.c b/mm/maccess.c
80506 index d53adf9..03a24bf 100644
80507 --- a/mm/maccess.c
80508 +++ b/mm/maccess.c
80509 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
80510 set_fs(KERNEL_DS);
80511 pagefault_disable();
80512 ret = __copy_from_user_inatomic(dst,
80513 - (__force const void __user *)src, size);
80514 + (const void __force_user *)src, size);
80515 pagefault_enable();
80516 set_fs(old_fs);
80517
80518 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
80519
80520 set_fs(KERNEL_DS);
80521 pagefault_disable();
80522 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
80523 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
80524 pagefault_enable();
80525 set_fs(old_fs);
80526
80527 diff --git a/mm/madvise.c b/mm/madvise.c
80528 index c58c94b..86ec14e 100644
80529 --- a/mm/madvise.c
80530 +++ b/mm/madvise.c
80531 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
80532 pgoff_t pgoff;
80533 unsigned long new_flags = vma->vm_flags;
80534
80535 +#ifdef CONFIG_PAX_SEGMEXEC
80536 + struct vm_area_struct *vma_m;
80537 +#endif
80538 +
80539 switch (behavior) {
80540 case MADV_NORMAL:
80541 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
80542 @@ -126,6 +130,13 @@ success:
80543 /*
80544 * vm_flags is protected by the mmap_sem held in write mode.
80545 */
80546 +
80547 +#ifdef CONFIG_PAX_SEGMEXEC
80548 + vma_m = pax_find_mirror_vma(vma);
80549 + if (vma_m)
80550 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
80551 +#endif
80552 +
80553 vma->vm_flags = new_flags;
80554
80555 out:
80556 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80557 struct vm_area_struct ** prev,
80558 unsigned long start, unsigned long end)
80559 {
80560 +
80561 +#ifdef CONFIG_PAX_SEGMEXEC
80562 + struct vm_area_struct *vma_m;
80563 +#endif
80564 +
80565 *prev = vma;
80566 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
80567 return -EINVAL;
80568 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80569 zap_page_range(vma, start, end - start, &details);
80570 } else
80571 zap_page_range(vma, start, end - start, NULL);
80572 +
80573 +#ifdef CONFIG_PAX_SEGMEXEC
80574 + vma_m = pax_find_mirror_vma(vma);
80575 + if (vma_m) {
80576 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
80577 + struct zap_details details = {
80578 + .nonlinear_vma = vma_m,
80579 + .last_index = ULONG_MAX,
80580 + };
80581 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
80582 + } else
80583 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
80584 + }
80585 +#endif
80586 +
80587 return 0;
80588 }
80589
80590 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
80591 if (end < start)
80592 goto out;
80593
80594 +#ifdef CONFIG_PAX_SEGMEXEC
80595 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
80596 + if (end > SEGMEXEC_TASK_SIZE)
80597 + goto out;
80598 + } else
80599 +#endif
80600 +
80601 + if (end > TASK_SIZE)
80602 + goto out;
80603 +
80604 error = 0;
80605 if (end == start)
80606 goto out;
80607 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
80608 index df0694c..bc95539 100644
80609 --- a/mm/memory-failure.c
80610 +++ b/mm/memory-failure.c
80611 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
80612
80613 int sysctl_memory_failure_recovery __read_mostly = 1;
80614
80615 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
80616 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
80617
80618 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
80619
80620 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
80621 pfn, t->comm, t->pid);
80622 si.si_signo = SIGBUS;
80623 si.si_errno = 0;
80624 - si.si_addr = (void *)addr;
80625 + si.si_addr = (void __user *)addr;
80626 #ifdef __ARCH_SI_TRAPNO
80627 si.si_trapno = trapno;
80628 #endif
80629 @@ -760,7 +760,7 @@ static struct page_state {
80630 unsigned long res;
80631 char *msg;
80632 int (*action)(struct page *p, unsigned long pfn);
80633 -} error_states[] = {
80634 +} __do_const error_states[] = {
80635 { reserved, reserved, "reserved kernel", me_kernel },
80636 /*
80637 * free pages are specially detected outside this table:
80638 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80639 nr_pages = 1 << compound_order(hpage);
80640 else /* normal page or thp */
80641 nr_pages = 1;
80642 - atomic_long_add(nr_pages, &num_poisoned_pages);
80643 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
80644
80645 /*
80646 * We need/can do nothing about count=0 pages.
80647 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80648 if (!PageHWPoison(hpage)
80649 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
80650 || (p != hpage && TestSetPageHWPoison(hpage))) {
80651 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80652 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80653 return 0;
80654 }
80655 set_page_hwpoison_huge_page(hpage);
80656 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80657 }
80658 if (hwpoison_filter(p)) {
80659 if (TestClearPageHWPoison(p))
80660 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80661 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80662 unlock_page(hpage);
80663 put_page(hpage);
80664 return 0;
80665 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
80666 return 0;
80667 }
80668 if (TestClearPageHWPoison(p))
80669 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80670 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80671 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
80672 return 0;
80673 }
80674 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
80675 */
80676 if (TestClearPageHWPoison(page)) {
80677 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
80678 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80679 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80680 freeit = 1;
80681 if (PageHuge(page))
80682 clear_page_hwpoison_huge_page(page);
80683 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
80684 } else {
80685 set_page_hwpoison_huge_page(hpage);
80686 dequeue_hwpoisoned_huge_page(hpage);
80687 - atomic_long_add(1 << compound_trans_order(hpage),
80688 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
80689 &num_poisoned_pages);
80690 }
80691 /* keep elevated page count for bad page */
80692 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
80693 if (PageHuge(page)) {
80694 set_page_hwpoison_huge_page(hpage);
80695 dequeue_hwpoisoned_huge_page(hpage);
80696 - atomic_long_add(1 << compound_trans_order(hpage),
80697 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
80698 &num_poisoned_pages);
80699 } else {
80700 SetPageHWPoison(page);
80701 - atomic_long_inc(&num_poisoned_pages);
80702 + atomic_long_inc_unchecked(&num_poisoned_pages);
80703 }
80704 }
80705 /* keep elevated page count for bad page */
80706 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
80707 put_page(page);
80708 pr_info("soft_offline: %#lx: invalidated\n", pfn);
80709 SetPageHWPoison(page);
80710 - atomic_long_inc(&num_poisoned_pages);
80711 + atomic_long_inc_unchecked(&num_poisoned_pages);
80712 return 0;
80713 }
80714
80715 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
80716 ret = -EIO;
80717 } else {
80718 SetPageHWPoison(page);
80719 - atomic_long_inc(&num_poisoned_pages);
80720 + atomic_long_inc_unchecked(&num_poisoned_pages);
80721 }
80722 } else {
80723 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
80724 diff --git a/mm/memory.c b/mm/memory.c
80725 index ba94dec..08ffe0d 100644
80726 --- a/mm/memory.c
80727 +++ b/mm/memory.c
80728 @@ -438,6 +438,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80729 free_pte_range(tlb, pmd, addr);
80730 } while (pmd++, addr = next, addr != end);
80731
80732 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
80733 start &= PUD_MASK;
80734 if (start < floor)
80735 return;
80736 @@ -452,6 +453,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80737 pmd = pmd_offset(pud, start);
80738 pud_clear(pud);
80739 pmd_free_tlb(tlb, pmd, start);
80740 +#endif
80741 +
80742 }
80743
80744 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80745 @@ -471,6 +474,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80746 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
80747 } while (pud++, addr = next, addr != end);
80748
80749 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
80750 start &= PGDIR_MASK;
80751 if (start < floor)
80752 return;
80753 @@ -485,6 +489,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80754 pud = pud_offset(pgd, start);
80755 pgd_clear(pgd);
80756 pud_free_tlb(tlb, pud, start);
80757 +#endif
80758 +
80759 }
80760
80761 /*
80762 @@ -1644,12 +1650,6 @@ no_page_table:
80763 return page;
80764 }
80765
80766 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
80767 -{
80768 - return stack_guard_page_start(vma, addr) ||
80769 - stack_guard_page_end(vma, addr+PAGE_SIZE);
80770 -}
80771 -
80772 /**
80773 * __get_user_pages() - pin user pages in memory
80774 * @tsk: task_struct of target task
80775 @@ -1736,10 +1736,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80776
80777 i = 0;
80778
80779 - do {
80780 + while (nr_pages) {
80781 struct vm_area_struct *vma;
80782
80783 - vma = find_extend_vma(mm, start);
80784 + vma = find_vma(mm, start);
80785 if (!vma && in_gate_area(mm, start)) {
80786 unsigned long pg = start & PAGE_MASK;
80787 pgd_t *pgd;
80788 @@ -1788,7 +1788,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80789 goto next_page;
80790 }
80791
80792 - if (!vma ||
80793 + if (!vma || start < vma->vm_start ||
80794 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
80795 !(vm_flags & vma->vm_flags))
80796 return i ? : -EFAULT;
80797 @@ -1817,11 +1817,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80798 int ret;
80799 unsigned int fault_flags = 0;
80800
80801 - /* For mlock, just skip the stack guard page. */
80802 - if (foll_flags & FOLL_MLOCK) {
80803 - if (stack_guard_page(vma, start))
80804 - goto next_page;
80805 - }
80806 if (foll_flags & FOLL_WRITE)
80807 fault_flags |= FAULT_FLAG_WRITE;
80808 if (nonblocking)
80809 @@ -1901,7 +1896,7 @@ next_page:
80810 start += page_increm * PAGE_SIZE;
80811 nr_pages -= page_increm;
80812 } while (nr_pages && start < vma->vm_end);
80813 - } while (nr_pages);
80814 + }
80815 return i;
80816 }
80817 EXPORT_SYMBOL(__get_user_pages);
80818 @@ -2108,6 +2103,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
80819 page_add_file_rmap(page);
80820 set_pte_at(mm, addr, pte, mk_pte(page, prot));
80821
80822 +#ifdef CONFIG_PAX_SEGMEXEC
80823 + pax_mirror_file_pte(vma, addr, page, ptl);
80824 +#endif
80825 +
80826 retval = 0;
80827 pte_unmap_unlock(pte, ptl);
80828 return retval;
80829 @@ -2152,9 +2151,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
80830 if (!page_count(page))
80831 return -EINVAL;
80832 if (!(vma->vm_flags & VM_MIXEDMAP)) {
80833 +
80834 +#ifdef CONFIG_PAX_SEGMEXEC
80835 + struct vm_area_struct *vma_m;
80836 +#endif
80837 +
80838 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
80839 BUG_ON(vma->vm_flags & VM_PFNMAP);
80840 vma->vm_flags |= VM_MIXEDMAP;
80841 +
80842 +#ifdef CONFIG_PAX_SEGMEXEC
80843 + vma_m = pax_find_mirror_vma(vma);
80844 + if (vma_m)
80845 + vma_m->vm_flags |= VM_MIXEDMAP;
80846 +#endif
80847 +
80848 }
80849 return insert_page(vma, addr, page, vma->vm_page_prot);
80850 }
80851 @@ -2237,6 +2248,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
80852 unsigned long pfn)
80853 {
80854 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
80855 + BUG_ON(vma->vm_mirror);
80856
80857 if (addr < vma->vm_start || addr >= vma->vm_end)
80858 return -EFAULT;
80859 @@ -2484,7 +2496,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
80860
80861 BUG_ON(pud_huge(*pud));
80862
80863 - pmd = pmd_alloc(mm, pud, addr);
80864 + pmd = (mm == &init_mm) ?
80865 + pmd_alloc_kernel(mm, pud, addr) :
80866 + pmd_alloc(mm, pud, addr);
80867 if (!pmd)
80868 return -ENOMEM;
80869 do {
80870 @@ -2504,7 +2518,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
80871 unsigned long next;
80872 int err;
80873
80874 - pud = pud_alloc(mm, pgd, addr);
80875 + pud = (mm == &init_mm) ?
80876 + pud_alloc_kernel(mm, pgd, addr) :
80877 + pud_alloc(mm, pgd, addr);
80878 if (!pud)
80879 return -ENOMEM;
80880 do {
80881 @@ -2592,6 +2608,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
80882 copy_user_highpage(dst, src, va, vma);
80883 }
80884
80885 +#ifdef CONFIG_PAX_SEGMEXEC
80886 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
80887 +{
80888 + struct mm_struct *mm = vma->vm_mm;
80889 + spinlock_t *ptl;
80890 + pte_t *pte, entry;
80891 +
80892 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
80893 + entry = *pte;
80894 + if (!pte_present(entry)) {
80895 + if (!pte_none(entry)) {
80896 + BUG_ON(pte_file(entry));
80897 + free_swap_and_cache(pte_to_swp_entry(entry));
80898 + pte_clear_not_present_full(mm, address, pte, 0);
80899 + }
80900 + } else {
80901 + struct page *page;
80902 +
80903 + flush_cache_page(vma, address, pte_pfn(entry));
80904 + entry = ptep_clear_flush(vma, address, pte);
80905 + BUG_ON(pte_dirty(entry));
80906 + page = vm_normal_page(vma, address, entry);
80907 + if (page) {
80908 + update_hiwater_rss(mm);
80909 + if (PageAnon(page))
80910 + dec_mm_counter_fast(mm, MM_ANONPAGES);
80911 + else
80912 + dec_mm_counter_fast(mm, MM_FILEPAGES);
80913 + page_remove_rmap(page);
80914 + page_cache_release(page);
80915 + }
80916 + }
80917 + pte_unmap_unlock(pte, ptl);
80918 +}
80919 +
80920 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
80921 + *
80922 + * the ptl of the lower mapped page is held on entry and is not released on exit
80923 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
80924 + */
80925 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80926 +{
80927 + struct mm_struct *mm = vma->vm_mm;
80928 + unsigned long address_m;
80929 + spinlock_t *ptl_m;
80930 + struct vm_area_struct *vma_m;
80931 + pmd_t *pmd_m;
80932 + pte_t *pte_m, entry_m;
80933 +
80934 + BUG_ON(!page_m || !PageAnon(page_m));
80935 +
80936 + vma_m = pax_find_mirror_vma(vma);
80937 + if (!vma_m)
80938 + return;
80939 +
80940 + BUG_ON(!PageLocked(page_m));
80941 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80942 + address_m = address + SEGMEXEC_TASK_SIZE;
80943 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80944 + pte_m = pte_offset_map(pmd_m, address_m);
80945 + ptl_m = pte_lockptr(mm, pmd_m);
80946 + if (ptl != ptl_m) {
80947 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80948 + if (!pte_none(*pte_m))
80949 + goto out;
80950 + }
80951 +
80952 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80953 + page_cache_get(page_m);
80954 + page_add_anon_rmap(page_m, vma_m, address_m);
80955 + inc_mm_counter_fast(mm, MM_ANONPAGES);
80956 + set_pte_at(mm, address_m, pte_m, entry_m);
80957 + update_mmu_cache(vma_m, address_m, pte_m);
80958 +out:
80959 + if (ptl != ptl_m)
80960 + spin_unlock(ptl_m);
80961 + pte_unmap(pte_m);
80962 + unlock_page(page_m);
80963 +}
80964 +
80965 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80966 +{
80967 + struct mm_struct *mm = vma->vm_mm;
80968 + unsigned long address_m;
80969 + spinlock_t *ptl_m;
80970 + struct vm_area_struct *vma_m;
80971 + pmd_t *pmd_m;
80972 + pte_t *pte_m, entry_m;
80973 +
80974 + BUG_ON(!page_m || PageAnon(page_m));
80975 +
80976 + vma_m = pax_find_mirror_vma(vma);
80977 + if (!vma_m)
80978 + return;
80979 +
80980 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80981 + address_m = address + SEGMEXEC_TASK_SIZE;
80982 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80983 + pte_m = pte_offset_map(pmd_m, address_m);
80984 + ptl_m = pte_lockptr(mm, pmd_m);
80985 + if (ptl != ptl_m) {
80986 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80987 + if (!pte_none(*pte_m))
80988 + goto out;
80989 + }
80990 +
80991 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80992 + page_cache_get(page_m);
80993 + page_add_file_rmap(page_m);
80994 + inc_mm_counter_fast(mm, MM_FILEPAGES);
80995 + set_pte_at(mm, address_m, pte_m, entry_m);
80996 + update_mmu_cache(vma_m, address_m, pte_m);
80997 +out:
80998 + if (ptl != ptl_m)
80999 + spin_unlock(ptl_m);
81000 + pte_unmap(pte_m);
81001 +}
81002 +
81003 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81004 +{
81005 + struct mm_struct *mm = vma->vm_mm;
81006 + unsigned long address_m;
81007 + spinlock_t *ptl_m;
81008 + struct vm_area_struct *vma_m;
81009 + pmd_t *pmd_m;
81010 + pte_t *pte_m, entry_m;
81011 +
81012 + vma_m = pax_find_mirror_vma(vma);
81013 + if (!vma_m)
81014 + return;
81015 +
81016 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81017 + address_m = address + SEGMEXEC_TASK_SIZE;
81018 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81019 + pte_m = pte_offset_map(pmd_m, address_m);
81020 + ptl_m = pte_lockptr(mm, pmd_m);
81021 + if (ptl != ptl_m) {
81022 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81023 + if (!pte_none(*pte_m))
81024 + goto out;
81025 + }
81026 +
81027 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81028 + set_pte_at(mm, address_m, pte_m, entry_m);
81029 +out:
81030 + if (ptl != ptl_m)
81031 + spin_unlock(ptl_m);
81032 + pte_unmap(pte_m);
81033 +}
81034 +
81035 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81036 +{
81037 + struct page *page_m;
81038 + pte_t entry;
81039 +
81040 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81041 + goto out;
81042 +
81043 + entry = *pte;
81044 + page_m = vm_normal_page(vma, address, entry);
81045 + if (!page_m)
81046 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81047 + else if (PageAnon(page_m)) {
81048 + if (pax_find_mirror_vma(vma)) {
81049 + pte_unmap_unlock(pte, ptl);
81050 + lock_page(page_m);
81051 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81052 + if (pte_same(entry, *pte))
81053 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81054 + else
81055 + unlock_page(page_m);
81056 + }
81057 + } else
81058 + pax_mirror_file_pte(vma, address, page_m, ptl);
81059 +
81060 +out:
81061 + pte_unmap_unlock(pte, ptl);
81062 +}
81063 +#endif
81064 +
81065 /*
81066 * This routine handles present pages, when users try to write
81067 * to a shared page. It is done by copying the page to a new address
81068 @@ -2808,6 +3004,12 @@ gotten:
81069 */
81070 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81071 if (likely(pte_same(*page_table, orig_pte))) {
81072 +
81073 +#ifdef CONFIG_PAX_SEGMEXEC
81074 + if (pax_find_mirror_vma(vma))
81075 + BUG_ON(!trylock_page(new_page));
81076 +#endif
81077 +
81078 if (old_page) {
81079 if (!PageAnon(old_page)) {
81080 dec_mm_counter_fast(mm, MM_FILEPAGES);
81081 @@ -2859,6 +3061,10 @@ gotten:
81082 page_remove_rmap(old_page);
81083 }
81084
81085 +#ifdef CONFIG_PAX_SEGMEXEC
81086 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81087 +#endif
81088 +
81089 /* Free the old page.. */
81090 new_page = old_page;
81091 ret |= VM_FAULT_WRITE;
81092 @@ -3134,6 +3340,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81093 swap_free(entry);
81094 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81095 try_to_free_swap(page);
81096 +
81097 +#ifdef CONFIG_PAX_SEGMEXEC
81098 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81099 +#endif
81100 +
81101 unlock_page(page);
81102 if (page != swapcache) {
81103 /*
81104 @@ -3157,6 +3368,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81105
81106 /* No need to invalidate - it was non-present before */
81107 update_mmu_cache(vma, address, page_table);
81108 +
81109 +#ifdef CONFIG_PAX_SEGMEXEC
81110 + pax_mirror_anon_pte(vma, address, page, ptl);
81111 +#endif
81112 +
81113 unlock:
81114 pte_unmap_unlock(page_table, ptl);
81115 out:
81116 @@ -3176,40 +3392,6 @@ out_release:
81117 }
81118
81119 /*
81120 - * This is like a special single-page "expand_{down|up}wards()",
81121 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81122 - * doesn't hit another vma.
81123 - */
81124 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81125 -{
81126 - address &= PAGE_MASK;
81127 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81128 - struct vm_area_struct *prev = vma->vm_prev;
81129 -
81130 - /*
81131 - * Is there a mapping abutting this one below?
81132 - *
81133 - * That's only ok if it's the same stack mapping
81134 - * that has gotten split..
81135 - */
81136 - if (prev && prev->vm_end == address)
81137 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81138 -
81139 - expand_downwards(vma, address - PAGE_SIZE);
81140 - }
81141 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81142 - struct vm_area_struct *next = vma->vm_next;
81143 -
81144 - /* As VM_GROWSDOWN but s/below/above/ */
81145 - if (next && next->vm_start == address + PAGE_SIZE)
81146 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81147 -
81148 - expand_upwards(vma, address + PAGE_SIZE);
81149 - }
81150 - return 0;
81151 -}
81152 -
81153 -/*
81154 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81155 * but allow concurrent faults), and pte mapped but not yet locked.
81156 * We return with mmap_sem still held, but pte unmapped and unlocked.
81157 @@ -3218,27 +3400,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81158 unsigned long address, pte_t *page_table, pmd_t *pmd,
81159 unsigned int flags)
81160 {
81161 - struct page *page;
81162 + struct page *page = NULL;
81163 spinlock_t *ptl;
81164 pte_t entry;
81165
81166 - pte_unmap(page_table);
81167 -
81168 - /* Check if we need to add a guard page to the stack */
81169 - if (check_stack_guard_page(vma, address) < 0)
81170 - return VM_FAULT_SIGBUS;
81171 -
81172 - /* Use the zero-page for reads */
81173 if (!(flags & FAULT_FLAG_WRITE)) {
81174 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81175 vma->vm_page_prot));
81176 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81177 + ptl = pte_lockptr(mm, pmd);
81178 + spin_lock(ptl);
81179 if (!pte_none(*page_table))
81180 goto unlock;
81181 goto setpte;
81182 }
81183
81184 /* Allocate our own private page. */
81185 + pte_unmap(page_table);
81186 +
81187 if (unlikely(anon_vma_prepare(vma)))
81188 goto oom;
81189 page = alloc_zeroed_user_highpage_movable(vma, address);
81190 @@ -3257,6 +3435,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81191 if (!pte_none(*page_table))
81192 goto release;
81193
81194 +#ifdef CONFIG_PAX_SEGMEXEC
81195 + if (pax_find_mirror_vma(vma))
81196 + BUG_ON(!trylock_page(page));
81197 +#endif
81198 +
81199 inc_mm_counter_fast(mm, MM_ANONPAGES);
81200 page_add_new_anon_rmap(page, vma, address);
81201 setpte:
81202 @@ -3264,6 +3447,12 @@ setpte:
81203
81204 /* No need to invalidate - it was non-present before */
81205 update_mmu_cache(vma, address, page_table);
81206 +
81207 +#ifdef CONFIG_PAX_SEGMEXEC
81208 + if (page)
81209 + pax_mirror_anon_pte(vma, address, page, ptl);
81210 +#endif
81211 +
81212 unlock:
81213 pte_unmap_unlock(page_table, ptl);
81214 return 0;
81215 @@ -3407,6 +3596,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81216 */
81217 /* Only go through if we didn't race with anybody else... */
81218 if (likely(pte_same(*page_table, orig_pte))) {
81219 +
81220 +#ifdef CONFIG_PAX_SEGMEXEC
81221 + if (anon && pax_find_mirror_vma(vma))
81222 + BUG_ON(!trylock_page(page));
81223 +#endif
81224 +
81225 flush_icache_page(vma, page);
81226 entry = mk_pte(page, vma->vm_page_prot);
81227 if (flags & FAULT_FLAG_WRITE)
81228 @@ -3426,6 +3621,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81229
81230 /* no need to invalidate: a not-present page won't be cached */
81231 update_mmu_cache(vma, address, page_table);
81232 +
81233 +#ifdef CONFIG_PAX_SEGMEXEC
81234 + if (anon)
81235 + pax_mirror_anon_pte(vma, address, page, ptl);
81236 + else
81237 + pax_mirror_file_pte(vma, address, page, ptl);
81238 +#endif
81239 +
81240 } else {
81241 if (cow_page)
81242 mem_cgroup_uncharge_page(cow_page);
81243 @@ -3747,6 +3950,12 @@ int handle_pte_fault(struct mm_struct *mm,
81244 if (flags & FAULT_FLAG_WRITE)
81245 flush_tlb_fix_spurious_fault(vma, address);
81246 }
81247 +
81248 +#ifdef CONFIG_PAX_SEGMEXEC
81249 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81250 + return 0;
81251 +#endif
81252 +
81253 unlock:
81254 pte_unmap_unlock(pte, ptl);
81255 return 0;
81256 @@ -3763,6 +3972,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81257 pmd_t *pmd;
81258 pte_t *pte;
81259
81260 +#ifdef CONFIG_PAX_SEGMEXEC
81261 + struct vm_area_struct *vma_m;
81262 +#endif
81263 +
81264 __set_current_state(TASK_RUNNING);
81265
81266 count_vm_event(PGFAULT);
81267 @@ -3774,6 +3987,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81268 if (unlikely(is_vm_hugetlb_page(vma)))
81269 return hugetlb_fault(mm, vma, address, flags);
81270
81271 +#ifdef CONFIG_PAX_SEGMEXEC
81272 + vma_m = pax_find_mirror_vma(vma);
81273 + if (vma_m) {
81274 + unsigned long address_m;
81275 + pgd_t *pgd_m;
81276 + pud_t *pud_m;
81277 + pmd_t *pmd_m;
81278 +
81279 + if (vma->vm_start > vma_m->vm_start) {
81280 + address_m = address;
81281 + address -= SEGMEXEC_TASK_SIZE;
81282 + vma = vma_m;
81283 + } else
81284 + address_m = address + SEGMEXEC_TASK_SIZE;
81285 +
81286 + pgd_m = pgd_offset(mm, address_m);
81287 + pud_m = pud_alloc(mm, pgd_m, address_m);
81288 + if (!pud_m)
81289 + return VM_FAULT_OOM;
81290 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81291 + if (!pmd_m)
81292 + return VM_FAULT_OOM;
81293 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81294 + return VM_FAULT_OOM;
81295 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81296 + }
81297 +#endif
81298 +
81299 retry:
81300 pgd = pgd_offset(mm, address);
81301 pud = pud_alloc(mm, pgd, address);
81302 @@ -3872,6 +4113,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81303 spin_unlock(&mm->page_table_lock);
81304 return 0;
81305 }
81306 +
81307 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81308 +{
81309 + pud_t *new = pud_alloc_one(mm, address);
81310 + if (!new)
81311 + return -ENOMEM;
81312 +
81313 + smp_wmb(); /* See comment in __pte_alloc */
81314 +
81315 + spin_lock(&mm->page_table_lock);
81316 + if (pgd_present(*pgd)) /* Another has populated it */
81317 + pud_free(mm, new);
81318 + else
81319 + pgd_populate_kernel(mm, pgd, new);
81320 + spin_unlock(&mm->page_table_lock);
81321 + return 0;
81322 +}
81323 #endif /* __PAGETABLE_PUD_FOLDED */
81324
81325 #ifndef __PAGETABLE_PMD_FOLDED
81326 @@ -3902,6 +4160,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81327 spin_unlock(&mm->page_table_lock);
81328 return 0;
81329 }
81330 +
81331 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81332 +{
81333 + pmd_t *new = pmd_alloc_one(mm, address);
81334 + if (!new)
81335 + return -ENOMEM;
81336 +
81337 + smp_wmb(); /* See comment in __pte_alloc */
81338 +
81339 + spin_lock(&mm->page_table_lock);
81340 +#ifndef __ARCH_HAS_4LEVEL_HACK
81341 + if (pud_present(*pud)) /* Another has populated it */
81342 + pmd_free(mm, new);
81343 + else
81344 + pud_populate_kernel(mm, pud, new);
81345 +#else
81346 + if (pgd_present(*pud)) /* Another has populated it */
81347 + pmd_free(mm, new);
81348 + else
81349 + pgd_populate_kernel(mm, pud, new);
81350 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81351 + spin_unlock(&mm->page_table_lock);
81352 + return 0;
81353 +}
81354 #endif /* __PAGETABLE_PMD_FOLDED */
81355
81356 #if !defined(__HAVE_ARCH_GATE_AREA)
81357 @@ -3915,7 +4197,7 @@ static int __init gate_vma_init(void)
81358 gate_vma.vm_start = FIXADDR_USER_START;
81359 gate_vma.vm_end = FIXADDR_USER_END;
81360 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81361 - gate_vma.vm_page_prot = __P101;
81362 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81363
81364 return 0;
81365 }
81366 @@ -4049,8 +4331,8 @@ out:
81367 return ret;
81368 }
81369
81370 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81371 - void *buf, int len, int write)
81372 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81373 + void *buf, size_t len, int write)
81374 {
81375 resource_size_t phys_addr;
81376 unsigned long prot = 0;
81377 @@ -4075,8 +4357,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81378 * Access another process' address space as given in mm. If non-NULL, use the
81379 * given task for page fault accounting.
81380 */
81381 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81382 - unsigned long addr, void *buf, int len, int write)
81383 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81384 + unsigned long addr, void *buf, size_t len, int write)
81385 {
81386 struct vm_area_struct *vma;
81387 void *old_buf = buf;
81388 @@ -4084,7 +4366,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81389 down_read(&mm->mmap_sem);
81390 /* ignore errors, just check how much was successfully transferred */
81391 while (len) {
81392 - int bytes, ret, offset;
81393 + ssize_t bytes, ret, offset;
81394 void *maddr;
81395 struct page *page = NULL;
81396
81397 @@ -4143,8 +4425,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81398 *
81399 * The caller must hold a reference on @mm.
81400 */
81401 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81402 - void *buf, int len, int write)
81403 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
81404 + void *buf, size_t len, int write)
81405 {
81406 return __access_remote_vm(NULL, mm, addr, buf, len, write);
81407 }
81408 @@ -4154,11 +4436,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81409 * Source/target buffer must be kernel space,
81410 * Do not walk the page table directly, use get_user_pages
81411 */
81412 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
81413 - void *buf, int len, int write)
81414 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
81415 + void *buf, size_t len, int write)
81416 {
81417 struct mm_struct *mm;
81418 - int ret;
81419 + ssize_t ret;
81420
81421 mm = get_task_mm(tsk);
81422 if (!mm)
81423 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
81424 index 7431001..0f8344e 100644
81425 --- a/mm/mempolicy.c
81426 +++ b/mm/mempolicy.c
81427 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81428 unsigned long vmstart;
81429 unsigned long vmend;
81430
81431 +#ifdef CONFIG_PAX_SEGMEXEC
81432 + struct vm_area_struct *vma_m;
81433 +#endif
81434 +
81435 vma = find_vma(mm, start);
81436 if (!vma || vma->vm_start > start)
81437 return -EFAULT;
81438 @@ -744,9 +748,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81439 if (err)
81440 goto out;
81441 }
81442 +
81443 err = vma_replace_policy(vma, new_pol);
81444 if (err)
81445 goto out;
81446 +
81447 +#ifdef CONFIG_PAX_SEGMEXEC
81448 + vma_m = pax_find_mirror_vma(vma);
81449 + if (vma_m) {
81450 + err = vma_replace_policy(vma_m, new_pol);
81451 + if (err)
81452 + goto out;
81453 + }
81454 +#endif
81455 +
81456 }
81457
81458 out:
81459 @@ -1202,6 +1217,17 @@ static long do_mbind(unsigned long start, unsigned long len,
81460
81461 if (end < start)
81462 return -EINVAL;
81463 +
81464 +#ifdef CONFIG_PAX_SEGMEXEC
81465 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81466 + if (end > SEGMEXEC_TASK_SIZE)
81467 + return -EINVAL;
81468 + } else
81469 +#endif
81470 +
81471 + if (end > TASK_SIZE)
81472 + return -EINVAL;
81473 +
81474 if (end == start)
81475 return 0;
81476
81477 @@ -1430,8 +1456,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81478 */
81479 tcred = __task_cred(task);
81480 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81481 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81482 - !capable(CAP_SYS_NICE)) {
81483 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81484 rcu_read_unlock();
81485 err = -EPERM;
81486 goto out_put;
81487 @@ -1462,6 +1487,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81488 goto out;
81489 }
81490
81491 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81492 + if (mm != current->mm &&
81493 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
81494 + mmput(mm);
81495 + err = -EPERM;
81496 + goto out;
81497 + }
81498 +#endif
81499 +
81500 err = do_migrate_pages(mm, old, new,
81501 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
81502
81503 diff --git a/mm/migrate.c b/mm/migrate.c
81504 index 3bbaf5d..299b0e9 100644
81505 --- a/mm/migrate.c
81506 +++ b/mm/migrate.c
81507 @@ -1382,8 +1382,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
81508 */
81509 tcred = __task_cred(task);
81510 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81511 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81512 - !capable(CAP_SYS_NICE)) {
81513 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81514 rcu_read_unlock();
81515 err = -EPERM;
81516 goto out;
81517 diff --git a/mm/mlock.c b/mm/mlock.c
81518 index 79b7cf7..c60424f 100644
81519 --- a/mm/mlock.c
81520 +++ b/mm/mlock.c
81521 @@ -13,6 +13,7 @@
81522 #include <linux/pagemap.h>
81523 #include <linux/mempolicy.h>
81524 #include <linux/syscalls.h>
81525 +#include <linux/security.h>
81526 #include <linux/sched.h>
81527 #include <linux/export.h>
81528 #include <linux/rmap.h>
81529 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
81530 {
81531 unsigned long nstart, end, tmp;
81532 struct vm_area_struct * vma, * prev;
81533 - int error;
81534 + int error = 0;
81535
81536 VM_BUG_ON(start & ~PAGE_MASK);
81537 VM_BUG_ON(len != PAGE_ALIGN(len));
81538 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
81539 return -EINVAL;
81540 if (end == start)
81541 return 0;
81542 + if (end > TASK_SIZE)
81543 + return -EINVAL;
81544 +
81545 vma = find_vma(current->mm, start);
81546 if (!vma || vma->vm_start > start)
81547 return -ENOMEM;
81548 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
81549 for (nstart = start ; ; ) {
81550 vm_flags_t newflags;
81551
81552 +#ifdef CONFIG_PAX_SEGMEXEC
81553 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81554 + break;
81555 +#endif
81556 +
81557 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
81558
81559 newflags = vma->vm_flags & ~VM_LOCKED;
81560 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
81561 lock_limit >>= PAGE_SHIFT;
81562
81563 /* check against resource limits */
81564 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
81565 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
81566 error = do_mlock(start, len, 1);
81567 up_write(&current->mm->mmap_sem);
81568 @@ -500,6 +510,12 @@ static int do_mlockall(int flags)
81569 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
81570 vm_flags_t newflags;
81571
81572 +#ifdef CONFIG_PAX_SEGMEXEC
81573 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81574 + break;
81575 +#endif
81576 +
81577 + BUG_ON(vma->vm_end > TASK_SIZE);
81578 newflags = vma->vm_flags & ~VM_LOCKED;
81579 if (flags & MCL_CURRENT)
81580 newflags |= VM_LOCKED;
81581 @@ -532,6 +548,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
81582 lock_limit >>= PAGE_SHIFT;
81583
81584 ret = -ENOMEM;
81585 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
81586 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
81587 capable(CAP_IPC_LOCK))
81588 ret = do_mlockall(flags);
81589 diff --git a/mm/mmap.c b/mm/mmap.c
81590 index 0dceed8..671951c 100644
81591 --- a/mm/mmap.c
81592 +++ b/mm/mmap.c
81593 @@ -33,6 +33,7 @@
81594 #include <linux/uprobes.h>
81595 #include <linux/rbtree_augmented.h>
81596 #include <linux/sched/sysctl.h>
81597 +#include <linux/random.h>
81598
81599 #include <asm/uaccess.h>
81600 #include <asm/cacheflush.h>
81601 @@ -49,6 +50,16 @@
81602 #define arch_rebalance_pgtables(addr, len) (addr)
81603 #endif
81604
81605 +static inline void verify_mm_writelocked(struct mm_struct *mm)
81606 +{
81607 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
81608 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
81609 + up_read(&mm->mmap_sem);
81610 + BUG();
81611 + }
81612 +#endif
81613 +}
81614 +
81615 static void unmap_region(struct mm_struct *mm,
81616 struct vm_area_struct *vma, struct vm_area_struct *prev,
81617 unsigned long start, unsigned long end);
81618 @@ -68,22 +79,32 @@ static void unmap_region(struct mm_struct *mm,
81619 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
81620 *
81621 */
81622 -pgprot_t protection_map[16] = {
81623 +pgprot_t protection_map[16] __read_only = {
81624 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
81625 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
81626 };
81627
81628 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
81629 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
81630 {
81631 - return __pgprot(pgprot_val(protection_map[vm_flags &
81632 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
81633 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
81634 pgprot_val(arch_vm_get_page_prot(vm_flags)));
81635 +
81636 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81637 + if (!(__supported_pte_mask & _PAGE_NX) &&
81638 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
81639 + (vm_flags & (VM_READ | VM_WRITE)))
81640 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
81641 +#endif
81642 +
81643 + return prot;
81644 }
81645 EXPORT_SYMBOL(vm_get_page_prot);
81646
81647 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
81648 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
81649 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
81650 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
81651 /*
81652 * Make sure vm_committed_as in one cacheline and not cacheline shared with
81653 * other variables. It can be updated by several CPUs frequently.
81654 @@ -239,6 +260,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
81655 struct vm_area_struct *next = vma->vm_next;
81656
81657 might_sleep();
81658 + BUG_ON(vma->vm_mirror);
81659 if (vma->vm_ops && vma->vm_ops->close)
81660 vma->vm_ops->close(vma);
81661 if (vma->vm_file)
81662 @@ -283,6 +305,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
81663 * not page aligned -Ram Gupta
81664 */
81665 rlim = rlimit(RLIMIT_DATA);
81666 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
81667 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
81668 (mm->end_data - mm->start_data) > rlim)
81669 goto out;
81670 @@ -897,6 +920,12 @@ static int
81671 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
81672 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81673 {
81674 +
81675 +#ifdef CONFIG_PAX_SEGMEXEC
81676 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
81677 + return 0;
81678 +#endif
81679 +
81680 if (is_mergeable_vma(vma, file, vm_flags) &&
81681 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81682 if (vma->vm_pgoff == vm_pgoff)
81683 @@ -916,6 +945,12 @@ static int
81684 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81685 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81686 {
81687 +
81688 +#ifdef CONFIG_PAX_SEGMEXEC
81689 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
81690 + return 0;
81691 +#endif
81692 +
81693 if (is_mergeable_vma(vma, file, vm_flags) &&
81694 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81695 pgoff_t vm_pglen;
81696 @@ -958,13 +993,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81697 struct vm_area_struct *vma_merge(struct mm_struct *mm,
81698 struct vm_area_struct *prev, unsigned long addr,
81699 unsigned long end, unsigned long vm_flags,
81700 - struct anon_vma *anon_vma, struct file *file,
81701 + struct anon_vma *anon_vma, struct file *file,
81702 pgoff_t pgoff, struct mempolicy *policy)
81703 {
81704 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
81705 struct vm_area_struct *area, *next;
81706 int err;
81707
81708 +#ifdef CONFIG_PAX_SEGMEXEC
81709 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
81710 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
81711 +
81712 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
81713 +#endif
81714 +
81715 /*
81716 * We later require that vma->vm_flags == vm_flags,
81717 * so this tests vma->vm_flags & VM_SPECIAL, too.
81718 @@ -980,6 +1022,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81719 if (next && next->vm_end == end) /* cases 6, 7, 8 */
81720 next = next->vm_next;
81721
81722 +#ifdef CONFIG_PAX_SEGMEXEC
81723 + if (prev)
81724 + prev_m = pax_find_mirror_vma(prev);
81725 + if (area)
81726 + area_m = pax_find_mirror_vma(area);
81727 + if (next)
81728 + next_m = pax_find_mirror_vma(next);
81729 +#endif
81730 +
81731 /*
81732 * Can it merge with the predecessor?
81733 */
81734 @@ -999,9 +1050,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81735 /* cases 1, 6 */
81736 err = vma_adjust(prev, prev->vm_start,
81737 next->vm_end, prev->vm_pgoff, NULL);
81738 - } else /* cases 2, 5, 7 */
81739 +
81740 +#ifdef CONFIG_PAX_SEGMEXEC
81741 + if (!err && prev_m)
81742 + err = vma_adjust(prev_m, prev_m->vm_start,
81743 + next_m->vm_end, prev_m->vm_pgoff, NULL);
81744 +#endif
81745 +
81746 + } else { /* cases 2, 5, 7 */
81747 err = vma_adjust(prev, prev->vm_start,
81748 end, prev->vm_pgoff, NULL);
81749 +
81750 +#ifdef CONFIG_PAX_SEGMEXEC
81751 + if (!err && prev_m)
81752 + err = vma_adjust(prev_m, prev_m->vm_start,
81753 + end_m, prev_m->vm_pgoff, NULL);
81754 +#endif
81755 +
81756 + }
81757 if (err)
81758 return NULL;
81759 khugepaged_enter_vma_merge(prev);
81760 @@ -1015,12 +1081,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81761 mpol_equal(policy, vma_policy(next)) &&
81762 can_vma_merge_before(next, vm_flags,
81763 anon_vma, file, pgoff+pglen)) {
81764 - if (prev && addr < prev->vm_end) /* case 4 */
81765 + if (prev && addr < prev->vm_end) { /* case 4 */
81766 err = vma_adjust(prev, prev->vm_start,
81767 addr, prev->vm_pgoff, NULL);
81768 - else /* cases 3, 8 */
81769 +
81770 +#ifdef CONFIG_PAX_SEGMEXEC
81771 + if (!err && prev_m)
81772 + err = vma_adjust(prev_m, prev_m->vm_start,
81773 + addr_m, prev_m->vm_pgoff, NULL);
81774 +#endif
81775 +
81776 + } else { /* cases 3, 8 */
81777 err = vma_adjust(area, addr, next->vm_end,
81778 next->vm_pgoff - pglen, NULL);
81779 +
81780 +#ifdef CONFIG_PAX_SEGMEXEC
81781 + if (!err && area_m)
81782 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
81783 + next_m->vm_pgoff - pglen, NULL);
81784 +#endif
81785 +
81786 + }
81787 if (err)
81788 return NULL;
81789 khugepaged_enter_vma_merge(area);
81790 @@ -1129,8 +1210,10 @@ none:
81791 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81792 struct file *file, long pages)
81793 {
81794 - const unsigned long stack_flags
81795 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
81796 +
81797 +#ifdef CONFIG_PAX_RANDMMAP
81798 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81799 +#endif
81800
81801 mm->total_vm += pages;
81802
81803 @@ -1138,7 +1221,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81804 mm->shared_vm += pages;
81805 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
81806 mm->exec_vm += pages;
81807 - } else if (flags & stack_flags)
81808 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
81809 mm->stack_vm += pages;
81810 }
81811 #endif /* CONFIG_PROC_FS */
81812 @@ -1177,7 +1260,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81813 * (the exception is when the underlying filesystem is noexec
81814 * mounted, in which case we dont add PROT_EXEC.)
81815 */
81816 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
81817 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
81818 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
81819 prot |= PROT_EXEC;
81820
81821 @@ -1203,7 +1286,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81822 /* Obtain the address to map to. we verify (or select) it and ensure
81823 * that it represents a valid section of the address space.
81824 */
81825 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
81826 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
81827 if (addr & ~PAGE_MASK)
81828 return addr;
81829
81830 @@ -1214,6 +1297,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81831 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
81832 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
81833
81834 +#ifdef CONFIG_PAX_MPROTECT
81835 + if (mm->pax_flags & MF_PAX_MPROTECT) {
81836 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
81837 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
81838 + gr_log_rwxmmap(file);
81839 +
81840 +#ifdef CONFIG_PAX_EMUPLT
81841 + vm_flags &= ~VM_EXEC;
81842 +#else
81843 + return -EPERM;
81844 +#endif
81845 +
81846 + }
81847 +
81848 + if (!(vm_flags & VM_EXEC))
81849 + vm_flags &= ~VM_MAYEXEC;
81850 +#else
81851 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
81852 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
81853 +#endif
81854 + else
81855 + vm_flags &= ~VM_MAYWRITE;
81856 + }
81857 +#endif
81858 +
81859 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81860 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
81861 + vm_flags &= ~VM_PAGEEXEC;
81862 +#endif
81863 +
81864 if (flags & MAP_LOCKED)
81865 if (!can_do_mlock())
81866 return -EPERM;
81867 @@ -1225,6 +1338,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81868 locked += mm->locked_vm;
81869 lock_limit = rlimit(RLIMIT_MEMLOCK);
81870 lock_limit >>= PAGE_SHIFT;
81871 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81872 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
81873 return -EAGAIN;
81874 }
81875 @@ -1305,6 +1419,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81876 vm_flags |= VM_NORESERVE;
81877 }
81878
81879 + if (!gr_acl_handle_mmap(file, prot))
81880 + return -EACCES;
81881 +
81882 addr = mmap_region(file, addr, len, vm_flags, pgoff);
81883 if (!IS_ERR_VALUE(addr) &&
81884 ((vm_flags & VM_LOCKED) ||
81885 @@ -1396,7 +1513,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
81886 vm_flags_t vm_flags = vma->vm_flags;
81887
81888 /* If it was private or non-writable, the write bit is already clear */
81889 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
81890 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
81891 return 0;
81892
81893 /* The backer wishes to know when pages are first written to? */
81894 @@ -1444,16 +1561,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
81895 unsigned long charged = 0;
81896 struct inode *inode = file ? file_inode(file) : NULL;
81897
81898 +#ifdef CONFIG_PAX_SEGMEXEC
81899 + struct vm_area_struct *vma_m = NULL;
81900 +#endif
81901 +
81902 + /*
81903 + * mm->mmap_sem is required to protect against another thread
81904 + * changing the mappings in case we sleep.
81905 + */
81906 + verify_mm_writelocked(mm);
81907 +
81908 /* Clear old maps */
81909 error = -ENOMEM;
81910 -munmap_back:
81911 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
81912 if (do_munmap(mm, addr, len))
81913 return -ENOMEM;
81914 - goto munmap_back;
81915 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
81916 }
81917
81918 /* Check against address space limit. */
81919 +
81920 +#ifdef CONFIG_PAX_RANDMMAP
81921 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81922 +#endif
81923 +
81924 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
81925 return -ENOMEM;
81926
81927 @@ -1485,6 +1616,16 @@ munmap_back:
81928 goto unacct_error;
81929 }
81930
81931 +#ifdef CONFIG_PAX_SEGMEXEC
81932 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
81933 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
81934 + if (!vma_m) {
81935 + error = -ENOMEM;
81936 + goto free_vma;
81937 + }
81938 + }
81939 +#endif
81940 +
81941 vma->vm_mm = mm;
81942 vma->vm_start = addr;
81943 vma->vm_end = addr + len;
81944 @@ -1509,6 +1650,13 @@ munmap_back:
81945 if (error)
81946 goto unmap_and_free_vma;
81947
81948 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81949 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
81950 + vma->vm_flags |= VM_PAGEEXEC;
81951 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
81952 + }
81953 +#endif
81954 +
81955 /* Can addr have changed??
81956 *
81957 * Answer: Yes, several device drivers can do it in their
81958 @@ -1547,6 +1695,11 @@ munmap_back:
81959 vma_link(mm, vma, prev, rb_link, rb_parent);
81960 file = vma->vm_file;
81961
81962 +#ifdef CONFIG_PAX_SEGMEXEC
81963 + if (vma_m)
81964 + BUG_ON(pax_mirror_vma(vma_m, vma));
81965 +#endif
81966 +
81967 /* Once vma denies write, undo our temporary denial count */
81968 if (correct_wcount)
81969 atomic_inc(&inode->i_writecount);
81970 @@ -1554,6 +1707,7 @@ out:
81971 perf_event_mmap(vma);
81972
81973 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
81974 + track_exec_limit(mm, addr, addr + len, vm_flags);
81975 if (vm_flags & VM_LOCKED) {
81976 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
81977 vma == get_gate_vma(current->mm)))
81978 @@ -1577,6 +1731,12 @@ unmap_and_free_vma:
81979 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
81980 charged = 0;
81981 free_vma:
81982 +
81983 +#ifdef CONFIG_PAX_SEGMEXEC
81984 + if (vma_m)
81985 + kmem_cache_free(vm_area_cachep, vma_m);
81986 +#endif
81987 +
81988 kmem_cache_free(vm_area_cachep, vma);
81989 unacct_error:
81990 if (charged)
81991 @@ -1584,6 +1744,62 @@ unacct_error:
81992 return error;
81993 }
81994
81995 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
81996 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
81997 +{
81998 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
81999 + return (random32() & 0xFF) << PAGE_SHIFT;
82000 +
82001 + return 0;
82002 +}
82003 +#endif
82004 +
82005 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82006 +{
82007 + if (!vma) {
82008 +#ifdef CONFIG_STACK_GROWSUP
82009 + if (addr > sysctl_heap_stack_gap)
82010 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82011 + else
82012 + vma = find_vma(current->mm, 0);
82013 + if (vma && (vma->vm_flags & VM_GROWSUP))
82014 + return false;
82015 +#endif
82016 + return true;
82017 + }
82018 +
82019 + if (addr + len > vma->vm_start)
82020 + return false;
82021 +
82022 + if (vma->vm_flags & VM_GROWSDOWN)
82023 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82024 +#ifdef CONFIG_STACK_GROWSUP
82025 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82026 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82027 +#endif
82028 + else if (offset)
82029 + return offset <= vma->vm_start - addr - len;
82030 +
82031 + return true;
82032 +}
82033 +
82034 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82035 +{
82036 + if (vma->vm_start < len)
82037 + return -ENOMEM;
82038 +
82039 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82040 + if (offset <= vma->vm_start - len)
82041 + return vma->vm_start - len - offset;
82042 + else
82043 + return -ENOMEM;
82044 + }
82045 +
82046 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82047 + return vma->vm_start - len - sysctl_heap_stack_gap;
82048 + return -ENOMEM;
82049 +}
82050 +
82051 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82052 {
82053 /*
82054 @@ -1803,6 +2019,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82055 struct mm_struct *mm = current->mm;
82056 struct vm_area_struct *vma;
82057 struct vm_unmapped_area_info info;
82058 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82059
82060 if (len > TASK_SIZE)
82061 return -ENOMEM;
82062 @@ -1810,29 +2027,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82063 if (flags & MAP_FIXED)
82064 return addr;
82065
82066 +#ifdef CONFIG_PAX_RANDMMAP
82067 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82068 +#endif
82069 +
82070 if (addr) {
82071 addr = PAGE_ALIGN(addr);
82072 vma = find_vma(mm, addr);
82073 - if (TASK_SIZE - len >= addr &&
82074 - (!vma || addr + len <= vma->vm_start))
82075 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82076 return addr;
82077 }
82078
82079 info.flags = 0;
82080 info.length = len;
82081 info.low_limit = TASK_UNMAPPED_BASE;
82082 +
82083 +#ifdef CONFIG_PAX_RANDMMAP
82084 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82085 + info.low_limit += mm->delta_mmap;
82086 +#endif
82087 +
82088 info.high_limit = TASK_SIZE;
82089 info.align_mask = 0;
82090 + info.threadstack_offset = offset;
82091 return vm_unmapped_area(&info);
82092 }
82093 #endif
82094
82095 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82096 {
82097 +
82098 +#ifdef CONFIG_PAX_SEGMEXEC
82099 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82100 + return;
82101 +#endif
82102 +
82103 /*
82104 * Is this a new hole at the lowest possible address?
82105 */
82106 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82107 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82108 mm->free_area_cache = addr;
82109 }
82110
82111 @@ -1850,6 +2083,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82112 struct mm_struct *mm = current->mm;
82113 unsigned long addr = addr0;
82114 struct vm_unmapped_area_info info;
82115 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82116
82117 /* requested length too big for entire address space */
82118 if (len > TASK_SIZE)
82119 @@ -1858,12 +2092,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
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 /* requesting a specific address */
82128 if (addr) {
82129 addr = PAGE_ALIGN(addr);
82130 vma = find_vma(mm, addr);
82131 - if (TASK_SIZE - len >= addr &&
82132 - (!vma || addr + len <= vma->vm_start))
82133 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82134 return addr;
82135 }
82136
82137 @@ -1872,6 +2109,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82138 info.low_limit = PAGE_SIZE;
82139 info.high_limit = mm->mmap_base;
82140 info.align_mask = 0;
82141 + info.threadstack_offset = offset;
82142 addr = vm_unmapped_area(&info);
82143
82144 /*
82145 @@ -1884,6 +2122,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82146 VM_BUG_ON(addr != -ENOMEM);
82147 info.flags = 0;
82148 info.low_limit = TASK_UNMAPPED_BASE;
82149 +
82150 +#ifdef CONFIG_PAX_RANDMMAP
82151 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82152 + info.low_limit += mm->delta_mmap;
82153 +#endif
82154 +
82155 info.high_limit = TASK_SIZE;
82156 addr = vm_unmapped_area(&info);
82157 }
82158 @@ -1894,6 +2138,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82159
82160 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82161 {
82162 +
82163 +#ifdef CONFIG_PAX_SEGMEXEC
82164 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82165 + return;
82166 +#endif
82167 +
82168 /*
82169 * Is this a new hole at the highest possible address?
82170 */
82171 @@ -1901,8 +2151,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82172 mm->free_area_cache = addr;
82173
82174 /* dont allow allocations above current base */
82175 - if (mm->free_area_cache > mm->mmap_base)
82176 + if (mm->free_area_cache > mm->mmap_base) {
82177 mm->free_area_cache = mm->mmap_base;
82178 + mm->cached_hole_size = ~0UL;
82179 + }
82180 }
82181
82182 unsigned long
82183 @@ -2001,6 +2253,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82184 return vma;
82185 }
82186
82187 +#ifdef CONFIG_PAX_SEGMEXEC
82188 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82189 +{
82190 + struct vm_area_struct *vma_m;
82191 +
82192 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82193 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82194 + BUG_ON(vma->vm_mirror);
82195 + return NULL;
82196 + }
82197 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82198 + vma_m = vma->vm_mirror;
82199 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82200 + BUG_ON(vma->vm_file != vma_m->vm_file);
82201 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82202 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82203 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82204 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82205 + return vma_m;
82206 +}
82207 +#endif
82208 +
82209 /*
82210 * Verify that the stack growth is acceptable and
82211 * update accounting. This is shared with both the
82212 @@ -2017,6 +2291,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82213 return -ENOMEM;
82214
82215 /* Stack limit test */
82216 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82217 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82218 return -ENOMEM;
82219
82220 @@ -2027,6 +2302,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82221 locked = mm->locked_vm + grow;
82222 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82223 limit >>= PAGE_SHIFT;
82224 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82225 if (locked > limit && !capable(CAP_IPC_LOCK))
82226 return -ENOMEM;
82227 }
82228 @@ -2056,37 +2332,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82229 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82230 * vma is the last one with address > vma->vm_end. Have to extend vma.
82231 */
82232 +#ifndef CONFIG_IA64
82233 +static
82234 +#endif
82235 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82236 {
82237 int error;
82238 + bool locknext;
82239
82240 if (!(vma->vm_flags & VM_GROWSUP))
82241 return -EFAULT;
82242
82243 + /* Also guard against wrapping around to address 0. */
82244 + if (address < PAGE_ALIGN(address+1))
82245 + address = PAGE_ALIGN(address+1);
82246 + else
82247 + return -ENOMEM;
82248 +
82249 /*
82250 * We must make sure the anon_vma is allocated
82251 * so that the anon_vma locking is not a noop.
82252 */
82253 if (unlikely(anon_vma_prepare(vma)))
82254 return -ENOMEM;
82255 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82256 + if (locknext && anon_vma_prepare(vma->vm_next))
82257 + return -ENOMEM;
82258 vma_lock_anon_vma(vma);
82259 + if (locknext)
82260 + vma_lock_anon_vma(vma->vm_next);
82261
82262 /*
82263 * vma->vm_start/vm_end cannot change under us because the caller
82264 * is required to hold the mmap_sem in read mode. We need the
82265 - * anon_vma lock to serialize against concurrent expand_stacks.
82266 - * Also guard against wrapping around to address 0.
82267 + * anon_vma locks to serialize against concurrent expand_stacks
82268 + * and expand_upwards.
82269 */
82270 - if (address < PAGE_ALIGN(address+4))
82271 - address = PAGE_ALIGN(address+4);
82272 - else {
82273 - vma_unlock_anon_vma(vma);
82274 - return -ENOMEM;
82275 - }
82276 error = 0;
82277
82278 /* Somebody else might have raced and expanded it already */
82279 - if (address > vma->vm_end) {
82280 + 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)
82281 + error = -ENOMEM;
82282 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82283 unsigned long size, grow;
82284
82285 size = address - vma->vm_start;
82286 @@ -2121,6 +2408,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82287 }
82288 }
82289 }
82290 + if (locknext)
82291 + vma_unlock_anon_vma(vma->vm_next);
82292 vma_unlock_anon_vma(vma);
82293 khugepaged_enter_vma_merge(vma);
82294 validate_mm(vma->vm_mm);
82295 @@ -2135,6 +2424,8 @@ int expand_downwards(struct vm_area_struct *vma,
82296 unsigned long address)
82297 {
82298 int error;
82299 + bool lockprev = false;
82300 + struct vm_area_struct *prev;
82301
82302 /*
82303 * We must make sure the anon_vma is allocated
82304 @@ -2148,6 +2439,15 @@ int expand_downwards(struct vm_area_struct *vma,
82305 if (error)
82306 return error;
82307
82308 + prev = vma->vm_prev;
82309 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82310 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82311 +#endif
82312 + if (lockprev && anon_vma_prepare(prev))
82313 + return -ENOMEM;
82314 + if (lockprev)
82315 + vma_lock_anon_vma(prev);
82316 +
82317 vma_lock_anon_vma(vma);
82318
82319 /*
82320 @@ -2157,9 +2457,17 @@ int expand_downwards(struct vm_area_struct *vma,
82321 */
82322
82323 /* Somebody else might have raced and expanded it already */
82324 - if (address < vma->vm_start) {
82325 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82326 + error = -ENOMEM;
82327 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82328 unsigned long size, grow;
82329
82330 +#ifdef CONFIG_PAX_SEGMEXEC
82331 + struct vm_area_struct *vma_m;
82332 +
82333 + vma_m = pax_find_mirror_vma(vma);
82334 +#endif
82335 +
82336 size = vma->vm_end - address;
82337 grow = (vma->vm_start - address) >> PAGE_SHIFT;
82338
82339 @@ -2184,6 +2492,18 @@ int expand_downwards(struct vm_area_struct *vma,
82340 vma->vm_pgoff -= grow;
82341 anon_vma_interval_tree_post_update_vma(vma);
82342 vma_gap_update(vma);
82343 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
82344 +
82345 +#ifdef CONFIG_PAX_SEGMEXEC
82346 + if (vma_m) {
82347 + anon_vma_interval_tree_pre_update_vma(vma_m);
82348 + vma_m->vm_start -= grow << PAGE_SHIFT;
82349 + vma_m->vm_pgoff -= grow;
82350 + anon_vma_interval_tree_post_update_vma(vma_m);
82351 + vma_gap_update(vma_m);
82352 + }
82353 +#endif
82354 +
82355 spin_unlock(&vma->vm_mm->page_table_lock);
82356
82357 perf_event_mmap(vma);
82358 @@ -2288,6 +2608,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
82359 do {
82360 long nrpages = vma_pages(vma);
82361
82362 +#ifdef CONFIG_PAX_SEGMEXEC
82363 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
82364 + vma = remove_vma(vma);
82365 + continue;
82366 + }
82367 +#endif
82368 +
82369 if (vma->vm_flags & VM_ACCOUNT)
82370 nr_accounted += nrpages;
82371 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
82372 @@ -2333,6 +2660,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
82373 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
82374 vma->vm_prev = NULL;
82375 do {
82376 +
82377 +#ifdef CONFIG_PAX_SEGMEXEC
82378 + if (vma->vm_mirror) {
82379 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
82380 + vma->vm_mirror->vm_mirror = NULL;
82381 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
82382 + vma->vm_mirror = NULL;
82383 + }
82384 +#endif
82385 +
82386 vma_rb_erase(vma, &mm->mm_rb);
82387 mm->map_count--;
82388 tail_vma = vma;
82389 @@ -2364,14 +2701,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82390 struct vm_area_struct *new;
82391 int err = -ENOMEM;
82392
82393 +#ifdef CONFIG_PAX_SEGMEXEC
82394 + struct vm_area_struct *vma_m, *new_m = NULL;
82395 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
82396 +#endif
82397 +
82398 if (is_vm_hugetlb_page(vma) && (addr &
82399 ~(huge_page_mask(hstate_vma(vma)))))
82400 return -EINVAL;
82401
82402 +#ifdef CONFIG_PAX_SEGMEXEC
82403 + vma_m = pax_find_mirror_vma(vma);
82404 +#endif
82405 +
82406 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82407 if (!new)
82408 goto out_err;
82409
82410 +#ifdef CONFIG_PAX_SEGMEXEC
82411 + if (vma_m) {
82412 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82413 + if (!new_m) {
82414 + kmem_cache_free(vm_area_cachep, new);
82415 + goto out_err;
82416 + }
82417 + }
82418 +#endif
82419 +
82420 /* most fields are the same, copy all, and then fixup */
82421 *new = *vma;
82422
82423 @@ -2384,6 +2740,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82424 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
82425 }
82426
82427 +#ifdef CONFIG_PAX_SEGMEXEC
82428 + if (vma_m) {
82429 + *new_m = *vma_m;
82430 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
82431 + new_m->vm_mirror = new;
82432 + new->vm_mirror = new_m;
82433 +
82434 + if (new_below)
82435 + new_m->vm_end = addr_m;
82436 + else {
82437 + new_m->vm_start = addr_m;
82438 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
82439 + }
82440 + }
82441 +#endif
82442 +
82443 pol = mpol_dup(vma_policy(vma));
82444 if (IS_ERR(pol)) {
82445 err = PTR_ERR(pol);
82446 @@ -2406,6 +2778,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82447 else
82448 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
82449
82450 +#ifdef CONFIG_PAX_SEGMEXEC
82451 + if (!err && vma_m) {
82452 + if (anon_vma_clone(new_m, vma_m))
82453 + goto out_free_mpol;
82454 +
82455 + mpol_get(pol);
82456 + vma_set_policy(new_m, pol);
82457 +
82458 + if (new_m->vm_file)
82459 + get_file(new_m->vm_file);
82460 +
82461 + if (new_m->vm_ops && new_m->vm_ops->open)
82462 + new_m->vm_ops->open(new_m);
82463 +
82464 + if (new_below)
82465 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
82466 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
82467 + else
82468 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
82469 +
82470 + if (err) {
82471 + if (new_m->vm_ops && new_m->vm_ops->close)
82472 + new_m->vm_ops->close(new_m);
82473 + if (new_m->vm_file)
82474 + fput(new_m->vm_file);
82475 + mpol_put(pol);
82476 + }
82477 + }
82478 +#endif
82479 +
82480 /* Success. */
82481 if (!err)
82482 return 0;
82483 @@ -2415,10 +2817,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82484 new->vm_ops->close(new);
82485 if (new->vm_file)
82486 fput(new->vm_file);
82487 - unlink_anon_vmas(new);
82488 out_free_mpol:
82489 mpol_put(pol);
82490 out_free_vma:
82491 +
82492 +#ifdef CONFIG_PAX_SEGMEXEC
82493 + if (new_m) {
82494 + unlink_anon_vmas(new_m);
82495 + kmem_cache_free(vm_area_cachep, new_m);
82496 + }
82497 +#endif
82498 +
82499 + unlink_anon_vmas(new);
82500 kmem_cache_free(vm_area_cachep, new);
82501 out_err:
82502 return err;
82503 @@ -2431,6 +2841,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82504 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82505 unsigned long addr, int new_below)
82506 {
82507 +
82508 +#ifdef CONFIG_PAX_SEGMEXEC
82509 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82510 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
82511 + if (mm->map_count >= sysctl_max_map_count-1)
82512 + return -ENOMEM;
82513 + } else
82514 +#endif
82515 +
82516 if (mm->map_count >= sysctl_max_map_count)
82517 return -ENOMEM;
82518
82519 @@ -2442,11 +2861,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82520 * work. This now handles partial unmappings.
82521 * Jeremy Fitzhardinge <jeremy@goop.org>
82522 */
82523 +#ifdef CONFIG_PAX_SEGMEXEC
82524 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82525 {
82526 + int ret = __do_munmap(mm, start, len);
82527 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
82528 + return ret;
82529 +
82530 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
82531 +}
82532 +
82533 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82534 +#else
82535 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82536 +#endif
82537 +{
82538 unsigned long end;
82539 struct vm_area_struct *vma, *prev, *last;
82540
82541 + /*
82542 + * mm->mmap_sem is required to protect against another thread
82543 + * changing the mappings in case we sleep.
82544 + */
82545 + verify_mm_writelocked(mm);
82546 +
82547 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
82548 return -EINVAL;
82549
82550 @@ -2521,6 +2959,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82551 /* Fix up all other VM information */
82552 remove_vma_list(mm, vma);
82553
82554 + track_exec_limit(mm, start, end, 0UL);
82555 +
82556 return 0;
82557 }
82558
82559 @@ -2529,6 +2969,13 @@ int vm_munmap(unsigned long start, size_t len)
82560 int ret;
82561 struct mm_struct *mm = current->mm;
82562
82563 +
82564 +#ifdef CONFIG_PAX_SEGMEXEC
82565 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
82566 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
82567 + return -EINVAL;
82568 +#endif
82569 +
82570 down_write(&mm->mmap_sem);
82571 ret = do_munmap(mm, start, len);
82572 up_write(&mm->mmap_sem);
82573 @@ -2542,16 +2989,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
82574 return vm_munmap(addr, len);
82575 }
82576
82577 -static inline void verify_mm_writelocked(struct mm_struct *mm)
82578 -{
82579 -#ifdef CONFIG_DEBUG_VM
82580 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82581 - WARN_ON(1);
82582 - up_read(&mm->mmap_sem);
82583 - }
82584 -#endif
82585 -}
82586 -
82587 /*
82588 * this is really a simplified "do_mmap". it only handles
82589 * anonymous maps. eventually we may be able to do some
82590 @@ -2565,6 +3002,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82591 struct rb_node ** rb_link, * rb_parent;
82592 pgoff_t pgoff = addr >> PAGE_SHIFT;
82593 int error;
82594 + unsigned long charged;
82595
82596 len = PAGE_ALIGN(len);
82597 if (!len)
82598 @@ -2572,16 +3010,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82599
82600 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
82601
82602 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
82603 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
82604 + flags &= ~VM_EXEC;
82605 +
82606 +#ifdef CONFIG_PAX_MPROTECT
82607 + if (mm->pax_flags & MF_PAX_MPROTECT)
82608 + flags &= ~VM_MAYEXEC;
82609 +#endif
82610 +
82611 + }
82612 +#endif
82613 +
82614 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
82615 if (error & ~PAGE_MASK)
82616 return error;
82617
82618 + charged = len >> PAGE_SHIFT;
82619 +
82620 /*
82621 * mlock MCL_FUTURE?
82622 */
82623 if (mm->def_flags & VM_LOCKED) {
82624 unsigned long locked, lock_limit;
82625 - locked = len >> PAGE_SHIFT;
82626 + locked = charged;
82627 locked += mm->locked_vm;
82628 lock_limit = rlimit(RLIMIT_MEMLOCK);
82629 lock_limit >>= PAGE_SHIFT;
82630 @@ -2598,21 +3050,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82631 /*
82632 * Clear old maps. this also does some error checking for us
82633 */
82634 - munmap_back:
82635 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82636 if (do_munmap(mm, addr, len))
82637 return -ENOMEM;
82638 - goto munmap_back;
82639 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82640 }
82641
82642 /* Check against address space limits *after* clearing old maps... */
82643 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82644 + if (!may_expand_vm(mm, charged))
82645 return -ENOMEM;
82646
82647 if (mm->map_count > sysctl_max_map_count)
82648 return -ENOMEM;
82649
82650 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
82651 + if (security_vm_enough_memory_mm(mm, charged))
82652 return -ENOMEM;
82653
82654 /* Can we just expand an old private anonymous mapping? */
82655 @@ -2626,7 +3077,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82656 */
82657 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82658 if (!vma) {
82659 - vm_unacct_memory(len >> PAGE_SHIFT);
82660 + vm_unacct_memory(charged);
82661 return -ENOMEM;
82662 }
82663
82664 @@ -2640,9 +3091,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82665 vma_link(mm, vma, prev, rb_link, rb_parent);
82666 out:
82667 perf_event_mmap(vma);
82668 - mm->total_vm += len >> PAGE_SHIFT;
82669 + mm->total_vm += charged;
82670 if (flags & VM_LOCKED)
82671 - mm->locked_vm += (len >> PAGE_SHIFT);
82672 + mm->locked_vm += charged;
82673 + track_exec_limit(mm, addr, addr + len, flags);
82674 return addr;
82675 }
82676
82677 @@ -2704,6 +3156,7 @@ void exit_mmap(struct mm_struct *mm)
82678 while (vma) {
82679 if (vma->vm_flags & VM_ACCOUNT)
82680 nr_accounted += vma_pages(vma);
82681 + vma->vm_mirror = NULL;
82682 vma = remove_vma(vma);
82683 }
82684 vm_unacct_memory(nr_accounted);
82685 @@ -2720,6 +3173,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82686 struct vm_area_struct *prev;
82687 struct rb_node **rb_link, *rb_parent;
82688
82689 +#ifdef CONFIG_PAX_SEGMEXEC
82690 + struct vm_area_struct *vma_m = NULL;
82691 +#endif
82692 +
82693 + if (security_mmap_addr(vma->vm_start))
82694 + return -EPERM;
82695 +
82696 /*
82697 * The vm_pgoff of a purely anonymous vma should be irrelevant
82698 * until its first write fault, when page's anon_vma and index
82699 @@ -2743,7 +3203,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82700 security_vm_enough_memory_mm(mm, vma_pages(vma)))
82701 return -ENOMEM;
82702
82703 +#ifdef CONFIG_PAX_SEGMEXEC
82704 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
82705 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82706 + if (!vma_m)
82707 + return -ENOMEM;
82708 + }
82709 +#endif
82710 +
82711 vma_link(mm, vma, prev, rb_link, rb_parent);
82712 +
82713 +#ifdef CONFIG_PAX_SEGMEXEC
82714 + if (vma_m)
82715 + BUG_ON(pax_mirror_vma(vma_m, vma));
82716 +#endif
82717 +
82718 return 0;
82719 }
82720
82721 @@ -2763,6 +3237,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82722 struct mempolicy *pol;
82723 bool faulted_in_anon_vma = true;
82724
82725 + BUG_ON(vma->vm_mirror);
82726 +
82727 /*
82728 * If anonymous vma has not yet been faulted, update new pgoff
82729 * to match new location, to increase its chance of merging.
82730 @@ -2829,6 +3305,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82731 return NULL;
82732 }
82733
82734 +#ifdef CONFIG_PAX_SEGMEXEC
82735 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
82736 +{
82737 + struct vm_area_struct *prev_m;
82738 + struct rb_node **rb_link_m, *rb_parent_m;
82739 + struct mempolicy *pol_m;
82740 +
82741 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
82742 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
82743 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
82744 + *vma_m = *vma;
82745 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
82746 + if (anon_vma_clone(vma_m, vma))
82747 + return -ENOMEM;
82748 + pol_m = vma_policy(vma_m);
82749 + mpol_get(pol_m);
82750 + vma_set_policy(vma_m, pol_m);
82751 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
82752 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
82753 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
82754 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
82755 + if (vma_m->vm_file)
82756 + get_file(vma_m->vm_file);
82757 + if (vma_m->vm_ops && vma_m->vm_ops->open)
82758 + vma_m->vm_ops->open(vma_m);
82759 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
82760 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
82761 + vma_m->vm_mirror = vma;
82762 + vma->vm_mirror = vma_m;
82763 + return 0;
82764 +}
82765 +#endif
82766 +
82767 /*
82768 * Return true if the calling process may expand its vm space by the passed
82769 * number of pages
82770 @@ -2840,6 +3349,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
82771
82772 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
82773
82774 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
82775 if (cur + npages > lim)
82776 return 0;
82777 return 1;
82778 @@ -2910,6 +3420,22 @@ int install_special_mapping(struct mm_struct *mm,
82779 vma->vm_start = addr;
82780 vma->vm_end = addr + len;
82781
82782 +#ifdef CONFIG_PAX_MPROTECT
82783 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82784 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82785 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
82786 + return -EPERM;
82787 + if (!(vm_flags & VM_EXEC))
82788 + vm_flags &= ~VM_MAYEXEC;
82789 +#else
82790 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82791 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82792 +#endif
82793 + else
82794 + vm_flags &= ~VM_MAYWRITE;
82795 + }
82796 +#endif
82797 +
82798 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
82799 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82800
82801 diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
82802 index be04122..6725ff1 100644
82803 --- a/mm/mmu_notifier.c
82804 +++ b/mm/mmu_notifier.c
82805 @@ -40,48 +40,44 @@ void __mmu_notifier_release(struct mm_struct *mm)
82806 int id;
82807
82808 /*
82809 - * srcu_read_lock() here will block synchronize_srcu() in
82810 - * mmu_notifier_unregister() until all registered
82811 - * ->release() callouts this function makes have
82812 - * returned.
82813 + * SRCU here will block mmu_notifier_unregister until
82814 + * ->release returns.
82815 */
82816 id = srcu_read_lock(&srcu);
82817 + hlist_for_each_entry_rcu(mn, &mm->mmu_notifier_mm->list, hlist)
82818 + /*
82819 + * If ->release runs before mmu_notifier_unregister it must be
82820 + * handled, as it's the only way for the driver to flush all
82821 + * existing sptes and stop the driver from establishing any more
82822 + * sptes before all the pages in the mm are freed.
82823 + */
82824 + if (mn->ops->release)
82825 + mn->ops->release(mn, mm);
82826 + srcu_read_unlock(&srcu, id);
82827 +
82828 spin_lock(&mm->mmu_notifier_mm->lock);
82829 while (unlikely(!hlist_empty(&mm->mmu_notifier_mm->list))) {
82830 mn = hlist_entry(mm->mmu_notifier_mm->list.first,
82831 struct mmu_notifier,
82832 hlist);
82833 -
82834 /*
82835 - * Unlink. This will prevent mmu_notifier_unregister()
82836 - * from also making the ->release() callout.
82837 + * We arrived before mmu_notifier_unregister so
82838 + * mmu_notifier_unregister will do nothing other than to wait
82839 + * for ->release to finish and for mmu_notifier_unregister to
82840 + * return.
82841 */
82842 hlist_del_init_rcu(&mn->hlist);
82843 - spin_unlock(&mm->mmu_notifier_mm->lock);
82844 -
82845 - /*
82846 - * Clear sptes. (see 'release' description in mmu_notifier.h)
82847 - */
82848 - if (mn->ops->release)
82849 - mn->ops->release(mn, mm);
82850 -
82851 - spin_lock(&mm->mmu_notifier_mm->lock);
82852 }
82853 spin_unlock(&mm->mmu_notifier_mm->lock);
82854
82855 /*
82856 - * All callouts to ->release() which we have done are complete.
82857 - * Allow synchronize_srcu() in mmu_notifier_unregister() to complete
82858 - */
82859 - srcu_read_unlock(&srcu, id);
82860 -
82861 - /*
82862 - * mmu_notifier_unregister() may have unlinked a notifier and may
82863 - * still be calling out to it. Additionally, other notifiers
82864 - * may have been active via vmtruncate() et. al. Block here
82865 - * to ensure that all notifier callouts for this mm have been
82866 - * completed and the sptes are really cleaned up before returning
82867 - * to exit_mmap().
82868 + * synchronize_srcu here prevents mmu_notifier_release from returning to
82869 + * exit_mmap (which would proceed with freeing all pages in the mm)
82870 + * until the ->release method returns, if it was invoked by
82871 + * mmu_notifier_unregister.
82872 + *
82873 + * The mmu_notifier_mm can't go away from under us because one mm_count
82874 + * is held by exit_mmap.
82875 */
82876 synchronize_srcu(&srcu);
82877 }
82878 @@ -292,31 +288,34 @@ void mmu_notifier_unregister(struct mmu_notifier *mn, struct mm_struct *mm)
82879 {
82880 BUG_ON(atomic_read(&mm->mm_count) <= 0);
82881
82882 - spin_lock(&mm->mmu_notifier_mm->lock);
82883 if (!hlist_unhashed(&mn->hlist)) {
82884 + /*
82885 + * SRCU here will force exit_mmap to wait for ->release to
82886 + * finish before freeing the pages.
82887 + */
82888 int id;
82889
82890 - /*
82891 - * Ensure we synchronize up with __mmu_notifier_release().
82892 - */
82893 id = srcu_read_lock(&srcu);
82894 -
82895 - hlist_del_rcu(&mn->hlist);
82896 - spin_unlock(&mm->mmu_notifier_mm->lock);
82897 -
82898 - if (mn->ops->release)
82899 - mn->ops->release(mn, mm);
82900 -
82901 /*
82902 - * Allow __mmu_notifier_release() to complete.
82903 + * exit_mmap will block in mmu_notifier_release to guarantee
82904 + * that ->release is called before freeing the pages.
82905 */
82906 + if (mn->ops->release)
82907 + mn->ops->release(mn, mm);
82908 srcu_read_unlock(&srcu, id);
82909 - } else
82910 +
82911 + spin_lock(&mm->mmu_notifier_mm->lock);
82912 + /*
82913 + * Can not use list_del_rcu() since __mmu_notifier_release
82914 + * can delete it before we hold the lock.
82915 + */
82916 + hlist_del_init_rcu(&mn->hlist);
82917 spin_unlock(&mm->mmu_notifier_mm->lock);
82918 + }
82919
82920 /*
82921 - * Wait for any running method to finish, including ->release() if it
82922 - * was run by __mmu_notifier_release() instead of us.
82923 + * Wait for any running method to finish, of course including
82924 + * ->release if it was run by mmu_notifier_relase instead of us.
82925 */
82926 synchronize_srcu(&srcu);
82927
82928 diff --git a/mm/mprotect.c b/mm/mprotect.c
82929 index 94722a4..07d9926 100644
82930 --- a/mm/mprotect.c
82931 +++ b/mm/mprotect.c
82932 @@ -23,10 +23,18 @@
82933 #include <linux/mmu_notifier.h>
82934 #include <linux/migrate.h>
82935 #include <linux/perf_event.h>
82936 +#include <linux/sched/sysctl.h>
82937 +
82938 +#ifdef CONFIG_PAX_MPROTECT
82939 +#include <linux/elf.h>
82940 +#include <linux/binfmts.h>
82941 +#endif
82942 +
82943 #include <asm/uaccess.h>
82944 #include <asm/pgtable.h>
82945 #include <asm/cacheflush.h>
82946 #include <asm/tlbflush.h>
82947 +#include <asm/mmu_context.h>
82948
82949 #ifndef pgprot_modify
82950 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
82951 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
82952 return pages;
82953 }
82954
82955 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82956 +/* called while holding the mmap semaphor for writing except stack expansion */
82957 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
82958 +{
82959 + unsigned long oldlimit, newlimit = 0UL;
82960 +
82961 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
82962 + return;
82963 +
82964 + spin_lock(&mm->page_table_lock);
82965 + oldlimit = mm->context.user_cs_limit;
82966 + if ((prot & VM_EXEC) && oldlimit < end)
82967 + /* USER_CS limit moved up */
82968 + newlimit = end;
82969 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
82970 + /* USER_CS limit moved down */
82971 + newlimit = start;
82972 +
82973 + if (newlimit) {
82974 + mm->context.user_cs_limit = newlimit;
82975 +
82976 +#ifdef CONFIG_SMP
82977 + wmb();
82978 + cpus_clear(mm->context.cpu_user_cs_mask);
82979 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
82980 +#endif
82981 +
82982 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
82983 + }
82984 + spin_unlock(&mm->page_table_lock);
82985 + if (newlimit == end) {
82986 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
82987 +
82988 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
82989 + if (is_vm_hugetlb_page(vma))
82990 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
82991 + else
82992 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
82993 + }
82994 +}
82995 +#endif
82996 +
82997 int
82998 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82999 unsigned long start, unsigned long end, unsigned long newflags)
83000 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83001 int error;
83002 int dirty_accountable = 0;
83003
83004 +#ifdef CONFIG_PAX_SEGMEXEC
83005 + struct vm_area_struct *vma_m = NULL;
83006 + unsigned long start_m, end_m;
83007 +
83008 + start_m = start + SEGMEXEC_TASK_SIZE;
83009 + end_m = end + SEGMEXEC_TASK_SIZE;
83010 +#endif
83011 +
83012 if (newflags == oldflags) {
83013 *pprev = vma;
83014 return 0;
83015 }
83016
83017 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83018 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83019 +
83020 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83021 + return -ENOMEM;
83022 +
83023 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83024 + return -ENOMEM;
83025 + }
83026 +
83027 /*
83028 * If we make a private mapping writable we increase our commit;
83029 * but (without finer accounting) cannot reduce our commit if we
83030 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83031 }
83032 }
83033
83034 +#ifdef CONFIG_PAX_SEGMEXEC
83035 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83036 + if (start != vma->vm_start) {
83037 + error = split_vma(mm, vma, start, 1);
83038 + if (error)
83039 + goto fail;
83040 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83041 + *pprev = (*pprev)->vm_next;
83042 + }
83043 +
83044 + if (end != vma->vm_end) {
83045 + error = split_vma(mm, vma, end, 0);
83046 + if (error)
83047 + goto fail;
83048 + }
83049 +
83050 + if (pax_find_mirror_vma(vma)) {
83051 + error = __do_munmap(mm, start_m, end_m - start_m);
83052 + if (error)
83053 + goto fail;
83054 + } else {
83055 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83056 + if (!vma_m) {
83057 + error = -ENOMEM;
83058 + goto fail;
83059 + }
83060 + vma->vm_flags = newflags;
83061 + error = pax_mirror_vma(vma_m, vma);
83062 + if (error) {
83063 + vma->vm_flags = oldflags;
83064 + goto fail;
83065 + }
83066 + }
83067 + }
83068 +#endif
83069 +
83070 /*
83071 * First try to merge with previous and/or next vma.
83072 */
83073 @@ -296,9 +400,21 @@ success:
83074 * vm_flags and vm_page_prot are protected by the mmap_sem
83075 * held in write mode.
83076 */
83077 +
83078 +#ifdef CONFIG_PAX_SEGMEXEC
83079 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83080 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83081 +#endif
83082 +
83083 vma->vm_flags = newflags;
83084 +
83085 +#ifdef CONFIG_PAX_MPROTECT
83086 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83087 + mm->binfmt->handle_mprotect(vma, newflags);
83088 +#endif
83089 +
83090 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83091 - vm_get_page_prot(newflags));
83092 + vm_get_page_prot(vma->vm_flags));
83093
83094 if (vma_wants_writenotify(vma)) {
83095 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83096 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83097 end = start + len;
83098 if (end <= start)
83099 return -ENOMEM;
83100 +
83101 +#ifdef CONFIG_PAX_SEGMEXEC
83102 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83103 + if (end > SEGMEXEC_TASK_SIZE)
83104 + return -EINVAL;
83105 + } else
83106 +#endif
83107 +
83108 + if (end > TASK_SIZE)
83109 + return -EINVAL;
83110 +
83111 if (!arch_validate_prot(prot))
83112 return -EINVAL;
83113
83114 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83115 /*
83116 * Does the application expect PROT_READ to imply PROT_EXEC:
83117 */
83118 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83119 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83120 prot |= PROT_EXEC;
83121
83122 vm_flags = calc_vm_prot_bits(prot);
83123 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83124 if (start > vma->vm_start)
83125 prev = vma;
83126
83127 +#ifdef CONFIG_PAX_MPROTECT
83128 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83129 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83130 +#endif
83131 +
83132 for (nstart = start ; ; ) {
83133 unsigned long newflags;
83134
83135 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83136
83137 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83138 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83139 + if (prot & (PROT_WRITE | PROT_EXEC))
83140 + gr_log_rwxmprotect(vma->vm_file);
83141 +
83142 + error = -EACCES;
83143 + goto out;
83144 + }
83145 +
83146 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83147 error = -EACCES;
83148 goto out;
83149 }
83150 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83151 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83152 if (error)
83153 goto out;
83154 +
83155 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83156 +
83157 nstart = tmp;
83158
83159 if (nstart < prev->vm_end)
83160 diff --git a/mm/mremap.c b/mm/mremap.c
83161 index 463a257..c0c7a92 100644
83162 --- a/mm/mremap.c
83163 +++ b/mm/mremap.c
83164 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83165 continue;
83166 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83167 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83168 +
83169 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83170 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83171 + pte = pte_exprotect(pte);
83172 +#endif
83173 +
83174 set_pte_at(mm, new_addr, new_pte, pte);
83175 }
83176
83177 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83178 if (is_vm_hugetlb_page(vma))
83179 goto Einval;
83180
83181 +#ifdef CONFIG_PAX_SEGMEXEC
83182 + if (pax_find_mirror_vma(vma))
83183 + goto Einval;
83184 +#endif
83185 +
83186 /* We can't remap across vm area boundaries */
83187 if (old_len > vma->vm_end - addr)
83188 goto Efault;
83189 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
83190 unsigned long ret = -EINVAL;
83191 unsigned long charged = 0;
83192 unsigned long map_flags;
83193 + unsigned long pax_task_size = TASK_SIZE;
83194
83195 if (new_addr & ~PAGE_MASK)
83196 goto out;
83197
83198 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83199 +#ifdef CONFIG_PAX_SEGMEXEC
83200 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83201 + pax_task_size = SEGMEXEC_TASK_SIZE;
83202 +#endif
83203 +
83204 + pax_task_size -= PAGE_SIZE;
83205 +
83206 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83207 goto out;
83208
83209 /* Check if the location we're moving into overlaps the
83210 * old location at all, and fail if it does.
83211 */
83212 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83213 - goto out;
83214 -
83215 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83216 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83217 goto out;
83218
83219 ret = do_munmap(mm, new_addr, new_len);
83220 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83221 unsigned long ret = -EINVAL;
83222 unsigned long charged = 0;
83223 bool locked = false;
83224 + unsigned long pax_task_size = TASK_SIZE;
83225
83226 down_write(&current->mm->mmap_sem);
83227
83228 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83229 if (!new_len)
83230 goto out;
83231
83232 +#ifdef CONFIG_PAX_SEGMEXEC
83233 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83234 + pax_task_size = SEGMEXEC_TASK_SIZE;
83235 +#endif
83236 +
83237 + pax_task_size -= PAGE_SIZE;
83238 +
83239 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83240 + old_len > pax_task_size || addr > pax_task_size-old_len)
83241 + goto out;
83242 +
83243 if (flags & MREMAP_FIXED) {
83244 if (flags & MREMAP_MAYMOVE)
83245 ret = mremap_to(addr, old_len, new_addr, new_len,
83246 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83247 new_addr = addr;
83248 }
83249 ret = addr;
83250 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83251 goto out;
83252 }
83253 }
83254 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83255 goto out;
83256 }
83257
83258 + map_flags = vma->vm_flags;
83259 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
83260 + if (!(ret & ~PAGE_MASK)) {
83261 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83262 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83263 + }
83264 }
83265 out:
83266 if (ret & ~PAGE_MASK)
83267 diff --git a/mm/nommu.c b/mm/nommu.c
83268 index e001768..9b52b30 100644
83269 --- a/mm/nommu.c
83270 +++ b/mm/nommu.c
83271 @@ -63,7 +63,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83272 int sysctl_overcommit_ratio = 50; /* default is 50% */
83273 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83274 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83275 -int heap_stack_gap = 0;
83276
83277 atomic_long_t mmap_pages_allocated;
83278
83279 @@ -841,15 +840,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83280 EXPORT_SYMBOL(find_vma);
83281
83282 /*
83283 - * find a VMA
83284 - * - we don't extend stack VMAs under NOMMU conditions
83285 - */
83286 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83287 -{
83288 - return find_vma(mm, addr);
83289 -}
83290 -
83291 -/*
83292 * expand a stack to a given address
83293 * - not supported under NOMMU conditions
83294 */
83295 @@ -1560,6 +1550,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83296
83297 /* most fields are the same, copy all, and then fixup */
83298 *new = *vma;
83299 + INIT_LIST_HEAD(&new->anon_vma_chain);
83300 *region = *vma->vm_region;
83301 new->vm_region = region;
83302
83303 @@ -1992,8 +1983,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83304 }
83305 EXPORT_SYMBOL(generic_file_remap_pages);
83306
83307 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83308 - unsigned long addr, void *buf, int len, int write)
83309 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83310 + unsigned long addr, void *buf, size_t len, int write)
83311 {
83312 struct vm_area_struct *vma;
83313
83314 @@ -2034,8 +2025,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83315 *
83316 * The caller must hold a reference on @mm.
83317 */
83318 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83319 - void *buf, int len, int write)
83320 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83321 + void *buf, size_t len, int write)
83322 {
83323 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83324 }
83325 @@ -2044,7 +2035,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83326 * Access another process' address space.
83327 * - source/target buffer must be kernel space
83328 */
83329 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83330 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83331 {
83332 struct mm_struct *mm;
83333
83334 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83335 index efe6814..64b4701 100644
83336 --- a/mm/page-writeback.c
83337 +++ b/mm/page-writeback.c
83338 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83339 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83340 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83341 */
83342 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83343 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83344 unsigned long thresh,
83345 unsigned long bg_thresh,
83346 unsigned long dirty,
83347 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83348 }
83349 }
83350
83351 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83352 +static struct notifier_block ratelimit_nb = {
83353 .notifier_call = ratelimit_handler,
83354 .next = NULL,
83355 };
83356 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83357 index 8fcced7..ebcd481 100644
83358 --- a/mm/page_alloc.c
83359 +++ b/mm/page_alloc.c
83360 @@ -59,6 +59,7 @@
83361 #include <linux/migrate.h>
83362 #include <linux/page-debug-flags.h>
83363 #include <linux/sched/rt.h>
83364 +#include <linux/random.h>
83365
83366 #include <asm/tlbflush.h>
83367 #include <asm/div64.h>
83368 @@ -344,7 +345,7 @@ out:
83369 * This usage means that zero-order pages may not be compound.
83370 */
83371
83372 -static void free_compound_page(struct page *page)
83373 +void free_compound_page(struct page *page)
83374 {
83375 __free_pages_ok(page, compound_order(page));
83376 }
83377 @@ -701,6 +702,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83378 int i;
83379 int bad = 0;
83380
83381 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83382 + unsigned long index = 1UL << order;
83383 +#endif
83384 +
83385 trace_mm_page_free(page, order);
83386 kmemcheck_free_shadow(page, order);
83387
83388 @@ -716,6 +721,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83389 debug_check_no_obj_freed(page_address(page),
83390 PAGE_SIZE << order);
83391 }
83392 +
83393 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83394 + for (; index; --index)
83395 + sanitize_highpage(page + index - 1);
83396 +#endif
83397 +
83398 arch_free_page(page, order);
83399 kernel_map_pages(page, 1 << order, 0);
83400
83401 @@ -738,6 +749,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83402 local_irq_restore(flags);
83403 }
83404
83405 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83406 +bool __meminitdata extra_latent_entropy;
83407 +
83408 +static int __init setup_pax_extra_latent_entropy(char *str)
83409 +{
83410 + extra_latent_entropy = true;
83411 + return 0;
83412 +}
83413 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83414 +
83415 +volatile u64 latent_entropy;
83416 +#endif
83417 +
83418 /*
83419 * Read access to zone->managed_pages is safe because it's unsigned long,
83420 * but we still need to serialize writers. Currently all callers of
83421 @@ -760,6 +784,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83422 set_page_count(p, 0);
83423 }
83424
83425 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83426 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83427 + u64 hash = 0;
83428 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83429 + const u64 *data = lowmem_page_address(page);
83430 +
83431 + for (index = 0; index < end; index++)
83432 + hash ^= hash + data[index];
83433 + latent_entropy ^= hash;
83434 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83435 + }
83436 +#endif
83437 +
83438 page_zone(page)->managed_pages += 1 << order;
83439 set_page_refcounted(page);
83440 __free_pages(page, order);
83441 @@ -869,8 +906,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
83442 arch_alloc_page(page, order);
83443 kernel_map_pages(page, 1 << order, 1);
83444
83445 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
83446 if (gfp_flags & __GFP_ZERO)
83447 prep_zero_page(page, order, gfp_flags);
83448 +#endif
83449
83450 if (order && (gfp_flags & __GFP_COMP))
83451 prep_compound_page(page, order);
83452 diff --git a/mm/page_io.c b/mm/page_io.c
83453 index 6182870..4bba6a2 100644
83454 --- a/mm/page_io.c
83455 +++ b/mm/page_io.c
83456 @@ -205,7 +205,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
83457 struct file *swap_file = sis->swap_file;
83458 struct address_space *mapping = swap_file->f_mapping;
83459 struct iovec iov = {
83460 - .iov_base = kmap(page),
83461 + .iov_base = (void __force_user *)kmap(page),
83462 .iov_len = PAGE_SIZE,
83463 };
83464
83465 diff --git a/mm/percpu.c b/mm/percpu.c
83466 index 8c8e08f..73a5cda 100644
83467 --- a/mm/percpu.c
83468 +++ b/mm/percpu.c
83469 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
83470 static unsigned int pcpu_high_unit_cpu __read_mostly;
83471
83472 /* the address of the first chunk which starts with the kernel static area */
83473 -void *pcpu_base_addr __read_mostly;
83474 +void *pcpu_base_addr __read_only;
83475 EXPORT_SYMBOL_GPL(pcpu_base_addr);
83476
83477 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
83478 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
83479 index fd26d04..0cea1b0 100644
83480 --- a/mm/process_vm_access.c
83481 +++ b/mm/process_vm_access.c
83482 @@ -13,6 +13,7 @@
83483 #include <linux/uio.h>
83484 #include <linux/sched.h>
83485 #include <linux/highmem.h>
83486 +#include <linux/security.h>
83487 #include <linux/ptrace.h>
83488 #include <linux/slab.h>
83489 #include <linux/syscalls.h>
83490 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83491 size_t iov_l_curr_offset = 0;
83492 ssize_t iov_len;
83493
83494 + return -ENOSYS; // PaX: until properly audited
83495 +
83496 /*
83497 * Work out how many pages of struct pages we're going to need
83498 * when eventually calling get_user_pages
83499 */
83500 for (i = 0; i < riovcnt; i++) {
83501 iov_len = rvec[i].iov_len;
83502 - if (iov_len > 0) {
83503 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
83504 - + iov_len)
83505 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
83506 - / PAGE_SIZE + 1;
83507 - nr_pages = max(nr_pages, nr_pages_iov);
83508 - }
83509 + if (iov_len <= 0)
83510 + continue;
83511 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
83512 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
83513 + nr_pages = max(nr_pages, nr_pages_iov);
83514 }
83515
83516 if (nr_pages == 0)
83517 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83518 goto free_proc_pages;
83519 }
83520
83521 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
83522 + rc = -EPERM;
83523 + goto put_task_struct;
83524 + }
83525 +
83526 mm = mm_access(task, PTRACE_MODE_ATTACH);
83527 if (!mm || IS_ERR(mm)) {
83528 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
83529 diff --git a/mm/rmap.c b/mm/rmap.c
83530 index 807c96b..0e05279 100644
83531 --- a/mm/rmap.c
83532 +++ b/mm/rmap.c
83533 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83534 struct anon_vma *anon_vma = vma->anon_vma;
83535 struct anon_vma_chain *avc;
83536
83537 +#ifdef CONFIG_PAX_SEGMEXEC
83538 + struct anon_vma_chain *avc_m = NULL;
83539 +#endif
83540 +
83541 might_sleep();
83542 if (unlikely(!anon_vma)) {
83543 struct mm_struct *mm = vma->vm_mm;
83544 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83545 if (!avc)
83546 goto out_enomem;
83547
83548 +#ifdef CONFIG_PAX_SEGMEXEC
83549 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
83550 + if (!avc_m)
83551 + goto out_enomem_free_avc;
83552 +#endif
83553 +
83554 anon_vma = find_mergeable_anon_vma(vma);
83555 allocated = NULL;
83556 if (!anon_vma) {
83557 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83558 /* page_table_lock to protect against threads */
83559 spin_lock(&mm->page_table_lock);
83560 if (likely(!vma->anon_vma)) {
83561 +
83562 +#ifdef CONFIG_PAX_SEGMEXEC
83563 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
83564 +
83565 + if (vma_m) {
83566 + BUG_ON(vma_m->anon_vma);
83567 + vma_m->anon_vma = anon_vma;
83568 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
83569 + avc_m = NULL;
83570 + }
83571 +#endif
83572 +
83573 vma->anon_vma = anon_vma;
83574 anon_vma_chain_link(vma, avc, anon_vma);
83575 allocated = NULL;
83576 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83577
83578 if (unlikely(allocated))
83579 put_anon_vma(allocated);
83580 +
83581 +#ifdef CONFIG_PAX_SEGMEXEC
83582 + if (unlikely(avc_m))
83583 + anon_vma_chain_free(avc_m);
83584 +#endif
83585 +
83586 if (unlikely(avc))
83587 anon_vma_chain_free(avc);
83588 }
83589 return 0;
83590
83591 out_enomem_free_avc:
83592 +
83593 +#ifdef CONFIG_PAX_SEGMEXEC
83594 + if (avc_m)
83595 + anon_vma_chain_free(avc_m);
83596 +#endif
83597 +
83598 anon_vma_chain_free(avc);
83599 out_enomem:
83600 return -ENOMEM;
83601 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
83602 * Attach the anon_vmas from src to dst.
83603 * Returns 0 on success, -ENOMEM on failure.
83604 */
83605 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83606 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
83607 {
83608 struct anon_vma_chain *avc, *pavc;
83609 struct anon_vma *root = NULL;
83610 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83611 * the corresponding VMA in the parent process is attached to.
83612 * Returns 0 on success, non-zero on failure.
83613 */
83614 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
83615 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
83616 {
83617 struct anon_vma_chain *avc;
83618 struct anon_vma *anon_vma;
83619 diff --git a/mm/shmem.c b/mm/shmem.c
83620 index 1c44af7..cefe9a6 100644
83621 --- a/mm/shmem.c
83622 +++ b/mm/shmem.c
83623 @@ -31,7 +31,7 @@
83624 #include <linux/export.h>
83625 #include <linux/swap.h>
83626
83627 -static struct vfsmount *shm_mnt;
83628 +struct vfsmount *shm_mnt;
83629
83630 #ifdef CONFIG_SHMEM
83631 /*
83632 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
83633 #define BOGO_DIRENT_SIZE 20
83634
83635 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
83636 -#define SHORT_SYMLINK_LEN 128
83637 +#define SHORT_SYMLINK_LEN 64
83638
83639 /*
83640 * shmem_fallocate and shmem_writepage communicate via inode->i_private
83641 @@ -2201,6 +2201,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
83642 static int shmem_xattr_validate(const char *name)
83643 {
83644 struct { const char *prefix; size_t len; } arr[] = {
83645 +
83646 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83647 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
83648 +#endif
83649 +
83650 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
83651 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
83652 };
83653 @@ -2256,6 +2261,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
83654 if (err)
83655 return err;
83656
83657 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83658 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
83659 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
83660 + return -EOPNOTSUPP;
83661 + if (size > 8)
83662 + return -EINVAL;
83663 + }
83664 +#endif
83665 +
83666 return simple_xattr_set(&info->xattrs, name, value, size, flags);
83667 }
83668
83669 @@ -2568,8 +2582,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
83670 int err = -ENOMEM;
83671
83672 /* Round up to L1_CACHE_BYTES to resist false sharing */
83673 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
83674 - L1_CACHE_BYTES), GFP_KERNEL);
83675 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
83676 if (!sbinfo)
83677 return -ENOMEM;
83678
83679 diff --git a/mm/slab.c b/mm/slab.c
83680 index 856e4a1..fafb820 100644
83681 --- a/mm/slab.c
83682 +++ b/mm/slab.c
83683 @@ -306,7 +306,7 @@ struct kmem_list3 {
83684 * Need this for bootstrapping a per node allocator.
83685 */
83686 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
83687 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
83688 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
83689 #define CACHE_CACHE 0
83690 #define SIZE_AC MAX_NUMNODES
83691 #define SIZE_L3 (2 * MAX_NUMNODES)
83692 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
83693 if ((x)->max_freeable < i) \
83694 (x)->max_freeable = i; \
83695 } while (0)
83696 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
83697 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
83698 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
83699 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
83700 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
83701 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
83702 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
83703 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
83704 #else
83705 #define STATS_INC_ACTIVE(x) do { } while (0)
83706 #define STATS_DEC_ACTIVE(x) do { } while (0)
83707 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
83708 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
83709 */
83710 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
83711 - const struct slab *slab, void *obj)
83712 + const struct slab *slab, const void *obj)
83713 {
83714 u32 offset = (obj - slab->s_mem);
83715 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
83716 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
83717 struct cache_names {
83718 char *name;
83719 char *name_dma;
83720 + char *name_usercopy;
83721 };
83722
83723 static struct cache_names __initdata cache_names[] = {
83724 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
83725 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
83726 #include <linux/kmalloc_sizes.h>
83727 - {NULL,}
83728 + {NULL}
83729 #undef CACHE
83730 };
83731
83732 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
83733 if (unlikely(gfpflags & GFP_DMA))
83734 return csizep->cs_dmacachep;
83735 #endif
83736 +
83737 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83738 + if (unlikely(gfpflags & GFP_USERCOPY))
83739 + return csizep->cs_usercopycachep;
83740 +#endif
83741 +
83742 return csizep->cs_cachep;
83743 }
83744
83745 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
83746 return notifier_from_errno(err);
83747 }
83748
83749 -static struct notifier_block __cpuinitdata cpucache_notifier = {
83750 +static struct notifier_block cpucache_notifier = {
83751 &cpuup_callback, NULL, 0
83752 };
83753
83754 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
83755 */
83756
83757 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
83758 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
83759 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83760
83761 if (INDEX_AC != INDEX_L3)
83762 sizes[INDEX_L3].cs_cachep =
83763 create_kmalloc_cache(names[INDEX_L3].name,
83764 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
83765 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83766
83767 slab_early_init = 0;
83768
83769 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
83770 */
83771 if (!sizes->cs_cachep)
83772 sizes->cs_cachep = create_kmalloc_cache(names->name,
83773 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
83774 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83775
83776 #ifdef CONFIG_ZONE_DMA
83777 sizes->cs_dmacachep = create_kmalloc_cache(
83778 names->name_dma, sizes->cs_size,
83779 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
83780 #endif
83781 +
83782 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83783 + sizes->cs_usercopycachep = create_kmalloc_cache(
83784 + names->name_usercopy, sizes->cs_size,
83785 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83786 +#endif
83787 +
83788 sizes++;
83789 names++;
83790 }
83791 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
83792
83793 if (unlikely(ZERO_OR_NULL_PTR(objp)))
83794 return;
83795 + VM_BUG_ON(!virt_addr_valid(objp));
83796 local_irq_save(flags);
83797 kfree_debugcheck(objp);
83798 c = virt_to_cache(objp);
83799 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
83800 }
83801 /* cpu stats */
83802 {
83803 - unsigned long allochit = atomic_read(&cachep->allochit);
83804 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
83805 - unsigned long freehit = atomic_read(&cachep->freehit);
83806 - unsigned long freemiss = atomic_read(&cachep->freemiss);
83807 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
83808 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
83809 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
83810 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
83811
83812 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
83813 allochit, allocmiss, freehit, freemiss);
83814 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
83815 static int __init slab_proc_init(void)
83816 {
83817 #ifdef CONFIG_DEBUG_SLAB_LEAK
83818 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
83819 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
83820 #endif
83821 return 0;
83822 }
83823 module_init(slab_proc_init);
83824 #endif
83825
83826 +bool is_usercopy_object(const void *ptr)
83827 +{
83828 + struct page *page;
83829 + struct kmem_cache *cachep;
83830 +
83831 + if (ZERO_OR_NULL_PTR(ptr))
83832 + return false;
83833 +
83834 + if (!slab_is_available())
83835 + return false;
83836 +
83837 + if (!virt_addr_valid(ptr))
83838 + return false;
83839 +
83840 + page = virt_to_head_page(ptr);
83841 +
83842 + if (!PageSlab(page))
83843 + return false;
83844 +
83845 + cachep = page->slab_cache;
83846 + return cachep->flags & SLAB_USERCOPY;
83847 +}
83848 +
83849 +#ifdef CONFIG_PAX_USERCOPY
83850 +const char *check_heap_object(const void *ptr, unsigned long n)
83851 +{
83852 + struct page *page;
83853 + struct kmem_cache *cachep;
83854 + struct slab *slabp;
83855 + unsigned int objnr;
83856 + unsigned long offset;
83857 +
83858 + if (ZERO_OR_NULL_PTR(ptr))
83859 + return "<null>";
83860 +
83861 + if (!virt_addr_valid(ptr))
83862 + return NULL;
83863 +
83864 + page = virt_to_head_page(ptr);
83865 +
83866 + if (!PageSlab(page))
83867 + return NULL;
83868 +
83869 + cachep = page->slab_cache;
83870 + if (!(cachep->flags & SLAB_USERCOPY))
83871 + return cachep->name;
83872 +
83873 + slabp = page->slab_page;
83874 + objnr = obj_to_index(cachep, slabp, ptr);
83875 + BUG_ON(objnr >= cachep->num);
83876 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
83877 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
83878 + return NULL;
83879 +
83880 + return cachep->name;
83881 +}
83882 +#endif
83883 +
83884 /**
83885 * ksize - get the actual amount of memory allocated for a given object
83886 * @objp: Pointer to the object
83887 diff --git a/mm/slab.h b/mm/slab.h
83888 index 34a98d6..73633d1 100644
83889 --- a/mm/slab.h
83890 +++ b/mm/slab.h
83891 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83892
83893 /* Legal flag mask for kmem_cache_create(), for various configurations */
83894 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
83895 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
83896 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
83897
83898 #if defined(CONFIG_DEBUG_SLAB)
83899 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
83900 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
83901 return s;
83902
83903 page = virt_to_head_page(x);
83904 +
83905 + BUG_ON(!PageSlab(page));
83906 +
83907 cachep = page->slab_cache;
83908 if (slab_equal_or_root(cachep, s))
83909 return cachep;
83910 diff --git a/mm/slab_common.c b/mm/slab_common.c
83911 index 3f3cd97..93b0236 100644
83912 --- a/mm/slab_common.c
83913 +++ b/mm/slab_common.c
83914 @@ -22,7 +22,7 @@
83915
83916 #include "slab.h"
83917
83918 -enum slab_state slab_state;
83919 +enum slab_state slab_state __read_only;
83920 LIST_HEAD(slab_caches);
83921 DEFINE_MUTEX(slab_mutex);
83922 struct kmem_cache *kmem_cache;
83923 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
83924
83925 err = __kmem_cache_create(s, flags);
83926 if (!err) {
83927 - s->refcount = 1;
83928 + atomic_set(&s->refcount, 1);
83929 list_add(&s->list, &slab_caches);
83930 memcg_cache_list_add(memcg, s);
83931 } else {
83932 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
83933
83934 get_online_cpus();
83935 mutex_lock(&slab_mutex);
83936 - s->refcount--;
83937 - if (!s->refcount) {
83938 + if (atomic_dec_and_test(&s->refcount)) {
83939 list_del(&s->list);
83940
83941 if (!__kmem_cache_shutdown(s)) {
83942 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
83943 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
83944 name, size, err);
83945
83946 - s->refcount = -1; /* Exempt from merging for now */
83947 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
83948 }
83949
83950 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83951 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83952
83953 create_boot_cache(s, name, size, flags);
83954 list_add(&s->list, &slab_caches);
83955 - s->refcount = 1;
83956 + atomic_set(&s->refcount, 1);
83957 return s;
83958 }
83959
83960 diff --git a/mm/slob.c b/mm/slob.c
83961 index eeed4a0..6ee34ec 100644
83962 --- a/mm/slob.c
83963 +++ b/mm/slob.c
83964 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
83965 /*
83966 * Return the size of a slob block.
83967 */
83968 -static slobidx_t slob_units(slob_t *s)
83969 +static slobidx_t slob_units(const slob_t *s)
83970 {
83971 if (s->units > 0)
83972 return s->units;
83973 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
83974 /*
83975 * Return the next free slob block pointer after this one.
83976 */
83977 -static slob_t *slob_next(slob_t *s)
83978 +static slob_t *slob_next(const slob_t *s)
83979 {
83980 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
83981 slobidx_t next;
83982 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
83983 /*
83984 * Returns true if s is the last free block in its page.
83985 */
83986 -static int slob_last(slob_t *s)
83987 +static int slob_last(const slob_t *s)
83988 {
83989 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
83990 }
83991
83992 -static void *slob_new_pages(gfp_t gfp, int order, int node)
83993 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
83994 {
83995 - void *page;
83996 + struct page *page;
83997
83998 #ifdef CONFIG_NUMA
83999 if (node != NUMA_NO_NODE)
84000 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84001 if (!page)
84002 return NULL;
84003
84004 - return page_address(page);
84005 + __SetPageSlab(page);
84006 + return page;
84007 }
84008
84009 -static void slob_free_pages(void *b, int order)
84010 +static void slob_free_pages(struct page *sp, int order)
84011 {
84012 if (current->reclaim_state)
84013 current->reclaim_state->reclaimed_slab += 1 << order;
84014 - free_pages((unsigned long)b, order);
84015 + __ClearPageSlab(sp);
84016 + reset_page_mapcount(sp);
84017 + sp->private = 0;
84018 + __free_pages(sp, order);
84019 }
84020
84021 /*
84022 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84023
84024 /* Not enough space: must allocate a new page */
84025 if (!b) {
84026 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84027 - if (!b)
84028 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84029 + if (!sp)
84030 return NULL;
84031 - sp = virt_to_page(b);
84032 - __SetPageSlab(sp);
84033 + b = page_address(sp);
84034
84035 spin_lock_irqsave(&slob_lock, flags);
84036 sp->units = SLOB_UNITS(PAGE_SIZE);
84037 sp->freelist = b;
84038 + sp->private = 0;
84039 INIT_LIST_HEAD(&sp->list);
84040 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84041 set_slob_page_free(sp, slob_list);
84042 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84043 if (slob_page_free(sp))
84044 clear_slob_page_free(sp);
84045 spin_unlock_irqrestore(&slob_lock, flags);
84046 - __ClearPageSlab(sp);
84047 - page_mapcount_reset(sp);
84048 - slob_free_pages(b, 0);
84049 + slob_free_pages(sp, 0);
84050 return;
84051 }
84052
84053 @@ -424,11 +426,10 @@ out:
84054 */
84055
84056 static __always_inline void *
84057 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84058 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84059 {
84060 - unsigned int *m;
84061 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84062 - void *ret;
84063 + slob_t *m;
84064 + void *ret = NULL;
84065
84066 gfp &= gfp_allowed_mask;
84067
84068 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84069
84070 if (!m)
84071 return NULL;
84072 - *m = size;
84073 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84074 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84075 + m[0].units = size;
84076 + m[1].units = align;
84077 ret = (void *)m + align;
84078
84079 trace_kmalloc_node(caller, ret,
84080 size, size + align, gfp, node);
84081 } else {
84082 unsigned int order = get_order(size);
84083 + struct page *page;
84084
84085 if (likely(order))
84086 gfp |= __GFP_COMP;
84087 - ret = slob_new_pages(gfp, order, node);
84088 + page = slob_new_pages(gfp, order, node);
84089 + if (page) {
84090 + ret = page_address(page);
84091 + page->private = size;
84092 + }
84093
84094 trace_kmalloc_node(caller, ret,
84095 size, PAGE_SIZE << order, gfp, node);
84096 }
84097
84098 - kmemleak_alloc(ret, size, 1, gfp);
84099 + return ret;
84100 +}
84101 +
84102 +static __always_inline void *
84103 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84104 +{
84105 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84106 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84107 +
84108 + if (!ZERO_OR_NULL_PTR(ret))
84109 + kmemleak_alloc(ret, size, 1, gfp);
84110 return ret;
84111 }
84112
84113 @@ -493,34 +512,112 @@ void kfree(const void *block)
84114 return;
84115 kmemleak_free(block);
84116
84117 + VM_BUG_ON(!virt_addr_valid(block));
84118 sp = virt_to_page(block);
84119 - if (PageSlab(sp)) {
84120 + VM_BUG_ON(!PageSlab(sp));
84121 + if (!sp->private) {
84122 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84123 - unsigned int *m = (unsigned int *)(block - align);
84124 - slob_free(m, *m + align);
84125 - } else
84126 + slob_t *m = (slob_t *)(block - align);
84127 + slob_free(m, m[0].units + align);
84128 + } else {
84129 + __ClearPageSlab(sp);
84130 + reset_page_mapcount(sp);
84131 + sp->private = 0;
84132 __free_pages(sp, compound_order(sp));
84133 + }
84134 }
84135 EXPORT_SYMBOL(kfree);
84136
84137 +bool is_usercopy_object(const void *ptr)
84138 +{
84139 + if (!slab_is_available())
84140 + return false;
84141 +
84142 + // PAX: TODO
84143 +
84144 + return false;
84145 +}
84146 +
84147 +#ifdef CONFIG_PAX_USERCOPY
84148 +const char *check_heap_object(const void *ptr, unsigned long n)
84149 +{
84150 + struct page *page;
84151 + const slob_t *free;
84152 + const void *base;
84153 + unsigned long flags;
84154 +
84155 + if (ZERO_OR_NULL_PTR(ptr))
84156 + return "<null>";
84157 +
84158 + if (!virt_addr_valid(ptr))
84159 + return NULL;
84160 +
84161 + page = virt_to_head_page(ptr);
84162 + if (!PageSlab(page))
84163 + return NULL;
84164 +
84165 + if (page->private) {
84166 + base = page;
84167 + if (base <= ptr && n <= page->private - (ptr - base))
84168 + return NULL;
84169 + return "<slob>";
84170 + }
84171 +
84172 + /* some tricky double walking to find the chunk */
84173 + spin_lock_irqsave(&slob_lock, flags);
84174 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84175 + free = page->freelist;
84176 +
84177 + while (!slob_last(free) && (void *)free <= ptr) {
84178 + base = free + slob_units(free);
84179 + free = slob_next(free);
84180 + }
84181 +
84182 + while (base < (void *)free) {
84183 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84184 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84185 + int offset;
84186 +
84187 + if (ptr < base + align)
84188 + break;
84189 +
84190 + offset = ptr - base - align;
84191 + if (offset >= m) {
84192 + base += size;
84193 + continue;
84194 + }
84195 +
84196 + if (n > m - offset)
84197 + break;
84198 +
84199 + spin_unlock_irqrestore(&slob_lock, flags);
84200 + return NULL;
84201 + }
84202 +
84203 + spin_unlock_irqrestore(&slob_lock, flags);
84204 + return "<slob>";
84205 +}
84206 +#endif
84207 +
84208 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84209 size_t ksize(const void *block)
84210 {
84211 struct page *sp;
84212 int align;
84213 - unsigned int *m;
84214 + slob_t *m;
84215
84216 BUG_ON(!block);
84217 if (unlikely(block == ZERO_SIZE_PTR))
84218 return 0;
84219
84220 sp = virt_to_page(block);
84221 - if (unlikely(!PageSlab(sp)))
84222 - return PAGE_SIZE << compound_order(sp);
84223 + VM_BUG_ON(!PageSlab(sp));
84224 + if (sp->private)
84225 + return sp->private;
84226
84227 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84228 - m = (unsigned int *)(block - align);
84229 - return SLOB_UNITS(*m) * SLOB_UNIT;
84230 + m = (slob_t *)(block - align);
84231 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84232 }
84233 EXPORT_SYMBOL(ksize);
84234
84235 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84236
84237 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84238 {
84239 - void *b;
84240 + void *b = NULL;
84241
84242 flags &= gfp_allowed_mask;
84243
84244 lockdep_trace_alloc(flags);
84245
84246 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84247 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84248 +#else
84249 if (c->size < PAGE_SIZE) {
84250 b = slob_alloc(c->size, flags, c->align, node);
84251 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84252 SLOB_UNITS(c->size) * SLOB_UNIT,
84253 flags, node);
84254 } else {
84255 - b = slob_new_pages(flags, get_order(c->size), node);
84256 + struct page *sp;
84257 +
84258 + sp = slob_new_pages(flags, get_order(c->size), node);
84259 + if (sp) {
84260 + b = page_address(sp);
84261 + sp->private = c->size;
84262 + }
84263 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84264 PAGE_SIZE << get_order(c->size),
84265 flags, node);
84266 }
84267 +#endif
84268
84269 if (c->ctor)
84270 c->ctor(b);
84271 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84272
84273 static void __kmem_cache_free(void *b, int size)
84274 {
84275 - if (size < PAGE_SIZE)
84276 + struct page *sp;
84277 +
84278 + sp = virt_to_page(b);
84279 + BUG_ON(!PageSlab(sp));
84280 + if (!sp->private)
84281 slob_free(b, size);
84282 else
84283 - slob_free_pages(b, get_order(size));
84284 + slob_free_pages(sp, get_order(size));
84285 }
84286
84287 static void kmem_rcu_free(struct rcu_head *head)
84288 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84289
84290 void kmem_cache_free(struct kmem_cache *c, void *b)
84291 {
84292 + int size = c->size;
84293 +
84294 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84295 + if (size + c->align < PAGE_SIZE) {
84296 + size += c->align;
84297 + b -= c->align;
84298 + }
84299 +#endif
84300 +
84301 kmemleak_free_recursive(b, c->flags);
84302 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84303 struct slob_rcu *slob_rcu;
84304 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84305 - slob_rcu->size = c->size;
84306 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84307 + slob_rcu->size = size;
84308 call_rcu(&slob_rcu->head, kmem_rcu_free);
84309 } else {
84310 - __kmem_cache_free(b, c->size);
84311 + __kmem_cache_free(b, size);
84312 }
84313
84314 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84315 + trace_kfree(_RET_IP_, b);
84316 +#else
84317 trace_kmem_cache_free(_RET_IP_, b);
84318 +#endif
84319 +
84320 }
84321 EXPORT_SYMBOL(kmem_cache_free);
84322
84323 diff --git a/mm/slub.c b/mm/slub.c
84324 index 4aec537..a64753d 100644
84325 --- a/mm/slub.c
84326 +++ b/mm/slub.c
84327 @@ -197,7 +197,7 @@ struct track {
84328
84329 enum track_item { TRACK_ALLOC, TRACK_FREE };
84330
84331 -#ifdef CONFIG_SYSFS
84332 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84333 static int sysfs_slab_add(struct kmem_cache *);
84334 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84335 static void sysfs_slab_remove(struct kmem_cache *);
84336 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84337 if (!t->addr)
84338 return;
84339
84340 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84341 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84342 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84343 #ifdef CONFIG_STACKTRACE
84344 {
84345 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84346 * Merge control. If this is set then no merging of slab caches will occur.
84347 * (Could be removed. This was introduced to pacify the merge skeptics.)
84348 */
84349 -static int slub_nomerge;
84350 +static int slub_nomerge = 1;
84351
84352 /*
84353 * Calculate the order of allocation given an slab object size.
84354 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84355 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84356 #endif
84357
84358 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84359 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84360 +#endif
84361 +
84362 static int __init setup_slub_min_order(char *str)
84363 {
84364 get_option(&str, &slub_min_order);
84365 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84366 return kmalloc_dma_caches[index];
84367
84368 #endif
84369 +
84370 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84371 + if (flags & SLAB_USERCOPY)
84372 + return kmalloc_usercopy_caches[index];
84373 +
84374 +#endif
84375 +
84376 return kmalloc_caches[index];
84377 }
84378
84379 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84380 EXPORT_SYMBOL(__kmalloc_node);
84381 #endif
84382
84383 +bool is_usercopy_object(const void *ptr)
84384 +{
84385 + struct page *page;
84386 + struct kmem_cache *s;
84387 +
84388 + if (ZERO_OR_NULL_PTR(ptr))
84389 + return false;
84390 +
84391 + if (!slab_is_available())
84392 + return false;
84393 +
84394 + if (!virt_addr_valid(ptr))
84395 + return false;
84396 +
84397 + page = virt_to_head_page(ptr);
84398 +
84399 + if (!PageSlab(page))
84400 + return false;
84401 +
84402 + s = page->slab_cache;
84403 + return s->flags & SLAB_USERCOPY;
84404 +}
84405 +
84406 +#ifdef CONFIG_PAX_USERCOPY
84407 +const char *check_heap_object(const void *ptr, unsigned long n)
84408 +{
84409 + struct page *page;
84410 + struct kmem_cache *s;
84411 + unsigned long offset;
84412 +
84413 + if (ZERO_OR_NULL_PTR(ptr))
84414 + return "<null>";
84415 +
84416 + if (!virt_addr_valid(ptr))
84417 + return NULL;
84418 +
84419 + page = virt_to_head_page(ptr);
84420 +
84421 + if (!PageSlab(page))
84422 + return NULL;
84423 +
84424 + s = page->slab_cache;
84425 + if (!(s->flags & SLAB_USERCOPY))
84426 + return s->name;
84427 +
84428 + offset = (ptr - page_address(page)) % s->size;
84429 + if (offset <= s->object_size && n <= s->object_size - offset)
84430 + return NULL;
84431 +
84432 + return s->name;
84433 +}
84434 +#endif
84435 +
84436 size_t ksize(const void *object)
84437 {
84438 struct page *page;
84439 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84440 if (unlikely(ZERO_OR_NULL_PTR(x)))
84441 return;
84442
84443 + VM_BUG_ON(!virt_addr_valid(x));
84444 page = virt_to_head_page(x);
84445 if (unlikely(!PageSlab(page))) {
84446 BUG_ON(!PageCompound(page));
84447 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84448
84449 /* Caches that are not of the two-to-the-power-of size */
84450 if (KMALLOC_MIN_SIZE <= 32) {
84451 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84452 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84453 caches++;
84454 }
84455
84456 if (KMALLOC_MIN_SIZE <= 64) {
84457 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
84458 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
84459 caches++;
84460 }
84461
84462 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
84463 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
84464 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
84465 caches++;
84466 }
84467
84468 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
84469 }
84470 }
84471 #endif
84472 +
84473 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84474 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
84475 + struct kmem_cache *s = kmalloc_caches[i];
84476 +
84477 + if (s && s->size) {
84478 + char *name = kasprintf(GFP_NOWAIT,
84479 + "usercopy-kmalloc-%d", s->object_size);
84480 +
84481 + BUG_ON(!name);
84482 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
84483 + s->object_size, SLAB_USERCOPY);
84484 + }
84485 + }
84486 +#endif
84487 +
84488 printk(KERN_INFO
84489 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
84490 " CPUs=%d, Nodes=%d\n",
84491 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
84492 /*
84493 * We may have set a slab to be unmergeable during bootstrap.
84494 */
84495 - if (s->refcount < 0)
84496 + if (atomic_read(&s->refcount) < 0)
84497 return 1;
84498
84499 return 0;
84500 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84501
84502 s = find_mergeable(memcg, size, align, flags, name, ctor);
84503 if (s) {
84504 - s->refcount++;
84505 + atomic_inc(&s->refcount);
84506 /*
84507 * Adjust the object sizes so that we clear
84508 * the complete object on kzalloc.
84509 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84510 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
84511
84512 if (sysfs_slab_alias(s, name)) {
84513 - s->refcount--;
84514 + atomic_dec(&s->refcount);
84515 s = NULL;
84516 }
84517 }
84518 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
84519 return NOTIFY_OK;
84520 }
84521
84522 -static struct notifier_block __cpuinitdata slab_notifier = {
84523 +static struct notifier_block slab_notifier = {
84524 .notifier_call = slab_cpuup_callback
84525 };
84526
84527 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
84528 }
84529 #endif
84530
84531 -#ifdef CONFIG_SYSFS
84532 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84533 static int count_inuse(struct page *page)
84534 {
84535 return page->inuse;
84536 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
84537 validate_slab_cache(kmalloc_caches[9]);
84538 }
84539 #else
84540 -#ifdef CONFIG_SYSFS
84541 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84542 static void resiliency_test(void) {};
84543 #endif
84544 #endif
84545
84546 -#ifdef CONFIG_SYSFS
84547 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84548 enum slab_stat_type {
84549 SL_ALL, /* All slabs */
84550 SL_PARTIAL, /* Only partially allocated slabs */
84551 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
84552
84553 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
84554 {
84555 - return sprintf(buf, "%d\n", s->refcount - 1);
84556 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
84557 }
84558 SLAB_ATTR_RO(aliases);
84559
84560 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
84561 return name;
84562 }
84563
84564 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84565 static int sysfs_slab_add(struct kmem_cache *s)
84566 {
84567 int err;
84568 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
84569 kobject_del(&s->kobj);
84570 kobject_put(&s->kobj);
84571 }
84572 +#endif
84573
84574 /*
84575 * Need to buffer aliases during bootup until sysfs becomes
84576 @@ -5336,6 +5419,7 @@ struct saved_alias {
84577
84578 static struct saved_alias *alias_list;
84579
84580 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84581 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84582 {
84583 struct saved_alias *al;
84584 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84585 alias_list = al;
84586 return 0;
84587 }
84588 +#endif
84589
84590 static int __init slab_sysfs_init(void)
84591 {
84592 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
84593 index 1b7e22a..3fcd4f3 100644
84594 --- a/mm/sparse-vmemmap.c
84595 +++ b/mm/sparse-vmemmap.c
84596 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
84597 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84598 if (!p)
84599 return NULL;
84600 - pud_populate(&init_mm, pud, p);
84601 + pud_populate_kernel(&init_mm, pud, p);
84602 }
84603 return pud;
84604 }
84605 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
84606 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84607 if (!p)
84608 return NULL;
84609 - pgd_populate(&init_mm, pgd, p);
84610 + pgd_populate_kernel(&init_mm, pgd, p);
84611 }
84612 return pgd;
84613 }
84614 diff --git a/mm/sparse.c b/mm/sparse.c
84615 index 7ca6dc8..6472aa1 100644
84616 --- a/mm/sparse.c
84617 +++ b/mm/sparse.c
84618 @@ -783,7 +783,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
84619
84620 for (i = 0; i < PAGES_PER_SECTION; i++) {
84621 if (PageHWPoison(&memmap[i])) {
84622 - atomic_long_sub(1, &num_poisoned_pages);
84623 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
84624 ClearPageHWPoison(&memmap[i]);
84625 }
84626 }
84627 diff --git a/mm/swap.c b/mm/swap.c
84628 index 8a529a0..154ef26 100644
84629 --- a/mm/swap.c
84630 +++ b/mm/swap.c
84631 @@ -30,6 +30,7 @@
84632 #include <linux/backing-dev.h>
84633 #include <linux/memcontrol.h>
84634 #include <linux/gfp.h>
84635 +#include <linux/hugetlb.h>
84636
84637 #include "internal.h"
84638
84639 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
84640
84641 __page_cache_release(page);
84642 dtor = get_compound_page_dtor(page);
84643 + if (!PageHuge(page))
84644 + BUG_ON(dtor != free_compound_page);
84645 (*dtor)(page);
84646 }
84647
84648 diff --git a/mm/swapfile.c b/mm/swapfile.c
84649 index a1f7772..9e982ac 100644
84650 --- a/mm/swapfile.c
84651 +++ b/mm/swapfile.c
84652 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
84653
84654 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
84655 /* Activity counter to indicate that a swapon or swapoff has occurred */
84656 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
84657 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
84658
84659 static inline unsigned char swap_count(unsigned char ent)
84660 {
84661 @@ -1683,7 +1683,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
84662 }
84663 filp_close(swap_file, NULL);
84664 err = 0;
84665 - atomic_inc(&proc_poll_event);
84666 + atomic_inc_unchecked(&proc_poll_event);
84667 wake_up_interruptible(&proc_poll_wait);
84668
84669 out_dput:
84670 @@ -1700,8 +1700,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
84671
84672 poll_wait(file, &proc_poll_wait, wait);
84673
84674 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
84675 - seq->poll_event = atomic_read(&proc_poll_event);
84676 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
84677 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84678 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
84679 }
84680
84681 @@ -1799,7 +1799,7 @@ static int swaps_open(struct inode *inode, struct file *file)
84682 return ret;
84683
84684 seq = file->private_data;
84685 - seq->poll_event = atomic_read(&proc_poll_event);
84686 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84687 return 0;
84688 }
84689
84690 @@ -2142,7 +2142,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
84691 (frontswap_map) ? "FS" : "");
84692
84693 mutex_unlock(&swapon_mutex);
84694 - atomic_inc(&proc_poll_event);
84695 + atomic_inc_unchecked(&proc_poll_event);
84696 wake_up_interruptible(&proc_poll_wait);
84697
84698 if (S_ISREG(inode->i_mode))
84699 diff --git a/mm/util.c b/mm/util.c
84700 index ab1424d..7c5bd5a 100644
84701 --- a/mm/util.c
84702 +++ b/mm/util.c
84703 @@ -294,6 +294,12 @@ done:
84704 void arch_pick_mmap_layout(struct mm_struct *mm)
84705 {
84706 mm->mmap_base = TASK_UNMAPPED_BASE;
84707 +
84708 +#ifdef CONFIG_PAX_RANDMMAP
84709 + if (mm->pax_flags & MF_PAX_RANDMMAP)
84710 + mm->mmap_base += mm->delta_mmap;
84711 +#endif
84712 +
84713 mm->get_unmapped_area = arch_get_unmapped_area;
84714 mm->unmap_area = arch_unmap_area;
84715 }
84716 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
84717 index 0f751f2..ef398a0 100644
84718 --- a/mm/vmalloc.c
84719 +++ b/mm/vmalloc.c
84720 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
84721
84722 pte = pte_offset_kernel(pmd, addr);
84723 do {
84724 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84725 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84726 +
84727 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84728 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
84729 + BUG_ON(!pte_exec(*pte));
84730 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
84731 + continue;
84732 + }
84733 +#endif
84734 +
84735 + {
84736 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84737 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84738 + }
84739 } while (pte++, addr += PAGE_SIZE, addr != end);
84740 }
84741
84742 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
84743 pte = pte_alloc_kernel(pmd, addr);
84744 if (!pte)
84745 return -ENOMEM;
84746 +
84747 + pax_open_kernel();
84748 do {
84749 struct page *page = pages[*nr];
84750
84751 - if (WARN_ON(!pte_none(*pte)))
84752 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84753 + if (pgprot_val(prot) & _PAGE_NX)
84754 +#endif
84755 +
84756 + if (!pte_none(*pte)) {
84757 + pax_close_kernel();
84758 + WARN_ON(1);
84759 return -EBUSY;
84760 - if (WARN_ON(!page))
84761 + }
84762 + if (!page) {
84763 + pax_close_kernel();
84764 + WARN_ON(1);
84765 return -ENOMEM;
84766 + }
84767 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
84768 (*nr)++;
84769 } while (pte++, addr += PAGE_SIZE, addr != end);
84770 + pax_close_kernel();
84771 return 0;
84772 }
84773
84774 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
84775 pmd_t *pmd;
84776 unsigned long next;
84777
84778 - pmd = pmd_alloc(&init_mm, pud, addr);
84779 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
84780 if (!pmd)
84781 return -ENOMEM;
84782 do {
84783 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
84784 pud_t *pud;
84785 unsigned long next;
84786
84787 - pud = pud_alloc(&init_mm, pgd, addr);
84788 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
84789 if (!pud)
84790 return -ENOMEM;
84791 do {
84792 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
84793 * and fall back on vmalloc() if that fails. Others
84794 * just put it in the vmalloc space.
84795 */
84796 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
84797 +#ifdef CONFIG_MODULES
84798 +#ifdef MODULES_VADDR
84799 unsigned long addr = (unsigned long)x;
84800 if (addr >= MODULES_VADDR && addr < MODULES_END)
84801 return 1;
84802 #endif
84803 +
84804 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84805 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
84806 + return 1;
84807 +#endif
84808 +
84809 +#endif
84810 +
84811 return is_vmalloc_addr(x);
84812 }
84813
84814 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
84815
84816 if (!pgd_none(*pgd)) {
84817 pud_t *pud = pud_offset(pgd, addr);
84818 +#ifdef CONFIG_X86
84819 + if (!pud_large(*pud))
84820 +#endif
84821 if (!pud_none(*pud)) {
84822 pmd_t *pmd = pmd_offset(pud, addr);
84823 +#ifdef CONFIG_X86
84824 + if (!pmd_large(*pmd))
84825 +#endif
84826 if (!pmd_none(*pmd)) {
84827 pte_t *ptep, pte;
84828
84829 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
84830 * Allocate a region of KVA of the specified size and alignment, within the
84831 * vstart and vend.
84832 */
84833 -static struct vmap_area *alloc_vmap_area(unsigned long size,
84834 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
84835 unsigned long align,
84836 unsigned long vstart, unsigned long vend,
84837 int node, gfp_t gfp_mask)
84838 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
84839 struct vm_struct *area;
84840
84841 BUG_ON(in_interrupt());
84842 +
84843 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84844 + if (flags & VM_KERNEXEC) {
84845 + if (start != VMALLOC_START || end != VMALLOC_END)
84846 + return NULL;
84847 + start = (unsigned long)MODULES_EXEC_VADDR;
84848 + end = (unsigned long)MODULES_EXEC_END;
84849 + }
84850 +#endif
84851 +
84852 if (flags & VM_IOREMAP) {
84853 int bit = fls(size);
84854
84855 @@ -1569,6 +1618,11 @@ void *vmap(struct page **pages, unsigned int count,
84856 if (count > totalram_pages)
84857 return NULL;
84858
84859 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84860 + if (!(pgprot_val(prot) & _PAGE_NX))
84861 + flags |= VM_KERNEXEC;
84862 +#endif
84863 +
84864 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
84865 __builtin_return_address(0));
84866 if (!area)
84867 @@ -1670,6 +1724,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
84868 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
84869 goto fail;
84870
84871 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84872 + if (!(pgprot_val(prot) & _PAGE_NX))
84873 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
84874 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
84875 + else
84876 +#endif
84877 +
84878 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
84879 start, end, node, gfp_mask, caller);
84880 if (!area)
84881 @@ -1845,10 +1906,9 @@ EXPORT_SYMBOL(vzalloc_node);
84882 * For tight control over page level allocator and protection flags
84883 * use __vmalloc() instead.
84884 */
84885 -
84886 void *vmalloc_exec(unsigned long size)
84887 {
84888 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
84889 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
84890 NUMA_NO_NODE, __builtin_return_address(0));
84891 }
84892
84893 @@ -2139,6 +2199,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
84894 unsigned long uaddr = vma->vm_start;
84895 unsigned long usize = vma->vm_end - vma->vm_start;
84896
84897 + BUG_ON(vma->vm_mirror);
84898 +
84899 if ((PAGE_SIZE-1) & (unsigned long)addr)
84900 return -EINVAL;
84901
84902 @@ -2578,7 +2640,11 @@ static int s_show(struct seq_file *m, void *p)
84903 v->addr, v->addr + v->size, v->size);
84904
84905 if (v->caller)
84906 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84907 + seq_printf(m, " %pK", v->caller);
84908 +#else
84909 seq_printf(m, " %pS", v->caller);
84910 +#endif
84911
84912 if (v->nr_pages)
84913 seq_printf(m, " pages=%d", v->nr_pages);
84914 diff --git a/mm/vmstat.c b/mm/vmstat.c
84915 index e1d8ed1..253fa3c 100644
84916 --- a/mm/vmstat.c
84917 +++ b/mm/vmstat.c
84918 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
84919 *
84920 * vm_stat contains the global counters
84921 */
84922 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84923 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84924 EXPORT_SYMBOL(vm_stat);
84925
84926 #ifdef CONFIG_SMP
84927 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
84928 v = p->vm_stat_diff[i];
84929 p->vm_stat_diff[i] = 0;
84930 local_irq_restore(flags);
84931 - atomic_long_add(v, &zone->vm_stat[i]);
84932 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84933 global_diff[i] += v;
84934 #ifdef CONFIG_NUMA
84935 /* 3 seconds idle till flush */
84936 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
84937
84938 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
84939 if (global_diff[i])
84940 - atomic_long_add(global_diff[i], &vm_stat[i]);
84941 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
84942 }
84943
84944 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84945 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84946 if (pset->vm_stat_diff[i]) {
84947 int v = pset->vm_stat_diff[i];
84948 pset->vm_stat_diff[i] = 0;
84949 - atomic_long_add(v, &zone->vm_stat[i]);
84950 - atomic_long_add(v, &vm_stat[i]);
84951 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84952 + atomic_long_add_unchecked(v, &vm_stat[i]);
84953 }
84954 }
84955 #endif
84956 @@ -1224,7 +1224,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
84957 return NOTIFY_OK;
84958 }
84959
84960 -static struct notifier_block __cpuinitdata vmstat_notifier =
84961 +static struct notifier_block vmstat_notifier =
84962 { &vmstat_cpuup_callback, NULL, 0 };
84963 #endif
84964
84965 @@ -1239,10 +1239,20 @@ static int __init setup_vmstat(void)
84966 start_cpu_timer(cpu);
84967 #endif
84968 #ifdef CONFIG_PROC_FS
84969 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
84970 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
84971 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
84972 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
84973 + {
84974 + mode_t gr_mode = S_IRUGO;
84975 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84976 + gr_mode = S_IRUSR;
84977 +#endif
84978 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
84979 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
84980 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
84981 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
84982 +#else
84983 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
84984 +#endif
84985 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
84986 + }
84987 #endif
84988 return 0;
84989 }
84990 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
84991 index 85addcd..c429a13 100644
84992 --- a/net/8021q/vlan.c
84993 +++ b/net/8021q/vlan.c
84994 @@ -114,6 +114,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
84995 if (vlan_id)
84996 vlan_vid_del(real_dev, vlan_id);
84997
84998 + /* Take it out of our own structures, but be sure to interlock with
84999 + * HW accelerating devices or SW vlan input packet processing if
85000 + * VLAN is not 0 (leave it there for 802.1p).
85001 + */
85002 + if (vlan_id)
85003 + vlan_vid_del(real_dev, vlan_id);
85004 +
85005 /* Get rid of the vlan's reference to real_dev */
85006 dev_put(real_dev);
85007 }
85008 @@ -496,7 +503,7 @@ out:
85009 return NOTIFY_DONE;
85010 }
85011
85012 -static struct notifier_block vlan_notifier_block __read_mostly = {
85013 +static struct notifier_block vlan_notifier_block = {
85014 .notifier_call = vlan_device_event,
85015 };
85016
85017 @@ -571,8 +578,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85018 err = -EPERM;
85019 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85020 break;
85021 - if ((args.u.name_type >= 0) &&
85022 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85023 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85024 struct vlan_net *vn;
85025
85026 vn = net_generic(net, vlan_net_id);
85027 diff --git a/net/9p/mod.c b/net/9p/mod.c
85028 index 6ab36ae..6f1841b 100644
85029 --- a/net/9p/mod.c
85030 +++ b/net/9p/mod.c
85031 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85032 void v9fs_register_trans(struct p9_trans_module *m)
85033 {
85034 spin_lock(&v9fs_trans_lock);
85035 - list_add_tail(&m->list, &v9fs_trans_list);
85036 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85037 spin_unlock(&v9fs_trans_lock);
85038 }
85039 EXPORT_SYMBOL(v9fs_register_trans);
85040 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85041 void v9fs_unregister_trans(struct p9_trans_module *m)
85042 {
85043 spin_lock(&v9fs_trans_lock);
85044 - list_del_init(&m->list);
85045 + pax_list_del_init((struct list_head *)&m->list);
85046 spin_unlock(&v9fs_trans_lock);
85047 }
85048 EXPORT_SYMBOL(v9fs_unregister_trans);
85049 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85050 index 02efb25..41541a9 100644
85051 --- a/net/9p/trans_fd.c
85052 +++ b/net/9p/trans_fd.c
85053 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85054 oldfs = get_fs();
85055 set_fs(get_ds());
85056 /* The cast to a user pointer is valid due to the set_fs() */
85057 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85058 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85059 set_fs(oldfs);
85060
85061 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85062 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85063 index 876fbe8..8bbea9f 100644
85064 --- a/net/atm/atm_misc.c
85065 +++ b/net/atm/atm_misc.c
85066 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85067 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85068 return 1;
85069 atm_return(vcc, truesize);
85070 - atomic_inc(&vcc->stats->rx_drop);
85071 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85072 return 0;
85073 }
85074 EXPORT_SYMBOL(atm_charge);
85075 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85076 }
85077 }
85078 atm_return(vcc, guess);
85079 - atomic_inc(&vcc->stats->rx_drop);
85080 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85081 return NULL;
85082 }
85083 EXPORT_SYMBOL(atm_alloc_charge);
85084 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85085
85086 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85087 {
85088 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85089 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85090 __SONET_ITEMS
85091 #undef __HANDLE_ITEM
85092 }
85093 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85094
85095 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85096 {
85097 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85098 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85099 __SONET_ITEMS
85100 #undef __HANDLE_ITEM
85101 }
85102 diff --git a/net/atm/lec.h b/net/atm/lec.h
85103 index a86aff9..3a0d6f6 100644
85104 --- a/net/atm/lec.h
85105 +++ b/net/atm/lec.h
85106 @@ -48,7 +48,7 @@ struct lane2_ops {
85107 const u8 *tlvs, u32 sizeoftlvs);
85108 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85109 const u8 *tlvs, u32 sizeoftlvs);
85110 -};
85111 +} __no_const;
85112
85113 /*
85114 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85115 diff --git a/net/atm/proc.c b/net/atm/proc.c
85116 index 6ac35ff..ac0e136 100644
85117 --- a/net/atm/proc.c
85118 +++ b/net/atm/proc.c
85119 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85120 const struct k_atm_aal_stats *stats)
85121 {
85122 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85123 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85124 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85125 - atomic_read(&stats->rx_drop));
85126 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85127 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85128 + atomic_read_unchecked(&stats->rx_drop));
85129 }
85130
85131 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85132 diff --git a/net/atm/resources.c b/net/atm/resources.c
85133 index 0447d5d..3cf4728 100644
85134 --- a/net/atm/resources.c
85135 +++ b/net/atm/resources.c
85136 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85137 static void copy_aal_stats(struct k_atm_aal_stats *from,
85138 struct atm_aal_stats *to)
85139 {
85140 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85141 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85142 __AAL_STAT_ITEMS
85143 #undef __HANDLE_ITEM
85144 }
85145 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85146 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85147 struct atm_aal_stats *to)
85148 {
85149 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85150 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85151 __AAL_STAT_ITEMS
85152 #undef __HANDLE_ITEM
85153 }
85154 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85155 index d5744b7..506bae3 100644
85156 --- a/net/ax25/sysctl_net_ax25.c
85157 +++ b/net/ax25/sysctl_net_ax25.c
85158 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85159 {
85160 char path[sizeof("net/ax25/") + IFNAMSIZ];
85161 int k;
85162 - struct ctl_table *table;
85163 + ctl_table_no_const *table;
85164
85165 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85166 if (!table)
85167 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85168 index a5bb0a7..e1d8b97 100644
85169 --- a/net/batman-adv/bat_iv_ogm.c
85170 +++ b/net/batman-adv/bat_iv_ogm.c
85171 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85172
85173 /* randomize initial seqno to avoid collision */
85174 get_random_bytes(&random_seqno, sizeof(random_seqno));
85175 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85176 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85177
85178 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85179 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85180 @@ -611,9 +611,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85181 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85182
85183 /* change sequence number to network order */
85184 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85185 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85186 batadv_ogm_packet->seqno = htonl(seqno);
85187 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85188 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85189
85190 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85191 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85192 @@ -1013,7 +1013,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85193 return;
85194
85195 /* could be changed by schedule_own_packet() */
85196 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85197 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85198
85199 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85200 has_directlink_flag = 1;
85201 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85202 index 368219e..53f56f9 100644
85203 --- a/net/batman-adv/hard-interface.c
85204 +++ b/net/batman-adv/hard-interface.c
85205 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85206 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85207 dev_add_pack(&hard_iface->batman_adv_ptype);
85208
85209 - atomic_set(&hard_iface->frag_seqno, 1);
85210 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85211 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85212 hard_iface->net_dev->name);
85213
85214 @@ -514,7 +514,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85215 /* This can't be called via a bat_priv callback because
85216 * we have no bat_priv yet.
85217 */
85218 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85219 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85220 hard_iface->bat_iv.ogm_buff = NULL;
85221
85222 return hard_iface;
85223 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85224 index 2711e87..4ca48fa 100644
85225 --- a/net/batman-adv/soft-interface.c
85226 +++ b/net/batman-adv/soft-interface.c
85227 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85228 primary_if->net_dev->dev_addr, ETH_ALEN);
85229
85230 /* set broadcast sequence number */
85231 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85232 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85233 bcast_packet->seqno = htonl(seqno);
85234
85235 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85236 @@ -527,7 +527,7 @@ struct net_device *batadv_softif_create(const char *name)
85237 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85238
85239 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85240 - atomic_set(&bat_priv->bcast_seqno, 1);
85241 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85242 atomic_set(&bat_priv->tt.vn, 0);
85243 atomic_set(&bat_priv->tt.local_changes, 0);
85244 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85245 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85246 index 4cd87a0..348e705 100644
85247 --- a/net/batman-adv/types.h
85248 +++ b/net/batman-adv/types.h
85249 @@ -51,7 +51,7 @@
85250 struct batadv_hard_iface_bat_iv {
85251 unsigned char *ogm_buff;
85252 int ogm_buff_len;
85253 - atomic_t ogm_seqno;
85254 + atomic_unchecked_t ogm_seqno;
85255 };
85256
85257 /**
85258 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
85259 int16_t if_num;
85260 char if_status;
85261 struct net_device *net_dev;
85262 - atomic_t frag_seqno;
85263 + atomic_unchecked_t frag_seqno;
85264 struct kobject *hardif_obj;
85265 atomic_t refcount;
85266 struct packet_type batman_adv_ptype;
85267 @@ -495,7 +495,7 @@ struct batadv_priv {
85268 #ifdef CONFIG_BATMAN_ADV_DEBUG
85269 atomic_t log_level;
85270 #endif
85271 - atomic_t bcast_seqno;
85272 + atomic_unchecked_t bcast_seqno;
85273 atomic_t bcast_queue_left;
85274 atomic_t batman_queue_left;
85275 char num_ifaces;
85276 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85277 index 50e079f..49ce2d2 100644
85278 --- a/net/batman-adv/unicast.c
85279 +++ b/net/batman-adv/unicast.c
85280 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85281 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85282 frag2->flags = large_tail;
85283
85284 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85285 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85286 frag1->seqno = htons(seqno - 1);
85287 frag2->seqno = htons(seqno);
85288
85289 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85290 index 6a93614..1415549 100644
85291 --- a/net/bluetooth/hci_sock.c
85292 +++ b/net/bluetooth/hci_sock.c
85293 @@ -929,7 +929,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85294 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85295 }
85296
85297 - len = min_t(unsigned int, len, sizeof(uf));
85298 + len = min((size_t)len, sizeof(uf));
85299 if (copy_from_user(&uf, optval, len)) {
85300 err = -EFAULT;
85301 break;
85302 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85303 index 7c7e932..7a7815d 100644
85304 --- a/net/bluetooth/l2cap_core.c
85305 +++ b/net/bluetooth/l2cap_core.c
85306 @@ -3395,8 +3395,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85307 break;
85308
85309 case L2CAP_CONF_RFC:
85310 - if (olen == sizeof(rfc))
85311 - memcpy(&rfc, (void *)val, olen);
85312 + if (olen != sizeof(rfc))
85313 + break;
85314 +
85315 + memcpy(&rfc, (void *)val, olen);
85316
85317 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85318 rfc.mode != chan->mode)
85319 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85320 index 1bcfb84..dad9f98 100644
85321 --- a/net/bluetooth/l2cap_sock.c
85322 +++ b/net/bluetooth/l2cap_sock.c
85323 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85324 struct sock *sk = sock->sk;
85325 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85326 struct l2cap_options opts;
85327 - int len, err = 0;
85328 + int err = 0;
85329 + size_t len = optlen;
85330 u32 opt;
85331
85332 BT_DBG("sk %p", sk);
85333 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85334 opts.max_tx = chan->max_tx;
85335 opts.txwin_size = chan->tx_win;
85336
85337 - len = min_t(unsigned int, sizeof(opts), optlen);
85338 + len = min(sizeof(opts), len);
85339 if (copy_from_user((char *) &opts, optval, len)) {
85340 err = -EFAULT;
85341 break;
85342 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85343 struct bt_security sec;
85344 struct bt_power pwr;
85345 struct l2cap_conn *conn;
85346 - int len, err = 0;
85347 + int err = 0;
85348 + size_t len = optlen;
85349 u32 opt;
85350
85351 BT_DBG("sk %p", sk);
85352 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85353
85354 sec.level = BT_SECURITY_LOW;
85355
85356 - len = min_t(unsigned int, sizeof(sec), optlen);
85357 + len = min(sizeof(sec), len);
85358 if (copy_from_user((char *) &sec, optval, len)) {
85359 err = -EFAULT;
85360 break;
85361 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85362
85363 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85364
85365 - len = min_t(unsigned int, sizeof(pwr), optlen);
85366 + len = min(sizeof(pwr), len);
85367 if (copy_from_user((char *) &pwr, optval, len)) {
85368 err = -EFAULT;
85369 break;
85370 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85371 index 7c9224b..381009e 100644
85372 --- a/net/bluetooth/rfcomm/sock.c
85373 +++ b/net/bluetooth/rfcomm/sock.c
85374 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85375 struct sock *sk = sock->sk;
85376 struct bt_security sec;
85377 int err = 0;
85378 - size_t len;
85379 + size_t len = optlen;
85380 u32 opt;
85381
85382 BT_DBG("sk %p", sk);
85383 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85384
85385 sec.level = BT_SECURITY_LOW;
85386
85387 - len = min_t(unsigned int, sizeof(sec), optlen);
85388 + len = min(sizeof(sec), len);
85389 if (copy_from_user((char *) &sec, optval, len)) {
85390 err = -EFAULT;
85391 break;
85392 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85393 index b6e44ad..5b0d514 100644
85394 --- a/net/bluetooth/rfcomm/tty.c
85395 +++ b/net/bluetooth/rfcomm/tty.c
85396 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85397 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85398
85399 spin_lock_irqsave(&dev->port.lock, flags);
85400 - if (dev->port.count > 0) {
85401 + if (atomic_read(&dev->port.count) > 0) {
85402 spin_unlock_irqrestore(&dev->port.lock, flags);
85403 return;
85404 }
85405 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85406 return -ENODEV;
85407
85408 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85409 - dev->channel, dev->port.count);
85410 + dev->channel, atomic_read(&dev->port.count));
85411
85412 spin_lock_irqsave(&dev->port.lock, flags);
85413 - if (++dev->port.count > 1) {
85414 + if (atomic_inc_return(&dev->port.count) > 1) {
85415 spin_unlock_irqrestore(&dev->port.lock, flags);
85416 return 0;
85417 }
85418 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85419 return;
85420
85421 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85422 - dev->port.count);
85423 + atomic_read(&dev->port.count));
85424
85425 spin_lock_irqsave(&dev->port.lock, flags);
85426 - if (!--dev->port.count) {
85427 + if (!atomic_dec_return(&dev->port.count)) {
85428 spin_unlock_irqrestore(&dev->port.lock, flags);
85429 if (dev->tty_dev->parent)
85430 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
85431 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
85432 index 8d493c9..3849e49 100644
85433 --- a/net/bridge/netfilter/ebtables.c
85434 +++ b/net/bridge/netfilter/ebtables.c
85435 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85436 tmp.valid_hooks = t->table->valid_hooks;
85437 }
85438 mutex_unlock(&ebt_mutex);
85439 - if (copy_to_user(user, &tmp, *len) != 0){
85440 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
85441 BUGPRINT("c2u Didn't work\n");
85442 ret = -EFAULT;
85443 break;
85444 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85445 goto out;
85446 tmp.valid_hooks = t->valid_hooks;
85447
85448 - if (copy_to_user(user, &tmp, *len) != 0) {
85449 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85450 ret = -EFAULT;
85451 break;
85452 }
85453 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85454 tmp.entries_size = t->table->entries_size;
85455 tmp.valid_hooks = t->table->valid_hooks;
85456
85457 - if (copy_to_user(user, &tmp, *len) != 0) {
85458 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85459 ret = -EFAULT;
85460 break;
85461 }
85462 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
85463 index a376ec1..1fbd6be 100644
85464 --- a/net/caif/cfctrl.c
85465 +++ b/net/caif/cfctrl.c
85466 @@ -10,6 +10,7 @@
85467 #include <linux/spinlock.h>
85468 #include <linux/slab.h>
85469 #include <linux/pkt_sched.h>
85470 +#include <linux/sched.h>
85471 #include <net/caif/caif_layer.h>
85472 #include <net/caif/cfpkt.h>
85473 #include <net/caif/cfctrl.h>
85474 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
85475 memset(&dev_info, 0, sizeof(dev_info));
85476 dev_info.id = 0xff;
85477 cfsrvl_init(&this->serv, 0, &dev_info, false);
85478 - atomic_set(&this->req_seq_no, 1);
85479 - atomic_set(&this->rsp_seq_no, 1);
85480 + atomic_set_unchecked(&this->req_seq_no, 1);
85481 + atomic_set_unchecked(&this->rsp_seq_no, 1);
85482 this->serv.layer.receive = cfctrl_recv;
85483 sprintf(this->serv.layer.name, "ctrl");
85484 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
85485 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
85486 struct cfctrl_request_info *req)
85487 {
85488 spin_lock_bh(&ctrl->info_list_lock);
85489 - atomic_inc(&ctrl->req_seq_no);
85490 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
85491 + atomic_inc_unchecked(&ctrl->req_seq_no);
85492 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
85493 list_add_tail(&req->list, &ctrl->list);
85494 spin_unlock_bh(&ctrl->info_list_lock);
85495 }
85496 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
85497 if (p != first)
85498 pr_warn("Requests are not received in order\n");
85499
85500 - atomic_set(&ctrl->rsp_seq_no,
85501 + atomic_set_unchecked(&ctrl->rsp_seq_no,
85502 p->sequence_no);
85503 list_del(&p->list);
85504 goto out;
85505 diff --git a/net/can/af_can.c b/net/can/af_can.c
85506 index c48e522..1223690 100644
85507 --- a/net/can/af_can.c
85508 +++ b/net/can/af_can.c
85509 @@ -870,7 +870,7 @@ static const struct net_proto_family can_family_ops = {
85510 };
85511
85512 /* notifier block for netdevice event */
85513 -static struct notifier_block can_netdev_notifier __read_mostly = {
85514 +static struct notifier_block can_netdev_notifier = {
85515 .notifier_call = can_notifier,
85516 };
85517
85518 diff --git a/net/can/gw.c b/net/can/gw.c
85519 index 117814a..ad4fb73 100644
85520 --- a/net/can/gw.c
85521 +++ b/net/can/gw.c
85522 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
85523 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
85524
85525 static HLIST_HEAD(cgw_list);
85526 -static struct notifier_block notifier;
85527
85528 static struct kmem_cache *cgw_cache __read_mostly;
85529
85530 @@ -928,6 +927,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
85531 return err;
85532 }
85533
85534 +static struct notifier_block notifier = {
85535 + .notifier_call = cgw_notifier
85536 +};
85537 +
85538 static __init int cgw_module_init(void)
85539 {
85540 /* sanitize given module parameter */
85541 @@ -943,7 +946,6 @@ static __init int cgw_module_init(void)
85542 return -ENOMEM;
85543
85544 /* set notifier */
85545 - notifier.notifier_call = cgw_notifier;
85546 register_netdevice_notifier(&notifier);
85547
85548 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
85549 diff --git a/net/compat.c b/net/compat.c
85550 index 79ae884..17c5c09 100644
85551 --- a/net/compat.c
85552 +++ b/net/compat.c
85553 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
85554 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
85555 __get_user(kmsg->msg_flags, &umsg->msg_flags))
85556 return -EFAULT;
85557 - kmsg->msg_name = compat_ptr(tmp1);
85558 - kmsg->msg_iov = compat_ptr(tmp2);
85559 - kmsg->msg_control = compat_ptr(tmp3);
85560 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
85561 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
85562 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
85563 return 0;
85564 }
85565
85566 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85567
85568 if (kern_msg->msg_namelen) {
85569 if (mode == VERIFY_READ) {
85570 - int err = move_addr_to_kernel(kern_msg->msg_name,
85571 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
85572 kern_msg->msg_namelen,
85573 kern_address);
85574 if (err < 0)
85575 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85576 kern_msg->msg_name = NULL;
85577
85578 tot_len = iov_from_user_compat_to_kern(kern_iov,
85579 - (struct compat_iovec __user *)kern_msg->msg_iov,
85580 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
85581 kern_msg->msg_iovlen);
85582 if (tot_len >= 0)
85583 kern_msg->msg_iov = kern_iov;
85584 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85585
85586 #define CMSG_COMPAT_FIRSTHDR(msg) \
85587 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
85588 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
85589 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
85590 (struct compat_cmsghdr __user *)NULL)
85591
85592 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
85593 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
85594 (ucmlen) <= (unsigned long) \
85595 ((mhdr)->msg_controllen - \
85596 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
85597 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
85598
85599 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
85600 struct compat_cmsghdr __user *cmsg, int cmsg_len)
85601 {
85602 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
85603 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
85604 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
85605 msg->msg_controllen)
85606 return NULL;
85607 return (struct compat_cmsghdr __user *)ptr;
85608 @@ -219,7 +219,7 @@ Efault:
85609
85610 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
85611 {
85612 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85613 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85614 struct compat_cmsghdr cmhdr;
85615 struct compat_timeval ctv;
85616 struct compat_timespec cts[3];
85617 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
85618
85619 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
85620 {
85621 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85622 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85623 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
85624 int fdnum = scm->fp->count;
85625 struct file **fp = scm->fp->fp;
85626 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
85627 return -EFAULT;
85628 old_fs = get_fs();
85629 set_fs(KERNEL_DS);
85630 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
85631 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
85632 set_fs(old_fs);
85633
85634 return err;
85635 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
85636 len = sizeof(ktime);
85637 old_fs = get_fs();
85638 set_fs(KERNEL_DS);
85639 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
85640 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
85641 set_fs(old_fs);
85642
85643 if (!err) {
85644 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85645 case MCAST_JOIN_GROUP:
85646 case MCAST_LEAVE_GROUP:
85647 {
85648 - struct compat_group_req __user *gr32 = (void *)optval;
85649 + struct compat_group_req __user *gr32 = (void __user *)optval;
85650 struct group_req __user *kgr =
85651 compat_alloc_user_space(sizeof(struct group_req));
85652 u32 interface;
85653 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85654 case MCAST_BLOCK_SOURCE:
85655 case MCAST_UNBLOCK_SOURCE:
85656 {
85657 - struct compat_group_source_req __user *gsr32 = (void *)optval;
85658 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
85659 struct group_source_req __user *kgsr = compat_alloc_user_space(
85660 sizeof(struct group_source_req));
85661 u32 interface;
85662 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85663 }
85664 case MCAST_MSFILTER:
85665 {
85666 - struct compat_group_filter __user *gf32 = (void *)optval;
85667 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85668 struct group_filter __user *kgf;
85669 u32 interface, fmode, numsrc;
85670
85671 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
85672 char __user *optval, int __user *optlen,
85673 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
85674 {
85675 - struct compat_group_filter __user *gf32 = (void *)optval;
85676 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85677 struct group_filter __user *kgf;
85678 int __user *koptlen;
85679 u32 interface, fmode, numsrc;
85680 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
85681
85682 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
85683 return -EINVAL;
85684 - if (copy_from_user(a, args, nas[call]))
85685 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
85686 return -EFAULT;
85687 a0 = a[0];
85688 a1 = a[1];
85689 diff --git a/net/core/datagram.c b/net/core/datagram.c
85690 index 368f9c3..f82d4a3 100644
85691 --- a/net/core/datagram.c
85692 +++ b/net/core/datagram.c
85693 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
85694 }
85695
85696 kfree_skb(skb);
85697 - atomic_inc(&sk->sk_drops);
85698 + atomic_inc_unchecked(&sk->sk_drops);
85699 sk_mem_reclaim_partial(sk);
85700
85701 return err;
85702 diff --git a/net/core/dev.c b/net/core/dev.c
85703 index 9a278e9..15f2b9e 100644
85704 --- a/net/core/dev.c
85705 +++ b/net/core/dev.c
85706 @@ -1617,7 +1617,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85707 {
85708 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
85709 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
85710 - atomic_long_inc(&dev->rx_dropped);
85711 + atomic_long_inc_unchecked(&dev->rx_dropped);
85712 kfree_skb(skb);
85713 return NET_RX_DROP;
85714 }
85715 @@ -1626,7 +1626,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85716 skb_orphan(skb);
85717
85718 if (unlikely(!is_skb_forwardable(dev, skb))) {
85719 - atomic_long_inc(&dev->rx_dropped);
85720 + atomic_long_inc_unchecked(&dev->rx_dropped);
85721 kfree_skb(skb);
85722 return NET_RX_DROP;
85723 }
85724 @@ -2351,7 +2351,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
85725
85726 struct dev_gso_cb {
85727 void (*destructor)(struct sk_buff *skb);
85728 -};
85729 +} __no_const;
85730
85731 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
85732
85733 @@ -3093,7 +3093,7 @@ enqueue:
85734
85735 local_irq_restore(flags);
85736
85737 - atomic_long_inc(&skb->dev->rx_dropped);
85738 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85739 kfree_skb(skb);
85740 return NET_RX_DROP;
85741 }
85742 @@ -3165,7 +3165,7 @@ int netif_rx_ni(struct sk_buff *skb)
85743 }
85744 EXPORT_SYMBOL(netif_rx_ni);
85745
85746 -static void net_tx_action(struct softirq_action *h)
85747 +static void net_tx_action(void)
85748 {
85749 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85750
85751 @@ -3490,7 +3490,7 @@ ncls:
85752 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
85753 } else {
85754 drop:
85755 - atomic_long_inc(&skb->dev->rx_dropped);
85756 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85757 kfree_skb(skb);
85758 /* Jamal, now you will not able to escape explaining
85759 * me how you were going to use this. :-)
85760 @@ -4095,7 +4095,7 @@ void netif_napi_del(struct napi_struct *napi)
85761 }
85762 EXPORT_SYMBOL(netif_napi_del);
85763
85764 -static void net_rx_action(struct softirq_action *h)
85765 +static void net_rx_action(void)
85766 {
85767 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85768 unsigned long time_limit = jiffies + 2;
85769 @@ -5522,7 +5522,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
85770 } else {
85771 netdev_stats_to_stats64(storage, &dev->stats);
85772 }
85773 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
85774 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
85775 return storage;
85776 }
85777 EXPORT_SYMBOL(dev_get_stats);
85778 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
85779 index 6cc0481..59cfb00 100644
85780 --- a/net/core/dev_ioctl.c
85781 +++ b/net/core/dev_ioctl.c
85782 @@ -376,9 +376,13 @@ void dev_load(struct net *net, const char *name)
85783 if (no_module && capable(CAP_NET_ADMIN))
85784 no_module = request_module("netdev-%s", name);
85785 if (no_module && capable(CAP_SYS_MODULE)) {
85786 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
85787 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
85788 +#else
85789 if (!request_module("%s", name))
85790 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
85791 name);
85792 +#endif
85793 }
85794 }
85795 EXPORT_SYMBOL(dev_load);
85796 diff --git a/net/core/flow.c b/net/core/flow.c
85797 index 2bfd081..53c6058 100644
85798 --- a/net/core/flow.c
85799 +++ b/net/core/flow.c
85800 @@ -61,7 +61,7 @@ struct flow_cache {
85801 struct timer_list rnd_timer;
85802 };
85803
85804 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
85805 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
85806 EXPORT_SYMBOL(flow_cache_genid);
85807 static struct flow_cache flow_cache_global;
85808 static struct kmem_cache *flow_cachep __read_mostly;
85809 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
85810
85811 static int flow_entry_valid(struct flow_cache_entry *fle)
85812 {
85813 - if (atomic_read(&flow_cache_genid) != fle->genid)
85814 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
85815 return 0;
85816 if (fle->object && !fle->object->ops->check(fle->object))
85817 return 0;
85818 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
85819 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
85820 fcp->hash_count++;
85821 }
85822 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
85823 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
85824 flo = fle->object;
85825 if (!flo)
85826 goto ret_object;
85827 @@ -279,7 +279,7 @@ nocache:
85828 }
85829 flo = resolver(net, key, family, dir, flo, ctx);
85830 if (fle) {
85831 - fle->genid = atomic_read(&flow_cache_genid);
85832 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
85833 if (!IS_ERR(flo))
85834 fle->object = flo;
85835 else
85836 diff --git a/net/core/iovec.c b/net/core/iovec.c
85837 index 7e7aeb0..2a998cb 100644
85838 --- a/net/core/iovec.c
85839 +++ b/net/core/iovec.c
85840 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85841 if (m->msg_namelen) {
85842 if (mode == VERIFY_READ) {
85843 void __user *namep;
85844 - namep = (void __user __force *) m->msg_name;
85845 + namep = (void __force_user *) m->msg_name;
85846 err = move_addr_to_kernel(namep, m->msg_namelen,
85847 address);
85848 if (err < 0)
85849 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85850 }
85851
85852 size = m->msg_iovlen * sizeof(struct iovec);
85853 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
85854 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
85855 return -EFAULT;
85856
85857 m->msg_iov = iov;
85858 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
85859 index 3863b8f..85c99a6 100644
85860 --- a/net/core/neighbour.c
85861 +++ b/net/core/neighbour.c
85862 @@ -2778,7 +2778,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
85863 size_t *lenp, loff_t *ppos)
85864 {
85865 int size, ret;
85866 - ctl_table tmp = *ctl;
85867 + ctl_table_no_const tmp = *ctl;
85868
85869 tmp.extra1 = &zero;
85870 tmp.extra2 = &unres_qlen_max;
85871 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
85872 index 3174f19..5810985 100644
85873 --- a/net/core/net-procfs.c
85874 +++ b/net/core/net-procfs.c
85875 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
85876 else
85877 seq_printf(seq, "%04x", ntohs(pt->type));
85878
85879 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85880 + seq_printf(seq, " %-8s %pF\n",
85881 + pt->dev ? pt->dev->name : "", NULL);
85882 +#else
85883 seq_printf(seq, " %-8s %pF\n",
85884 pt->dev ? pt->dev->name : "", pt->func);
85885 +#endif
85886 }
85887
85888 return 0;
85889 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
85890 index 7427ab5..389f411 100644
85891 --- a/net/core/net-sysfs.c
85892 +++ b/net/core/net-sysfs.c
85893 @@ -1321,7 +1321,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
85894 }
85895 EXPORT_SYMBOL(netdev_class_remove_file);
85896
85897 -int netdev_kobject_init(void)
85898 +int __init netdev_kobject_init(void)
85899 {
85900 kobj_ns_type_register(&net_ns_type_operations);
85901 return class_register(&net_class);
85902 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
85903 index 80e271d..2980cc2 100644
85904 --- a/net/core/net_namespace.c
85905 +++ b/net/core/net_namespace.c
85906 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
85907 int error;
85908 LIST_HEAD(net_exit_list);
85909
85910 - list_add_tail(&ops->list, list);
85911 + pax_list_add_tail((struct list_head *)&ops->list, list);
85912 if (ops->init || (ops->id && ops->size)) {
85913 for_each_net(net) {
85914 error = ops_init(ops, net);
85915 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
85916
85917 out_undo:
85918 /* If I have an error cleanup all namespaces I initialized */
85919 - list_del(&ops->list);
85920 + pax_list_del((struct list_head *)&ops->list);
85921 ops_exit_list(ops, &net_exit_list);
85922 ops_free_list(ops, &net_exit_list);
85923 return error;
85924 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
85925 struct net *net;
85926 LIST_HEAD(net_exit_list);
85927
85928 - list_del(&ops->list);
85929 + pax_list_del((struct list_head *)&ops->list);
85930 for_each_net(net)
85931 list_add_tail(&net->exit_list, &net_exit_list);
85932 ops_exit_list(ops, &net_exit_list);
85933 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
85934 mutex_lock(&net_mutex);
85935 error = register_pernet_operations(&pernet_list, ops);
85936 if (!error && (first_device == &pernet_list))
85937 - first_device = &ops->list;
85938 + first_device = (struct list_head *)&ops->list;
85939 mutex_unlock(&net_mutex);
85940 return error;
85941 }
85942 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
85943 index 23854b5..ff4fda4 100644
85944 --- a/net/core/rtnetlink.c
85945 +++ b/net/core/rtnetlink.c
85946 @@ -58,7 +58,7 @@ struct rtnl_link {
85947 rtnl_doit_func doit;
85948 rtnl_dumpit_func dumpit;
85949 rtnl_calcit_func calcit;
85950 -};
85951 +} __no_const;
85952
85953 static DEFINE_MUTEX(rtnl_mutex);
85954
85955 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
85956 if (rtnl_link_ops_get(ops->kind))
85957 return -EEXIST;
85958
85959 - if (!ops->dellink)
85960 - ops->dellink = unregister_netdevice_queue;
85961 + if (!ops->dellink) {
85962 + pax_open_kernel();
85963 + *(void **)&ops->dellink = unregister_netdevice_queue;
85964 + pax_close_kernel();
85965 + }
85966
85967 - list_add_tail(&ops->list, &link_ops);
85968 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
85969 return 0;
85970 }
85971 EXPORT_SYMBOL_GPL(__rtnl_link_register);
85972 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
85973 for_each_net(net) {
85974 __rtnl_kill_links(net, ops);
85975 }
85976 - list_del(&ops->list);
85977 + pax_list_del((struct list_head *)&ops->list);
85978 }
85979 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
85980
85981 diff --git a/net/core/scm.c b/net/core/scm.c
85982 index 2dc6cda..2159524 100644
85983 --- a/net/core/scm.c
85984 +++ b/net/core/scm.c
85985 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
85986 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85987 {
85988 struct cmsghdr __user *cm
85989 - = (__force struct cmsghdr __user *)msg->msg_control;
85990 + = (struct cmsghdr __force_user *)msg->msg_control;
85991 struct cmsghdr cmhdr;
85992 int cmlen = CMSG_LEN(len);
85993 int err;
85994 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85995 err = -EFAULT;
85996 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
85997 goto out;
85998 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
85999 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86000 goto out;
86001 cmlen = CMSG_SPACE(len);
86002 if (msg->msg_controllen < cmlen)
86003 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86004 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86005 {
86006 struct cmsghdr __user *cm
86007 - = (__force struct cmsghdr __user*)msg->msg_control;
86008 + = (struct cmsghdr __force_user *)msg->msg_control;
86009
86010 int fdmax = 0;
86011 int fdnum = scm->fp->count;
86012 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86013 if (fdnum < fdmax)
86014 fdmax = fdnum;
86015
86016 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86017 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86018 i++, cmfptr++)
86019 {
86020 struct socket *sock;
86021 diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
86022 index e61a8bb..6a2f13c 100644
86023 --- a/net/core/secure_seq.c
86024 +++ b/net/core/secure_seq.c
86025 @@ -12,12 +12,10 @@
86026
86027 static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
86028
86029 -static int __init net_secret_init(void)
86030 +void net_secret_init(void)
86031 {
86032 get_random_bytes(net_secret, sizeof(net_secret));
86033 - return 0;
86034 }
86035 -late_initcall(net_secret_init);
86036
86037 #ifdef CONFIG_INET
86038 static u32 seq_scale(u32 seq)
86039 diff --git a/net/core/sock.c b/net/core/sock.c
86040 index 1432266..1a0d4a1 100644
86041 --- a/net/core/sock.c
86042 +++ b/net/core/sock.c
86043 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86044 struct sk_buff_head *list = &sk->sk_receive_queue;
86045
86046 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86047 - atomic_inc(&sk->sk_drops);
86048 + atomic_inc_unchecked(&sk->sk_drops);
86049 trace_sock_rcvqueue_full(sk, skb);
86050 return -ENOMEM;
86051 }
86052 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86053 return err;
86054
86055 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86056 - atomic_inc(&sk->sk_drops);
86057 + atomic_inc_unchecked(&sk->sk_drops);
86058 return -ENOBUFS;
86059 }
86060
86061 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86062 skb_dst_force(skb);
86063
86064 spin_lock_irqsave(&list->lock, flags);
86065 - skb->dropcount = atomic_read(&sk->sk_drops);
86066 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86067 __skb_queue_tail(list, skb);
86068 spin_unlock_irqrestore(&list->lock, flags);
86069
86070 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86071 skb->dev = NULL;
86072
86073 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86074 - atomic_inc(&sk->sk_drops);
86075 + atomic_inc_unchecked(&sk->sk_drops);
86076 goto discard_and_relse;
86077 }
86078 if (nested)
86079 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86080 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86081 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86082 bh_unlock_sock(sk);
86083 - atomic_inc(&sk->sk_drops);
86084 + atomic_inc_unchecked(&sk->sk_drops);
86085 goto discard_and_relse;
86086 }
86087
86088 @@ -942,12 +942,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86089 struct timeval tm;
86090 } v;
86091
86092 - int lv = sizeof(int);
86093 - int len;
86094 + unsigned int lv = sizeof(int);
86095 + unsigned int len;
86096
86097 if (get_user(len, optlen))
86098 return -EFAULT;
86099 - if (len < 0)
86100 + if (len > INT_MAX)
86101 return -EINVAL;
86102
86103 memset(&v, 0, sizeof(v));
86104 @@ -1099,11 +1099,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86105
86106 case SO_PEERNAME:
86107 {
86108 - char address[128];
86109 + char address[_K_SS_MAXSIZE];
86110
86111 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86112 return -ENOTCONN;
86113 - if (lv < len)
86114 + if (lv < len || sizeof address < len)
86115 return -EINVAL;
86116 if (copy_to_user(optval, address, len))
86117 return -EFAULT;
86118 @@ -1166,7 +1166,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86119
86120 if (len > lv)
86121 len = lv;
86122 - if (copy_to_user(optval, &v, len))
86123 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86124 return -EFAULT;
86125 lenout:
86126 if (put_user(len, optlen))
86127 @@ -2284,7 +2284,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86128 */
86129 smp_wmb();
86130 atomic_set(&sk->sk_refcnt, 1);
86131 - atomic_set(&sk->sk_drops, 0);
86132 + atomic_set_unchecked(&sk->sk_drops, 0);
86133 }
86134 EXPORT_SYMBOL(sock_init_data);
86135
86136 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86137 index a29e90c..922399c 100644
86138 --- a/net/core/sock_diag.c
86139 +++ b/net/core/sock_diag.c
86140 @@ -9,26 +9,33 @@
86141 #include <linux/inet_diag.h>
86142 #include <linux/sock_diag.h>
86143
86144 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86145 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86146 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86147 static DEFINE_MUTEX(sock_diag_table_mutex);
86148
86149 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86150 {
86151 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86152 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86153 cookie[1] != INET_DIAG_NOCOOKIE) &&
86154 ((u32)(unsigned long)sk != cookie[0] ||
86155 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86156 return -ESTALE;
86157 else
86158 +#endif
86159 return 0;
86160 }
86161 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86162
86163 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86164 {
86165 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86166 + cookie[0] = 0;
86167 + cookie[1] = 0;
86168 +#else
86169 cookie[0] = (u32)(unsigned long)sk;
86170 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86171 +#endif
86172 }
86173 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86174
86175 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86176 mutex_lock(&sock_diag_table_mutex);
86177 if (sock_diag_handlers[hndl->family])
86178 err = -EBUSY;
86179 - else
86180 + else {
86181 + pax_open_kernel();
86182 sock_diag_handlers[hndl->family] = hndl;
86183 + pax_close_kernel();
86184 + }
86185 mutex_unlock(&sock_diag_table_mutex);
86186
86187 return err;
86188 @@ -92,7 +102,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86189
86190 mutex_lock(&sock_diag_table_mutex);
86191 BUG_ON(sock_diag_handlers[family] != hnld);
86192 + pax_open_kernel();
86193 sock_diag_handlers[family] = NULL;
86194 + pax_close_kernel();
86195 mutex_unlock(&sock_diag_table_mutex);
86196 }
86197 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86198 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86199 index cfdb46a..cef55e1 100644
86200 --- a/net/core/sysctl_net_core.c
86201 +++ b/net/core/sysctl_net_core.c
86202 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86203 {
86204 unsigned int orig_size, size;
86205 int ret, i;
86206 - ctl_table tmp = {
86207 + ctl_table_no_const tmp = {
86208 .data = &size,
86209 .maxlen = sizeof(size),
86210 .mode = table->mode
86211 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
86212
86213 static __net_init int sysctl_core_net_init(struct net *net)
86214 {
86215 - struct ctl_table *tbl;
86216 + ctl_table_no_const *tbl = NULL;
86217
86218 net->core.sysctl_somaxconn = SOMAXCONN;
86219
86220 - tbl = netns_core_table;
86221 if (!net_eq(net, &init_net)) {
86222 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86223 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86224 if (tbl == NULL)
86225 goto err_dup;
86226
86227 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86228 if (net->user_ns != &init_user_ns) {
86229 tbl[0].procname = NULL;
86230 }
86231 - }
86232 -
86233 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86234 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86235 + } else
86236 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86237 if (net->core.sysctl_hdr == NULL)
86238 goto err_reg;
86239
86240 return 0;
86241
86242 err_reg:
86243 - if (tbl != netns_core_table)
86244 - kfree(tbl);
86245 + kfree(tbl);
86246 err_dup:
86247 return -ENOMEM;
86248 }
86249 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86250 kfree(tbl);
86251 }
86252
86253 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86254 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86255 .init = sysctl_core_net_init,
86256 .exit = sysctl_core_net_exit,
86257 };
86258 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86259 index c21f200..bc4565b 100644
86260 --- a/net/decnet/af_decnet.c
86261 +++ b/net/decnet/af_decnet.c
86262 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
86263 .sysctl_rmem = sysctl_decnet_rmem,
86264 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86265 .obj_size = sizeof(struct dn_sock),
86266 + .slab_flags = SLAB_USERCOPY,
86267 };
86268
86269 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86270 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86271 index a55eecc..dd8428c 100644
86272 --- a/net/decnet/sysctl_net_decnet.c
86273 +++ b/net/decnet/sysctl_net_decnet.c
86274 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86275
86276 if (len > *lenp) len = *lenp;
86277
86278 - if (copy_to_user(buffer, addr, len))
86279 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86280 return -EFAULT;
86281
86282 *lenp = len;
86283 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86284
86285 if (len > *lenp) len = *lenp;
86286
86287 - if (copy_to_user(buffer, devname, len))
86288 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86289 return -EFAULT;
86290
86291 *lenp = len;
86292 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86293 index c929d9c..df10cde 100644
86294 --- a/net/ipv4/af_inet.c
86295 +++ b/net/ipv4/af_inet.c
86296 @@ -115,6 +115,7 @@
86297 #include <net/inet_common.h>
86298 #include <net/xfrm.h>
86299 #include <net/net_namespace.h>
86300 +#include <net/secure_seq.h>
86301 #ifdef CONFIG_IP_MROUTE
86302 #include <linux/mroute.h>
86303 #endif
86304 @@ -263,8 +264,10 @@ void build_ehash_secret(void)
86305 get_random_bytes(&rnd, sizeof(rnd));
86306 } while (rnd == 0);
86307
86308 - if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
86309 + if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0) {
86310 get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
86311 + net_secret_init();
86312 + }
86313 }
86314 EXPORT_SYMBOL(build_ehash_secret);
86315
86316 @@ -1699,13 +1702,9 @@ static int __init inet_init(void)
86317
86318 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
86319
86320 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86321 - if (!sysctl_local_reserved_ports)
86322 - goto out;
86323 -
86324 rc = proto_register(&tcp_prot, 1);
86325 if (rc)
86326 - goto out_free_reserved_ports;
86327 + goto out;
86328
86329 rc = proto_register(&udp_prot, 1);
86330 if (rc)
86331 @@ -1814,8 +1813,6 @@ out_unregister_udp_proto:
86332 proto_unregister(&udp_prot);
86333 out_unregister_tcp_proto:
86334 proto_unregister(&tcp_prot);
86335 -out_free_reserved_ports:
86336 - kfree(sysctl_local_reserved_ports);
86337 goto out;
86338 }
86339
86340 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86341 index 2e7f194..0fa4d6d 100644
86342 --- a/net/ipv4/ah4.c
86343 +++ b/net/ipv4/ah4.c
86344 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86345 return;
86346
86347 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86348 - atomic_inc(&flow_cache_genid);
86349 + atomic_inc_unchecked(&flow_cache_genid);
86350 rt_genid_bump(net);
86351
86352 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86353 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86354 index c6287cd..e9bc96a 100644
86355 --- a/net/ipv4/devinet.c
86356 +++ b/net/ipv4/devinet.c
86357 @@ -1992,7 +1992,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86358 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86359 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86360
86361 -static struct devinet_sysctl_table {
86362 +static const struct devinet_sysctl_table {
86363 struct ctl_table_header *sysctl_header;
86364 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86365 } devinet_sysctl = {
86366 @@ -2110,7 +2110,7 @@ static __net_init int devinet_init_net(struct net *net)
86367 int err;
86368 struct ipv4_devconf *all, *dflt;
86369 #ifdef CONFIG_SYSCTL
86370 - struct ctl_table *tbl = ctl_forward_entry;
86371 + ctl_table_no_const *tbl = NULL;
86372 struct ctl_table_header *forw_hdr;
86373 #endif
86374
86375 @@ -2128,7 +2128,7 @@ static __net_init int devinet_init_net(struct net *net)
86376 goto err_alloc_dflt;
86377
86378 #ifdef CONFIG_SYSCTL
86379 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86380 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86381 if (tbl == NULL)
86382 goto err_alloc_ctl;
86383
86384 @@ -2148,7 +2148,10 @@ static __net_init int devinet_init_net(struct net *net)
86385 goto err_reg_dflt;
86386
86387 err = -ENOMEM;
86388 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86389 + if (!net_eq(net, &init_net))
86390 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86391 + else
86392 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86393 if (forw_hdr == NULL)
86394 goto err_reg_ctl;
86395 net->ipv4.forw_hdr = forw_hdr;
86396 @@ -2164,8 +2167,7 @@ err_reg_ctl:
86397 err_reg_dflt:
86398 __devinet_sysctl_unregister(all);
86399 err_reg_all:
86400 - if (tbl != ctl_forward_entry)
86401 - kfree(tbl);
86402 + kfree(tbl);
86403 err_alloc_ctl:
86404 #endif
86405 if (dflt != &ipv4_devconf_dflt)
86406 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
86407 index 4cfe34d..a6ba66e 100644
86408 --- a/net/ipv4/esp4.c
86409 +++ b/net/ipv4/esp4.c
86410 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
86411 return;
86412
86413 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86414 - atomic_inc(&flow_cache_genid);
86415 + atomic_inc_unchecked(&flow_cache_genid);
86416 rt_genid_bump(net);
86417
86418 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
86419 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
86420 index eb4bb12..ee4ec7d 100644
86421 --- a/net/ipv4/fib_frontend.c
86422 +++ b/net/ipv4/fib_frontend.c
86423 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
86424 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86425 fib_sync_up(dev);
86426 #endif
86427 - atomic_inc(&net->ipv4.dev_addr_genid);
86428 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86429 rt_cache_flush(dev_net(dev));
86430 break;
86431 case NETDEV_DOWN:
86432 fib_del_ifaddr(ifa, NULL);
86433 - atomic_inc(&net->ipv4.dev_addr_genid);
86434 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86435 if (ifa->ifa_dev->ifa_list == NULL) {
86436 /* Last address was deleted from this interface.
86437 * Disable IP.
86438 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
86439 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86440 fib_sync_up(dev);
86441 #endif
86442 - atomic_inc(&net->ipv4.dev_addr_genid);
86443 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86444 rt_cache_flush(net);
86445 break;
86446 case NETDEV_DOWN:
86447 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
86448 index 8f6cb7a..34507f9 100644
86449 --- a/net/ipv4/fib_semantics.c
86450 +++ b/net/ipv4/fib_semantics.c
86451 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
86452 nh->nh_saddr = inet_select_addr(nh->nh_dev,
86453 nh->nh_gw,
86454 nh->nh_parent->fib_scope);
86455 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
86456 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
86457
86458 return nh->nh_saddr;
86459 }
86460 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
86461 index 786d97a..1889c0d 100644
86462 --- a/net/ipv4/inet_connection_sock.c
86463 +++ b/net/ipv4/inet_connection_sock.c
86464 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
86465 .range = { 32768, 61000 },
86466 };
86467
86468 -unsigned long *sysctl_local_reserved_ports;
86469 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
86470 EXPORT_SYMBOL(sysctl_local_reserved_ports);
86471
86472 void inet_get_local_port_range(int *low, int *high)
86473 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
86474 index 6af375a..c493c74 100644
86475 --- a/net/ipv4/inet_hashtables.c
86476 +++ b/net/ipv4/inet_hashtables.c
86477 @@ -18,12 +18,15 @@
86478 #include <linux/sched.h>
86479 #include <linux/slab.h>
86480 #include <linux/wait.h>
86481 +#include <linux/security.h>
86482
86483 #include <net/inet_connection_sock.h>
86484 #include <net/inet_hashtables.h>
86485 #include <net/secure_seq.h>
86486 #include <net/ip.h>
86487
86488 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
86489 +
86490 /*
86491 * Allocate and initialize a new local port bind bucket.
86492 * The bindhash mutex for snum's hash chain must be held here.
86493 @@ -554,6 +557,8 @@ ok:
86494 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
86495 spin_unlock(&head->lock);
86496
86497 + gr_update_task_in_ip_table(current, inet_sk(sk));
86498 +
86499 if (tw) {
86500 inet_twsk_deschedule(tw, death_row);
86501 while (twrefcnt) {
86502 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
86503 index 000e3d2..5472da3 100644
86504 --- a/net/ipv4/inetpeer.c
86505 +++ b/net/ipv4/inetpeer.c
86506 @@ -503,8 +503,8 @@ relookup:
86507 if (p) {
86508 p->daddr = *daddr;
86509 atomic_set(&p->refcnt, 1);
86510 - atomic_set(&p->rid, 0);
86511 - atomic_set(&p->ip_id_count,
86512 + atomic_set_unchecked(&p->rid, 0);
86513 + atomic_set_unchecked(&p->ip_id_count,
86514 (daddr->family == AF_INET) ?
86515 secure_ip_id(daddr->addr.a4) :
86516 secure_ipv6_id(daddr->addr.a6));
86517 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
86518 index 52c273e..579060b 100644
86519 --- a/net/ipv4/ip_fragment.c
86520 +++ b/net/ipv4/ip_fragment.c
86521 @@ -311,7 +311,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
86522 return 0;
86523
86524 start = qp->rid;
86525 - end = atomic_inc_return(&peer->rid);
86526 + end = atomic_inc_return_unchecked(&peer->rid);
86527 qp->rid = end;
86528
86529 rc = qp->q.fragments && (end - start) > max;
86530 @@ -788,12 +788,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
86531
86532 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86533 {
86534 - struct ctl_table *table;
86535 + ctl_table_no_const *table = NULL;
86536 struct ctl_table_header *hdr;
86537
86538 - table = ip4_frags_ns_ctl_table;
86539 if (!net_eq(net, &init_net)) {
86540 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86541 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86542 if (table == NULL)
86543 goto err_alloc;
86544
86545 @@ -804,9 +803,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86546 /* Don't export sysctls to unprivileged users */
86547 if (net->user_ns != &init_user_ns)
86548 table[0].procname = NULL;
86549 - }
86550 + hdr = register_net_sysctl(net, "net/ipv4", table);
86551 + } else
86552 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
86553
86554 - hdr = register_net_sysctl(net, "net/ipv4", table);
86555 if (hdr == NULL)
86556 goto err_reg;
86557
86558 @@ -814,8 +814,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86559 return 0;
86560
86561 err_reg:
86562 - if (!net_eq(net, &init_net))
86563 - kfree(table);
86564 + kfree(table);
86565 err_alloc:
86566 return -ENOMEM;
86567 }
86568 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
86569 index 91d66db..4af7d99 100644
86570 --- a/net/ipv4/ip_gre.c
86571 +++ b/net/ipv4/ip_gre.c
86572 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
86573 module_param(log_ecn_error, bool, 0644);
86574 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
86575
86576 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
86577 +static struct rtnl_link_ops ipgre_link_ops;
86578 static int ipgre_tunnel_init(struct net_device *dev);
86579 static void ipgre_tunnel_setup(struct net_device *dev);
86580 static int ipgre_tunnel_bind_dev(struct net_device *dev);
86581 @@ -1823,7 +1823,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
86582 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
86583 };
86584
86585 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86586 +static struct rtnl_link_ops ipgre_link_ops = {
86587 .kind = "gre",
86588 .maxtype = IFLA_GRE_MAX,
86589 .policy = ipgre_policy,
86590 @@ -1836,7 +1836,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86591 .fill_info = ipgre_fill_info,
86592 };
86593
86594 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
86595 +static struct rtnl_link_ops ipgre_tap_ops = {
86596 .kind = "gretap",
86597 .maxtype = IFLA_GRE_MAX,
86598 .policy = ipgre_policy,
86599 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
86600 index d9c4f11..02b82dbc 100644
86601 --- a/net/ipv4/ip_sockglue.c
86602 +++ b/net/ipv4/ip_sockglue.c
86603 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86604 len = min_t(unsigned int, len, opt->optlen);
86605 if (put_user(len, optlen))
86606 return -EFAULT;
86607 - if (copy_to_user(optval, opt->__data, len))
86608 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
86609 + copy_to_user(optval, opt->__data, len))
86610 return -EFAULT;
86611 return 0;
86612 }
86613 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86614 if (sk->sk_type != SOCK_STREAM)
86615 return -ENOPROTOOPT;
86616
86617 - msg.msg_control = optval;
86618 + msg.msg_control = (void __force_kernel *)optval;
86619 msg.msg_controllen = len;
86620 msg.msg_flags = flags;
86621
86622 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
86623 index c3a4233..1412161 100644
86624 --- a/net/ipv4/ip_vti.c
86625 +++ b/net/ipv4/ip_vti.c
86626 @@ -47,7 +47,7 @@
86627 #define HASH_SIZE 16
86628 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
86629
86630 -static struct rtnl_link_ops vti_link_ops __read_mostly;
86631 +static struct rtnl_link_ops vti_link_ops;
86632
86633 static int vti_net_id __read_mostly;
86634 struct vti_net {
86635 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
86636 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
86637 };
86638
86639 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
86640 +static struct rtnl_link_ops vti_link_ops = {
86641 .kind = "vti",
86642 .maxtype = IFLA_VTI_MAX,
86643 .policy = vti_policy,
86644 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
86645 index f01d1b1..8fe03ad 100644
86646 --- a/net/ipv4/ipcomp.c
86647 +++ b/net/ipv4/ipcomp.c
86648 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
86649 return;
86650
86651 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86652 - atomic_inc(&flow_cache_genid);
86653 + atomic_inc_unchecked(&flow_cache_genid);
86654 rt_genid_bump(net);
86655
86656 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
86657 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
86658 index bf6c5cf..ab2e9c6 100644
86659 --- a/net/ipv4/ipconfig.c
86660 +++ b/net/ipv4/ipconfig.c
86661 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
86662
86663 mm_segment_t oldfs = get_fs();
86664 set_fs(get_ds());
86665 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86666 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86667 set_fs(oldfs);
86668 return res;
86669 }
86670 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
86671
86672 mm_segment_t oldfs = get_fs();
86673 set_fs(get_ds());
86674 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86675 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86676 set_fs(oldfs);
86677 return res;
86678 }
86679 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
86680
86681 mm_segment_t oldfs = get_fs();
86682 set_fs(get_ds());
86683 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
86684 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
86685 set_fs(oldfs);
86686 return res;
86687 }
86688 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
86689 index 8f024d4..8b3500c 100644
86690 --- a/net/ipv4/ipip.c
86691 +++ b/net/ipv4/ipip.c
86692 @@ -138,7 +138,7 @@ struct ipip_net {
86693 static int ipip_tunnel_init(struct net_device *dev);
86694 static void ipip_tunnel_setup(struct net_device *dev);
86695 static void ipip_dev_free(struct net_device *dev);
86696 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
86697 +static struct rtnl_link_ops ipip_link_ops;
86698
86699 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
86700 struct rtnl_link_stats64 *tot)
86701 @@ -974,7 +974,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
86702 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
86703 };
86704
86705 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
86706 +static struct rtnl_link_ops ipip_link_ops = {
86707 .kind = "ipip",
86708 .maxtype = IFLA_IPTUN_MAX,
86709 .policy = ipip_policy,
86710 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
86711 index 7dc6a97..229c61b 100644
86712 --- a/net/ipv4/netfilter/arp_tables.c
86713 +++ b/net/ipv4/netfilter/arp_tables.c
86714 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
86715 #endif
86716
86717 static int get_info(struct net *net, void __user *user,
86718 - const int *len, int compat)
86719 + int len, int compat)
86720 {
86721 char name[XT_TABLE_MAXNAMELEN];
86722 struct xt_table *t;
86723 int ret;
86724
86725 - if (*len != sizeof(struct arpt_getinfo)) {
86726 - duprintf("length %u != %Zu\n", *len,
86727 + if (len != sizeof(struct arpt_getinfo)) {
86728 + duprintf("length %u != %Zu\n", len,
86729 sizeof(struct arpt_getinfo));
86730 return -EINVAL;
86731 }
86732 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
86733 info.size = private->size;
86734 strcpy(info.name, name);
86735
86736 - if (copy_to_user(user, &info, *len) != 0)
86737 + if (copy_to_user(user, &info, len) != 0)
86738 ret = -EFAULT;
86739 else
86740 ret = 0;
86741 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
86742
86743 switch (cmd) {
86744 case ARPT_SO_GET_INFO:
86745 - ret = get_info(sock_net(sk), user, len, 1);
86746 + ret = get_info(sock_net(sk), user, *len, 1);
86747 break;
86748 case ARPT_SO_GET_ENTRIES:
86749 ret = compat_get_entries(sock_net(sk), user, len);
86750 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
86751
86752 switch (cmd) {
86753 case ARPT_SO_GET_INFO:
86754 - ret = get_info(sock_net(sk), user, len, 0);
86755 + ret = get_info(sock_net(sk), user, *len, 0);
86756 break;
86757
86758 case ARPT_SO_GET_ENTRIES:
86759 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
86760 index 3efcf87..5247916 100644
86761 --- a/net/ipv4/netfilter/ip_tables.c
86762 +++ b/net/ipv4/netfilter/ip_tables.c
86763 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
86764 #endif
86765
86766 static int get_info(struct net *net, void __user *user,
86767 - const int *len, int compat)
86768 + int len, int compat)
86769 {
86770 char name[XT_TABLE_MAXNAMELEN];
86771 struct xt_table *t;
86772 int ret;
86773
86774 - if (*len != sizeof(struct ipt_getinfo)) {
86775 - duprintf("length %u != %zu\n", *len,
86776 + if (len != sizeof(struct ipt_getinfo)) {
86777 + duprintf("length %u != %zu\n", len,
86778 sizeof(struct ipt_getinfo));
86779 return -EINVAL;
86780 }
86781 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
86782 info.size = private->size;
86783 strcpy(info.name, name);
86784
86785 - if (copy_to_user(user, &info, *len) != 0)
86786 + if (copy_to_user(user, &info, len) != 0)
86787 ret = -EFAULT;
86788 else
86789 ret = 0;
86790 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86791
86792 switch (cmd) {
86793 case IPT_SO_GET_INFO:
86794 - ret = get_info(sock_net(sk), user, len, 1);
86795 + ret = get_info(sock_net(sk), user, *len, 1);
86796 break;
86797 case IPT_SO_GET_ENTRIES:
86798 ret = compat_get_entries(sock_net(sk), user, len);
86799 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86800
86801 switch (cmd) {
86802 case IPT_SO_GET_INFO:
86803 - ret = get_info(sock_net(sk), user, len, 0);
86804 + ret = get_info(sock_net(sk), user, *len, 0);
86805 break;
86806
86807 case IPT_SO_GET_ENTRIES:
86808 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
86809 index 2e91006..f084394 100644
86810 --- a/net/ipv4/ping.c
86811 +++ b/net/ipv4/ping.c
86812 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
86813 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
86814 0, sock_i_ino(sp),
86815 atomic_read(&sp->sk_refcnt), sp,
86816 - atomic_read(&sp->sk_drops), len);
86817 + atomic_read_unchecked(&sp->sk_drops), len);
86818 }
86819
86820 static int ping_seq_show(struct seq_file *seq, void *v)
86821 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
86822 index dd44e0a..06dcca4 100644
86823 --- a/net/ipv4/raw.c
86824 +++ b/net/ipv4/raw.c
86825 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
86826 int raw_rcv(struct sock *sk, struct sk_buff *skb)
86827 {
86828 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
86829 - atomic_inc(&sk->sk_drops);
86830 + atomic_inc_unchecked(&sk->sk_drops);
86831 kfree_skb(skb);
86832 return NET_RX_DROP;
86833 }
86834 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
86835
86836 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
86837 {
86838 + struct icmp_filter filter;
86839 +
86840 if (optlen > sizeof(struct icmp_filter))
86841 optlen = sizeof(struct icmp_filter);
86842 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
86843 + if (copy_from_user(&filter, optval, optlen))
86844 return -EFAULT;
86845 + raw_sk(sk)->filter = filter;
86846 return 0;
86847 }
86848
86849 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
86850 {
86851 int len, ret = -EFAULT;
86852 + struct icmp_filter filter;
86853
86854 if (get_user(len, optlen))
86855 goto out;
86856 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
86857 if (len > sizeof(struct icmp_filter))
86858 len = sizeof(struct icmp_filter);
86859 ret = -EFAULT;
86860 - if (put_user(len, optlen) ||
86861 - copy_to_user(optval, &raw_sk(sk)->filter, len))
86862 + filter = raw_sk(sk)->filter;
86863 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
86864 goto out;
86865 ret = 0;
86866 out: return ret;
86867 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
86868 0, 0L, 0,
86869 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
86870 0, sock_i_ino(sp),
86871 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
86872 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
86873 }
86874
86875 static int raw_seq_show(struct seq_file *seq, void *v)
86876 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
86877 index 6e28514..5e1b055 100644
86878 --- a/net/ipv4/route.c
86879 +++ b/net/ipv4/route.c
86880 @@ -2553,34 +2553,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
86881 .maxlen = sizeof(int),
86882 .mode = 0200,
86883 .proc_handler = ipv4_sysctl_rtcache_flush,
86884 + .extra1 = &init_net,
86885 },
86886 { },
86887 };
86888
86889 static __net_init int sysctl_route_net_init(struct net *net)
86890 {
86891 - struct ctl_table *tbl;
86892 + ctl_table_no_const *tbl = NULL;
86893
86894 - tbl = ipv4_route_flush_table;
86895 if (!net_eq(net, &init_net)) {
86896 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86897 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86898 if (tbl == NULL)
86899 goto err_dup;
86900
86901 /* Don't export sysctls to unprivileged users */
86902 if (net->user_ns != &init_user_ns)
86903 tbl[0].procname = NULL;
86904 - }
86905 - tbl[0].extra1 = net;
86906 + tbl[0].extra1 = net;
86907 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86908 + } else
86909 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
86910
86911 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86912 if (net->ipv4.route_hdr == NULL)
86913 goto err_reg;
86914 return 0;
86915
86916 err_reg:
86917 - if (tbl != ipv4_route_flush_table)
86918 - kfree(tbl);
86919 + kfree(tbl);
86920 err_dup:
86921 return -ENOMEM;
86922 }
86923 @@ -2603,7 +2603,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
86924
86925 static __net_init int rt_genid_init(struct net *net)
86926 {
86927 - atomic_set(&net->rt_genid, 0);
86928 + atomic_set_unchecked(&net->rt_genid, 0);
86929 get_random_bytes(&net->ipv4.dev_addr_genid,
86930 sizeof(net->ipv4.dev_addr_genid));
86931 return 0;
86932 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
86933 index 960fd29..d55bf64 100644
86934 --- a/net/ipv4/sysctl_net_ipv4.c
86935 +++ b/net/ipv4/sysctl_net_ipv4.c
86936 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
86937 {
86938 int ret;
86939 int range[2];
86940 - ctl_table tmp = {
86941 + ctl_table_no_const tmp = {
86942 .data = &range,
86943 .maxlen = sizeof(range),
86944 .mode = table->mode,
86945 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
86946 int ret;
86947 gid_t urange[2];
86948 kgid_t low, high;
86949 - ctl_table tmp = {
86950 + ctl_table_no_const tmp = {
86951 .data = &urange,
86952 .maxlen = sizeof(urange),
86953 .mode = table->mode,
86954 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
86955 void __user *buffer, size_t *lenp, loff_t *ppos)
86956 {
86957 char val[TCP_CA_NAME_MAX];
86958 - ctl_table tbl = {
86959 + ctl_table_no_const tbl = {
86960 .data = val,
86961 .maxlen = TCP_CA_NAME_MAX,
86962 };
86963 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
86964 void __user *buffer, size_t *lenp,
86965 loff_t *ppos)
86966 {
86967 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
86968 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
86969 int ret;
86970
86971 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86972 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
86973 void __user *buffer, size_t *lenp,
86974 loff_t *ppos)
86975 {
86976 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
86977 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
86978 int ret;
86979
86980 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86981 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86982 struct mem_cgroup *memcg;
86983 #endif
86984
86985 - ctl_table tmp = {
86986 + ctl_table_no_const tmp = {
86987 .data = &vec,
86988 .maxlen = sizeof(vec),
86989 .mode = ctl->mode,
86990 };
86991
86992 if (!write) {
86993 - ctl->data = &net->ipv4.sysctl_tcp_mem;
86994 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
86995 + ctl_table_no_const tcp_mem = *ctl;
86996 +
86997 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
86998 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
86999 }
87000
87001 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87002 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87003 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87004 size_t *lenp, loff_t *ppos)
87005 {
87006 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87007 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87008 struct tcp_fastopen_context *ctxt;
87009 int ret;
87010 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87011 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
87012 },
87013 {
87014 .procname = "ip_local_reserved_ports",
87015 - .data = NULL, /* initialized in sysctl_ipv4_init */
87016 + .data = sysctl_local_reserved_ports,
87017 .maxlen = 65536,
87018 .mode = 0644,
87019 .proc_handler = proc_do_large_bitmap,
87020 @@ -856,11 +858,10 @@ static struct ctl_table ipv4_net_table[] = {
87021
87022 static __net_init int ipv4_sysctl_init_net(struct net *net)
87023 {
87024 - struct ctl_table *table;
87025 + ctl_table_no_const *table = NULL;
87026
87027 - table = ipv4_net_table;
87028 if (!net_eq(net, &init_net)) {
87029 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87030 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87031 if (table == NULL)
87032 goto err_alloc;
87033
87034 @@ -895,15 +896,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87035
87036 tcp_init_mem(net);
87037
87038 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87039 + if (!net_eq(net, &init_net))
87040 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87041 + else
87042 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87043 if (net->ipv4.ipv4_hdr == NULL)
87044 goto err_reg;
87045
87046 return 0;
87047
87048 err_reg:
87049 - if (!net_eq(net, &init_net))
87050 - kfree(table);
87051 + kfree(table);
87052 err_alloc:
87053 return -ENOMEM;
87054 }
87055 @@ -925,16 +928,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87056 static __init int sysctl_ipv4_init(void)
87057 {
87058 struct ctl_table_header *hdr;
87059 - struct ctl_table *i;
87060 -
87061 - for (i = ipv4_table; i->procname; i++) {
87062 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87063 - i->data = sysctl_local_reserved_ports;
87064 - break;
87065 - }
87066 - }
87067 - if (!i->procname)
87068 - return -EINVAL;
87069
87070 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87071 if (hdr == NULL)
87072 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87073 index 13b9c08..d33a8d0 100644
87074 --- a/net/ipv4/tcp_input.c
87075 +++ b/net/ipv4/tcp_input.c
87076 @@ -4724,7 +4724,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87077 * simplifies code)
87078 */
87079 static void
87080 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87081 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87082 struct sk_buff *head, struct sk_buff *tail,
87083 u32 start, u32 end)
87084 {
87085 @@ -5838,6 +5838,7 @@ discard:
87086 tcp_paws_reject(&tp->rx_opt, 0))
87087 goto discard_and_undo;
87088
87089 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87090 if (th->syn) {
87091 /* We see SYN without ACK. It is attempt of
87092 * simultaneous connect with crossed SYNs.
87093 @@ -5888,6 +5889,7 @@ discard:
87094 goto discard;
87095 #endif
87096 }
87097 +#endif
87098 /* "fifth, if neither of the SYN or RST bits is set then
87099 * drop the segment and return."
87100 */
87101 @@ -5932,7 +5934,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87102 goto discard;
87103
87104 if (th->syn) {
87105 - if (th->fin)
87106 + if (th->fin || th->urg || th->psh)
87107 goto discard;
87108 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87109 return 1;
87110 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87111 index d09203c..fd5cc91 100644
87112 --- a/net/ipv4/tcp_ipv4.c
87113 +++ b/net/ipv4/tcp_ipv4.c
87114 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87115 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87116
87117
87118 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87119 +extern int grsec_enable_blackhole;
87120 +#endif
87121 +
87122 #ifdef CONFIG_TCP_MD5SIG
87123 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87124 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87125 @@ -1897,6 +1901,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87126 return 0;
87127
87128 reset:
87129 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87130 + if (!grsec_enable_blackhole)
87131 +#endif
87132 tcp_v4_send_reset(rsk, skb);
87133 discard:
87134 kfree_skb(skb);
87135 @@ -1996,12 +2003,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87136 TCP_SKB_CB(skb)->sacked = 0;
87137
87138 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87139 - if (!sk)
87140 + if (!sk) {
87141 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87142 + ret = 1;
87143 +#endif
87144 goto no_tcp_socket;
87145 -
87146 + }
87147 process:
87148 - if (sk->sk_state == TCP_TIME_WAIT)
87149 + if (sk->sk_state == TCP_TIME_WAIT) {
87150 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87151 + ret = 2;
87152 +#endif
87153 goto do_time_wait;
87154 + }
87155
87156 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87157 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87158 @@ -2052,6 +2066,10 @@ no_tcp_socket:
87159 bad_packet:
87160 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87161 } else {
87162 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87163 + if (!grsec_enable_blackhole || (ret == 1 &&
87164 + (skb->dev->flags & IFF_LOOPBACK)))
87165 +#endif
87166 tcp_v4_send_reset(NULL, skb);
87167 }
87168
87169 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87170 index 2f672e7..b8895e9 100644
87171 --- a/net/ipv4/tcp_minisocks.c
87172 +++ b/net/ipv4/tcp_minisocks.c
87173 @@ -27,6 +27,10 @@
87174 #include <net/inet_common.h>
87175 #include <net/xfrm.h>
87176
87177 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87178 +extern int grsec_enable_blackhole;
87179 +#endif
87180 +
87181 int sysctl_tcp_syncookies __read_mostly = 1;
87182 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87183
87184 @@ -749,7 +753,10 @@ embryonic_reset:
87185 * avoid becoming vulnerable to outside attack aiming at
87186 * resetting legit local connections.
87187 */
87188 - req->rsk_ops->send_reset(sk, skb);
87189 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87190 + if (!grsec_enable_blackhole)
87191 +#endif
87192 + req->rsk_ops->send_reset(sk, skb);
87193 } else if (fastopen) { /* received a valid RST pkt */
87194 reqsk_fastopen_remove(sk, req, true);
87195 tcp_reset(sk);
87196 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87197 index d4943f6..e7a74a5 100644
87198 --- a/net/ipv4/tcp_probe.c
87199 +++ b/net/ipv4/tcp_probe.c
87200 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87201 if (cnt + width >= len)
87202 break;
87203
87204 - if (copy_to_user(buf + cnt, tbuf, width))
87205 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87206 return -EFAULT;
87207 cnt += width;
87208 }
87209 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87210 index b78aac3..e18230b 100644
87211 --- a/net/ipv4/tcp_timer.c
87212 +++ b/net/ipv4/tcp_timer.c
87213 @@ -22,6 +22,10 @@
87214 #include <linux/gfp.h>
87215 #include <net/tcp.h>
87216
87217 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87218 +extern int grsec_lastack_retries;
87219 +#endif
87220 +
87221 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87222 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87223 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87224 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87225 }
87226 }
87227
87228 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87229 + if ((sk->sk_state == TCP_LAST_ACK) &&
87230 + (grsec_lastack_retries > 0) &&
87231 + (grsec_lastack_retries < retry_until))
87232 + retry_until = grsec_lastack_retries;
87233 +#endif
87234 +
87235 if (retransmits_timed_out(sk, retry_until,
87236 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87237 /* Has it gone just too far? */
87238 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87239 index 0a073a2..ddf6279 100644
87240 --- a/net/ipv4/udp.c
87241 +++ b/net/ipv4/udp.c
87242 @@ -87,6 +87,7 @@
87243 #include <linux/types.h>
87244 #include <linux/fcntl.h>
87245 #include <linux/module.h>
87246 +#include <linux/security.h>
87247 #include <linux/socket.h>
87248 #include <linux/sockios.h>
87249 #include <linux/igmp.h>
87250 @@ -111,6 +112,10 @@
87251 #include <trace/events/skb.h>
87252 #include "udp_impl.h"
87253
87254 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87255 +extern int grsec_enable_blackhole;
87256 +#endif
87257 +
87258 struct udp_table udp_table __read_mostly;
87259 EXPORT_SYMBOL(udp_table);
87260
87261 @@ -594,6 +599,9 @@ found:
87262 return s;
87263 }
87264
87265 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87266 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87267 +
87268 /*
87269 * This routine is called by the ICMP module when it gets some
87270 * sort of error condition. If err < 0 then the socket should
87271 @@ -889,9 +897,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87272 dport = usin->sin_port;
87273 if (dport == 0)
87274 return -EINVAL;
87275 +
87276 + err = gr_search_udp_sendmsg(sk, usin);
87277 + if (err)
87278 + return err;
87279 } else {
87280 if (sk->sk_state != TCP_ESTABLISHED)
87281 return -EDESTADDRREQ;
87282 +
87283 + err = gr_search_udp_sendmsg(sk, NULL);
87284 + if (err)
87285 + return err;
87286 +
87287 daddr = inet->inet_daddr;
87288 dport = inet->inet_dport;
87289 /* Open fast path for connected socket.
87290 @@ -1133,7 +1150,7 @@ static unsigned int first_packet_length(struct sock *sk)
87291 udp_lib_checksum_complete(skb)) {
87292 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87293 IS_UDPLITE(sk));
87294 - atomic_inc(&sk->sk_drops);
87295 + atomic_inc_unchecked(&sk->sk_drops);
87296 __skb_unlink(skb, rcvq);
87297 __skb_queue_tail(&list_kill, skb);
87298 }
87299 @@ -1219,6 +1236,10 @@ try_again:
87300 if (!skb)
87301 goto out;
87302
87303 + err = gr_search_udp_recvmsg(sk, skb);
87304 + if (err)
87305 + goto out_free;
87306 +
87307 ulen = skb->len - sizeof(struct udphdr);
87308 copied = len;
87309 if (copied > ulen)
87310 @@ -1252,7 +1273,7 @@ try_again:
87311 if (unlikely(err)) {
87312 trace_kfree_skb(skb, udp_recvmsg);
87313 if (!peeked) {
87314 - atomic_inc(&sk->sk_drops);
87315 + atomic_inc_unchecked(&sk->sk_drops);
87316 UDP_INC_STATS_USER(sock_net(sk),
87317 UDP_MIB_INERRORS, is_udplite);
87318 }
87319 @@ -1535,7 +1556,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87320
87321 drop:
87322 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87323 - atomic_inc(&sk->sk_drops);
87324 + atomic_inc_unchecked(&sk->sk_drops);
87325 kfree_skb(skb);
87326 return -1;
87327 }
87328 @@ -1554,7 +1575,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87329 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87330
87331 if (!skb1) {
87332 - atomic_inc(&sk->sk_drops);
87333 + atomic_inc_unchecked(&sk->sk_drops);
87334 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87335 IS_UDPLITE(sk));
87336 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87337 @@ -1723,6 +1744,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87338 goto csum_error;
87339
87340 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87341 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87342 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87343 +#endif
87344 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87345
87346 /*
87347 @@ -2152,7 +2176,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87348 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87349 0, sock_i_ino(sp),
87350 atomic_read(&sp->sk_refcnt), sp,
87351 - atomic_read(&sp->sk_drops), len);
87352 + atomic_read_unchecked(&sp->sk_drops), len);
87353 }
87354
87355 int udp4_seq_show(struct seq_file *seq, void *v)
87356 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
87357 index 9a459be..086b866 100644
87358 --- a/net/ipv4/xfrm4_policy.c
87359 +++ b/net/ipv4/xfrm4_policy.c
87360 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
87361
87362 static int __net_init xfrm4_net_init(struct net *net)
87363 {
87364 - struct ctl_table *table;
87365 + ctl_table_no_const *table = NULL;
87366 struct ctl_table_header *hdr;
87367
87368 - table = xfrm4_policy_table;
87369 if (!net_eq(net, &init_net)) {
87370 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
87371 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
87372 if (!table)
87373 goto err_alloc;
87374
87375 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
87376 - }
87377 -
87378 - hdr = register_net_sysctl(net, "net/ipv4", table);
87379 + hdr = register_net_sysctl(net, "net/ipv4", table);
87380 + } else
87381 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
87382 if (!hdr)
87383 goto err_reg;
87384
87385 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
87386 return 0;
87387
87388 err_reg:
87389 - if (!net_eq(net, &init_net))
87390 - kfree(table);
87391 + kfree(table);
87392 err_alloc:
87393 return -ENOMEM;
87394 }
87395 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
87396 index dae802c..bfa4baa 100644
87397 --- a/net/ipv6/addrconf.c
87398 +++ b/net/ipv6/addrconf.c
87399 @@ -2274,7 +2274,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
87400 p.iph.ihl = 5;
87401 p.iph.protocol = IPPROTO_IPV6;
87402 p.iph.ttl = 64;
87403 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
87404 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
87405
87406 if (ops->ndo_do_ioctl) {
87407 mm_segment_t oldfs = get_fs();
87408 @@ -4410,7 +4410,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
87409 int *valp = ctl->data;
87410 int val = *valp;
87411 loff_t pos = *ppos;
87412 - ctl_table lctl;
87413 + ctl_table_no_const lctl;
87414 int ret;
87415
87416 /*
87417 @@ -4492,7 +4492,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
87418 int *valp = ctl->data;
87419 int val = *valp;
87420 loff_t pos = *ppos;
87421 - ctl_table lctl;
87422 + ctl_table_no_const lctl;
87423 int ret;
87424
87425 /*
87426 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
87427 index fff5bdd..15194fb 100644
87428 --- a/net/ipv6/icmp.c
87429 +++ b/net/ipv6/icmp.c
87430 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
87431
87432 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
87433 {
87434 - struct ctl_table *table;
87435 + ctl_table_no_const *table;
87436
87437 table = kmemdup(ipv6_icmp_table_template,
87438 sizeof(ipv6_icmp_table_template),
87439 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
87440 index 95d13c7..791fe2f 100644
87441 --- a/net/ipv6/ip6_gre.c
87442 +++ b/net/ipv6/ip6_gre.c
87443 @@ -73,7 +73,7 @@ struct ip6gre_net {
87444 struct net_device *fb_tunnel_dev;
87445 };
87446
87447 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
87448 +static struct rtnl_link_ops ip6gre_link_ops;
87449 static int ip6gre_tunnel_init(struct net_device *dev);
87450 static void ip6gre_tunnel_setup(struct net_device *dev);
87451 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
87452 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
87453 }
87454
87455
87456 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
87457 +static struct inet6_protocol ip6gre_protocol = {
87458 .handler = ip6gre_rcv,
87459 .err_handler = ip6gre_err,
87460 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
87461 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
87462 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
87463 };
87464
87465 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87466 +static struct rtnl_link_ops ip6gre_link_ops = {
87467 .kind = "ip6gre",
87468 .maxtype = IFLA_GRE_MAX,
87469 .policy = ip6gre_policy,
87470 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87471 .fill_info = ip6gre_fill_info,
87472 };
87473
87474 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
87475 +static struct rtnl_link_ops ip6gre_tap_ops = {
87476 .kind = "ip6gretap",
87477 .maxtype = IFLA_GRE_MAX,
87478 .policy = ip6gre_policy,
87479 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
87480 index fff83cb..82d49dd 100644
87481 --- a/net/ipv6/ip6_tunnel.c
87482 +++ b/net/ipv6/ip6_tunnel.c
87483 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87484
87485 static int ip6_tnl_dev_init(struct net_device *dev);
87486 static void ip6_tnl_dev_setup(struct net_device *dev);
87487 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
87488 +static struct rtnl_link_ops ip6_link_ops;
87489
87490 static int ip6_tnl_net_id __read_mostly;
87491 struct ip6_tnl_net {
87492 @@ -1684,7 +1684,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
87493 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
87494 };
87495
87496 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
87497 +static struct rtnl_link_ops ip6_link_ops = {
87498 .kind = "ip6tnl",
87499 .maxtype = IFLA_IPTUN_MAX,
87500 .policy = ip6_tnl_policy,
87501 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
87502 index d1e2e8e..51c19ae 100644
87503 --- a/net/ipv6/ipv6_sockglue.c
87504 +++ b/net/ipv6/ipv6_sockglue.c
87505 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
87506 if (sk->sk_type != SOCK_STREAM)
87507 return -ENOPROTOOPT;
87508
87509 - msg.msg_control = optval;
87510 + msg.msg_control = (void __force_kernel *)optval;
87511 msg.msg_controllen = len;
87512 msg.msg_flags = flags;
87513
87514 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
87515 index 341b54a..591e8ed 100644
87516 --- a/net/ipv6/netfilter/ip6_tables.c
87517 +++ b/net/ipv6/netfilter/ip6_tables.c
87518 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
87519 #endif
87520
87521 static int get_info(struct net *net, void __user *user,
87522 - const int *len, int compat)
87523 + int len, int compat)
87524 {
87525 char name[XT_TABLE_MAXNAMELEN];
87526 struct xt_table *t;
87527 int ret;
87528
87529 - if (*len != sizeof(struct ip6t_getinfo)) {
87530 - duprintf("length %u != %zu\n", *len,
87531 + if (len != sizeof(struct ip6t_getinfo)) {
87532 + duprintf("length %u != %zu\n", len,
87533 sizeof(struct ip6t_getinfo));
87534 return -EINVAL;
87535 }
87536 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
87537 info.size = private->size;
87538 strcpy(info.name, name);
87539
87540 - if (copy_to_user(user, &info, *len) != 0)
87541 + if (copy_to_user(user, &info, len) != 0)
87542 ret = -EFAULT;
87543 else
87544 ret = 0;
87545 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87546
87547 switch (cmd) {
87548 case IP6T_SO_GET_INFO:
87549 - ret = get_info(sock_net(sk), user, len, 1);
87550 + ret = get_info(sock_net(sk), user, *len, 1);
87551 break;
87552 case IP6T_SO_GET_ENTRIES:
87553 ret = compat_get_entries(sock_net(sk), user, len);
87554 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87555
87556 switch (cmd) {
87557 case IP6T_SO_GET_INFO:
87558 - ret = get_info(sock_net(sk), user, len, 0);
87559 + ret = get_info(sock_net(sk), user, *len, 0);
87560 break;
87561
87562 case IP6T_SO_GET_ENTRIES:
87563 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
87564 index 6700069..1e50f42 100644
87565 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
87566 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
87567 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
87568
87569 static int nf_ct_frag6_sysctl_register(struct net *net)
87570 {
87571 - struct ctl_table *table;
87572 + ctl_table_no_const *table = NULL;
87573 struct ctl_table_header *hdr;
87574
87575 - table = nf_ct_frag6_sysctl_table;
87576 if (!net_eq(net, &init_net)) {
87577 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
87578 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
87579 GFP_KERNEL);
87580 if (table == NULL)
87581 goto err_alloc;
87582 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87583 table[0].data = &net->nf_frag.frags.timeout;
87584 table[1].data = &net->nf_frag.frags.low_thresh;
87585 table[2].data = &net->nf_frag.frags.high_thresh;
87586 - }
87587 -
87588 - hdr = register_net_sysctl(net, "net/netfilter", table);
87589 + hdr = register_net_sysctl(net, "net/netfilter", table);
87590 + } else
87591 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
87592 if (hdr == NULL)
87593 goto err_reg;
87594
87595 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87596 return 0;
87597
87598 err_reg:
87599 - if (!net_eq(net, &init_net))
87600 - kfree(table);
87601 + kfree(table);
87602 err_alloc:
87603 return -ENOMEM;
87604 }
87605 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
87606 index 330b5e7..796fbf1 100644
87607 --- a/net/ipv6/raw.c
87608 +++ b/net/ipv6/raw.c
87609 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
87610 {
87611 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
87612 skb_checksum_complete(skb)) {
87613 - atomic_inc(&sk->sk_drops);
87614 + atomic_inc_unchecked(&sk->sk_drops);
87615 kfree_skb(skb);
87616 return NET_RX_DROP;
87617 }
87618 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87619 struct raw6_sock *rp = raw6_sk(sk);
87620
87621 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
87622 - atomic_inc(&sk->sk_drops);
87623 + atomic_inc_unchecked(&sk->sk_drops);
87624 kfree_skb(skb);
87625 return NET_RX_DROP;
87626 }
87627 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87628
87629 if (inet->hdrincl) {
87630 if (skb_checksum_complete(skb)) {
87631 - atomic_inc(&sk->sk_drops);
87632 + atomic_inc_unchecked(&sk->sk_drops);
87633 kfree_skb(skb);
87634 return NET_RX_DROP;
87635 }
87636 @@ -603,7 +603,7 @@ out:
87637 return err;
87638 }
87639
87640 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
87641 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
87642 struct flowi6 *fl6, struct dst_entry **dstp,
87643 unsigned int flags)
87644 {
87645 @@ -915,12 +915,15 @@ do_confirm:
87646 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
87647 char __user *optval, int optlen)
87648 {
87649 + struct icmp6_filter filter;
87650 +
87651 switch (optname) {
87652 case ICMPV6_FILTER:
87653 if (optlen > sizeof(struct icmp6_filter))
87654 optlen = sizeof(struct icmp6_filter);
87655 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
87656 + if (copy_from_user(&filter, optval, optlen))
87657 return -EFAULT;
87658 + raw6_sk(sk)->filter = filter;
87659 return 0;
87660 default:
87661 return -ENOPROTOOPT;
87662 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87663 char __user *optval, int __user *optlen)
87664 {
87665 int len;
87666 + struct icmp6_filter filter;
87667
87668 switch (optname) {
87669 case ICMPV6_FILTER:
87670 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87671 len = sizeof(struct icmp6_filter);
87672 if (put_user(len, optlen))
87673 return -EFAULT;
87674 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
87675 + filter = raw6_sk(sk)->filter;
87676 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
87677 return -EFAULT;
87678 return 0;
87679 default:
87680 @@ -1252,7 +1257,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87681 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87682 0,
87683 sock_i_ino(sp),
87684 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87685 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87686 }
87687
87688 static int raw6_seq_show(struct seq_file *seq, void *v)
87689 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
87690 index 0ba10e5..c14a4f6 100644
87691 --- a/net/ipv6/reassembly.c
87692 +++ b/net/ipv6/reassembly.c
87693 @@ -602,12 +602,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
87694
87695 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87696 {
87697 - struct ctl_table *table;
87698 + ctl_table_no_const *table = NULL;
87699 struct ctl_table_header *hdr;
87700
87701 - table = ip6_frags_ns_ctl_table;
87702 if (!net_eq(net, &init_net)) {
87703 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87704 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87705 if (table == NULL)
87706 goto err_alloc;
87707
87708 @@ -618,9 +617,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87709 /* Don't export sysctls to unprivileged users */
87710 if (net->user_ns != &init_user_ns)
87711 table[0].procname = NULL;
87712 - }
87713 + hdr = register_net_sysctl(net, "net/ipv6", table);
87714 + } else
87715 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
87716
87717 - hdr = register_net_sysctl(net, "net/ipv6", table);
87718 if (hdr == NULL)
87719 goto err_reg;
87720
87721 @@ -628,8 +628,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87722 return 0;
87723
87724 err_reg:
87725 - if (!net_eq(net, &init_net))
87726 - kfree(table);
87727 + kfree(table);
87728 err_alloc:
87729 return -ENOMEM;
87730 }
87731 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
87732 index e5fe004..9fe3e8e 100644
87733 --- a/net/ipv6/route.c
87734 +++ b/net/ipv6/route.c
87735 @@ -2881,7 +2881,7 @@ ctl_table ipv6_route_table_template[] = {
87736
87737 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
87738 {
87739 - struct ctl_table *table;
87740 + ctl_table_no_const *table;
87741
87742 table = kmemdup(ipv6_route_table_template,
87743 sizeof(ipv6_route_table_template),
87744 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
87745 index 02f96dc..4a5a6e5 100644
87746 --- a/net/ipv6/sit.c
87747 +++ b/net/ipv6/sit.c
87748 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
87749 static void ipip6_dev_free(struct net_device *dev);
87750 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
87751 __be32 *v4dst);
87752 -static struct rtnl_link_ops sit_link_ops __read_mostly;
87753 +static struct rtnl_link_ops sit_link_ops;
87754
87755 static int sit_net_id __read_mostly;
87756 struct sit_net {
87757 @@ -1486,7 +1486,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
87758 #endif
87759 };
87760
87761 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
87762 +static struct rtnl_link_ops sit_link_ops = {
87763 .kind = "sit",
87764 .maxtype = IFLA_IPTUN_MAX,
87765 .policy = ipip6_policy,
87766 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
87767 index e85c48b..b8268d3 100644
87768 --- a/net/ipv6/sysctl_net_ipv6.c
87769 +++ b/net/ipv6/sysctl_net_ipv6.c
87770 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
87771
87772 static int __net_init ipv6_sysctl_net_init(struct net *net)
87773 {
87774 - struct ctl_table *ipv6_table;
87775 + ctl_table_no_const *ipv6_table;
87776 struct ctl_table *ipv6_route_table;
87777 struct ctl_table *ipv6_icmp_table;
87778 int err;
87779 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
87780 index 0fce928..c52a518 100644
87781 --- a/net/ipv6/tcp_ipv6.c
87782 +++ b/net/ipv6/tcp_ipv6.c
87783 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
87784 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
87785 }
87786
87787 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87788 +extern int grsec_enable_blackhole;
87789 +#endif
87790 +
87791 static void tcp_v6_hash(struct sock *sk)
87792 {
87793 if (sk->sk_state != TCP_CLOSE) {
87794 @@ -1446,6 +1450,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
87795 return 0;
87796
87797 reset:
87798 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87799 + if (!grsec_enable_blackhole)
87800 +#endif
87801 tcp_v6_send_reset(sk, skb);
87802 discard:
87803 if (opt_skb)
87804 @@ -1527,12 +1534,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
87805 TCP_SKB_CB(skb)->sacked = 0;
87806
87807 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87808 - if (!sk)
87809 + if (!sk) {
87810 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87811 + ret = 1;
87812 +#endif
87813 goto no_tcp_socket;
87814 + }
87815
87816 process:
87817 - if (sk->sk_state == TCP_TIME_WAIT)
87818 + if (sk->sk_state == TCP_TIME_WAIT) {
87819 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87820 + ret = 2;
87821 +#endif
87822 goto do_time_wait;
87823 + }
87824
87825 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
87826 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87827 @@ -1581,6 +1596,10 @@ no_tcp_socket:
87828 bad_packet:
87829 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87830 } else {
87831 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87832 + if (!grsec_enable_blackhole || (ret == 1 &&
87833 + (skb->dev->flags & IFF_LOOPBACK)))
87834 +#endif
87835 tcp_v6_send_reset(NULL, skb);
87836 }
87837
87838 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
87839 index 27f0f8e..949e7ee 100644
87840 --- a/net/ipv6/udp.c
87841 +++ b/net/ipv6/udp.c
87842 @@ -52,6 +52,10 @@
87843 #include <trace/events/skb.h>
87844 #include "udp_impl.h"
87845
87846 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87847 +extern int grsec_enable_blackhole;
87848 +#endif
87849 +
87850 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
87851 {
87852 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
87853 @@ -419,7 +423,7 @@ try_again:
87854 if (unlikely(err)) {
87855 trace_kfree_skb(skb, udpv6_recvmsg);
87856 if (!peeked) {
87857 - atomic_inc(&sk->sk_drops);
87858 + atomic_inc_unchecked(&sk->sk_drops);
87859 if (is_udp4)
87860 UDP_INC_STATS_USER(sock_net(sk),
87861 UDP_MIB_INERRORS,
87862 @@ -657,7 +661,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87863 return rc;
87864 drop:
87865 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87866 - atomic_inc(&sk->sk_drops);
87867 + atomic_inc_unchecked(&sk->sk_drops);
87868 kfree_skb(skb);
87869 return -1;
87870 }
87871 @@ -715,7 +719,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87872 if (likely(skb1 == NULL))
87873 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87874 if (!skb1) {
87875 - atomic_inc(&sk->sk_drops);
87876 + atomic_inc_unchecked(&sk->sk_drops);
87877 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87878 IS_UDPLITE(sk));
87879 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87880 @@ -852,6 +856,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87881 goto discard;
87882
87883 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87884 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87885 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87886 +#endif
87887 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
87888
87889 kfree_skb(skb);
87890 @@ -1377,7 +1384,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
87891 0,
87892 sock_i_ino(sp),
87893 atomic_read(&sp->sk_refcnt), sp,
87894 - atomic_read(&sp->sk_drops));
87895 + atomic_read_unchecked(&sp->sk_drops));
87896 }
87897
87898 int udp6_seq_show(struct seq_file *seq, void *v)
87899 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
87900 index 23ed03d..465a71d 100644
87901 --- a/net/ipv6/xfrm6_policy.c
87902 +++ b/net/ipv6/xfrm6_policy.c
87903 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
87904
87905 static int __net_init xfrm6_net_init(struct net *net)
87906 {
87907 - struct ctl_table *table;
87908 + ctl_table_no_const *table = NULL;
87909 struct ctl_table_header *hdr;
87910
87911 - table = xfrm6_policy_table;
87912 if (!net_eq(net, &init_net)) {
87913 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
87914 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
87915 if (!table)
87916 goto err_alloc;
87917
87918 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
87919 - }
87920 + hdr = register_net_sysctl(net, "net/ipv6", table);
87921 + } else
87922 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
87923
87924 - hdr = register_net_sysctl(net, "net/ipv6", table);
87925 if (!hdr)
87926 goto err_reg;
87927
87928 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
87929 return 0;
87930
87931 err_reg:
87932 - if (!net_eq(net, &init_net))
87933 - kfree(table);
87934 + kfree(table);
87935 err_alloc:
87936 return -ENOMEM;
87937 }
87938 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
87939 index 362ba47..66196f4 100644
87940 --- a/net/irda/ircomm/ircomm_tty.c
87941 +++ b/net/irda/ircomm/ircomm_tty.c
87942 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87943 add_wait_queue(&port->open_wait, &wait);
87944
87945 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
87946 - __FILE__, __LINE__, tty->driver->name, port->count);
87947 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87948
87949 spin_lock_irqsave(&port->lock, flags);
87950 if (!tty_hung_up_p(filp))
87951 - port->count--;
87952 + atomic_dec(&port->count);
87953 port->blocked_open++;
87954 spin_unlock_irqrestore(&port->lock, flags);
87955
87956 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87957 }
87958
87959 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
87960 - __FILE__, __LINE__, tty->driver->name, port->count);
87961 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87962
87963 schedule();
87964 }
87965 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87966
87967 spin_lock_irqsave(&port->lock, flags);
87968 if (!tty_hung_up_p(filp))
87969 - port->count++;
87970 + atomic_inc(&port->count);
87971 port->blocked_open--;
87972 spin_unlock_irqrestore(&port->lock, flags);
87973
87974 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
87975 - __FILE__, __LINE__, tty->driver->name, port->count);
87976 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87977
87978 if (!retval)
87979 port->flags |= ASYNC_NORMAL_ACTIVE;
87980 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
87981
87982 /* ++ is not atomic, so this should be protected - Jean II */
87983 spin_lock_irqsave(&self->port.lock, flags);
87984 - self->port.count++;
87985 + atomic_inc(&self->port.count);
87986 spin_unlock_irqrestore(&self->port.lock, flags);
87987 tty_port_tty_set(&self->port, tty);
87988
87989 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
87990 - self->line, self->port.count);
87991 + self->line, atomic_read(&self->port.count));
87992
87993 /* Not really used by us, but lets do it anyway */
87994 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
87995 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
87996 tty_kref_put(port->tty);
87997 }
87998 port->tty = NULL;
87999 - port->count = 0;
88000 + atomic_set(&port->count, 0);
88001 spin_unlock_irqrestore(&port->lock, flags);
88002
88003 wake_up_interruptible(&port->open_wait);
88004 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88005 seq_putc(m, '\n');
88006
88007 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88008 - seq_printf(m, "Open count: %d\n", self->port.count);
88009 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88010 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88011 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88012
88013 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88014 index 206ce6d..cfb27cd 100644
88015 --- a/net/iucv/af_iucv.c
88016 +++ b/net/iucv/af_iucv.c
88017 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
88018
88019 write_lock_bh(&iucv_sk_list.lock);
88020
88021 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88022 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88023 while (__iucv_get_sock_by_name(name)) {
88024 sprintf(name, "%08x",
88025 - atomic_inc_return(&iucv_sk_list.autobind_name));
88026 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88027 }
88028
88029 write_unlock_bh(&iucv_sk_list.lock);
88030 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88031 index 4fe76ff..426a904 100644
88032 --- a/net/iucv/iucv.c
88033 +++ b/net/iucv/iucv.c
88034 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88035 return NOTIFY_OK;
88036 }
88037
88038 -static struct notifier_block __refdata iucv_cpu_notifier = {
88039 +static struct notifier_block iucv_cpu_notifier = {
88040 .notifier_call = iucv_cpu_notify,
88041 };
88042
88043 diff --git a/net/key/af_key.c b/net/key/af_key.c
88044 index 5b1e5af..2358147 100644
88045 --- a/net/key/af_key.c
88046 +++ b/net/key/af_key.c
88047 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88048 static u32 get_acqseq(void)
88049 {
88050 u32 res;
88051 - static atomic_t acqseq;
88052 + static atomic_unchecked_t acqseq;
88053
88054 do {
88055 - res = atomic_inc_return(&acqseq);
88056 + res = atomic_inc_return_unchecked(&acqseq);
88057 } while (!res);
88058 return res;
88059 }
88060 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88061 index 843d8c4..cb04fa1 100644
88062 --- a/net/mac80211/cfg.c
88063 +++ b/net/mac80211/cfg.c
88064 @@ -799,7 +799,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88065 ret = ieee80211_vif_use_channel(sdata, chandef,
88066 IEEE80211_CHANCTX_EXCLUSIVE);
88067 }
88068 - } else if (local->open_count == local->monitors) {
88069 + } else if (local_read(&local->open_count) == local->monitors) {
88070 local->_oper_channel = chandef->chan;
88071 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88072 ieee80211_hw_config(local, 0);
88073 @@ -2834,7 +2834,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88074 else
88075 local->probe_req_reg--;
88076
88077 - if (!local->open_count)
88078 + if (!local_read(&local->open_count))
88079 break;
88080
88081 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88082 @@ -3297,8 +3297,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
88083 if (chanctx_conf) {
88084 *chandef = chanctx_conf->def;
88085 ret = 0;
88086 - } else if (local->open_count > 0 &&
88087 - local->open_count == local->monitors &&
88088 + } else if (local_read(&local->open_count) > 0 &&
88089 + local_read(&local->open_count) == local->monitors &&
88090 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
88091 if (local->use_chanctx)
88092 *chandef = local->monitor_chandef;
88093 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88094 index 5672533..6738c93 100644
88095 --- a/net/mac80211/ieee80211_i.h
88096 +++ b/net/mac80211/ieee80211_i.h
88097 @@ -28,6 +28,7 @@
88098 #include <net/ieee80211_radiotap.h>
88099 #include <net/cfg80211.h>
88100 #include <net/mac80211.h>
88101 +#include <asm/local.h>
88102 #include "key.h"
88103 #include "sta_info.h"
88104 #include "debug.h"
88105 @@ -897,7 +898,7 @@ struct ieee80211_local {
88106 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88107 spinlock_t queue_stop_reason_lock;
88108
88109 - int open_count;
88110 + local_t open_count;
88111 int monitors, cooked_mntrs;
88112 /* number of interfaces with corresponding FIF_ flags */
88113 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88114 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88115 index d51ca9d..042c35f 100644
88116 --- a/net/mac80211/iface.c
88117 +++ b/net/mac80211/iface.c
88118 @@ -495,7 +495,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88119 break;
88120 }
88121
88122 - if (local->open_count == 0) {
88123 + if (local_read(&local->open_count) == 0) {
88124 res = drv_start(local);
88125 if (res)
88126 goto err_del_bss;
88127 @@ -540,7 +540,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88128 break;
88129 }
88130
88131 - if (local->monitors == 0 && local->open_count == 0) {
88132 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88133 res = ieee80211_add_virtual_monitor(local);
88134 if (res)
88135 goto err_stop;
88136 @@ -649,7 +649,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88137 atomic_inc(&local->iff_promiscs);
88138
88139 if (coming_up)
88140 - local->open_count++;
88141 + local_inc(&local->open_count);
88142
88143 if (hw_reconf_flags)
88144 ieee80211_hw_config(local, hw_reconf_flags);
88145 @@ -663,7 +663,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88146 err_del_interface:
88147 drv_remove_interface(local, sdata);
88148 err_stop:
88149 - if (!local->open_count)
88150 + if (!local_read(&local->open_count))
88151 drv_stop(local);
88152 err_del_bss:
88153 sdata->bss = NULL;
88154 @@ -806,7 +806,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88155 }
88156
88157 if (going_down)
88158 - local->open_count--;
88159 + local_dec(&local->open_count);
88160
88161 switch (sdata->vif.type) {
88162 case NL80211_IFTYPE_AP_VLAN:
88163 @@ -871,7 +871,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88164
88165 ieee80211_recalc_ps(local, -1);
88166
88167 - if (local->open_count == 0) {
88168 + if (local_read(&local->open_count) == 0) {
88169 if (local->ops->napi_poll)
88170 napi_disable(&local->napi);
88171 ieee80211_clear_tx_pending(local);
88172 @@ -897,7 +897,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88173 }
88174 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88175
88176 - if (local->monitors == local->open_count && local->monitors > 0)
88177 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88178 ieee80211_add_virtual_monitor(local);
88179 }
88180
88181 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88182 index 1a8591b..ef5db54 100644
88183 --- a/net/mac80211/main.c
88184 +++ b/net/mac80211/main.c
88185 @@ -180,7 +180,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88186 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88187 IEEE80211_CONF_CHANGE_POWER);
88188
88189 - if (changed && local->open_count) {
88190 + if (changed && local_read(&local->open_count)) {
88191 ret = drv_config(local, changed);
88192 /*
88193 * Goal:
88194 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88195 index 835584c..be46e67 100644
88196 --- a/net/mac80211/pm.c
88197 +++ b/net/mac80211/pm.c
88198 @@ -33,7 +33,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88199 struct sta_info *sta;
88200 struct ieee80211_chanctx *ctx;
88201
88202 - if (!local->open_count)
88203 + if (!local_read(&local->open_count))
88204 goto suspend;
88205
88206 ieee80211_scan_cancel(local);
88207 @@ -75,7 +75,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88208 cancel_work_sync(&local->dynamic_ps_enable_work);
88209 del_timer_sync(&local->dynamic_ps_timer);
88210
88211 - local->wowlan = wowlan && local->open_count;
88212 + local->wowlan = wowlan && local_read(&local->open_count);
88213 if (local->wowlan) {
88214 int err = drv_suspend(local, wowlan);
88215 if (err < 0) {
88216 @@ -214,7 +214,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88217 mutex_unlock(&local->chanctx_mtx);
88218
88219 /* stop hardware - this must stop RX */
88220 - if (local->open_count)
88221 + if (local_read(&local->open_count))
88222 ieee80211_stop_device(local);
88223
88224 suspend:
88225 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88226 index dd88381..eef4dd6 100644
88227 --- a/net/mac80211/rate.c
88228 +++ b/net/mac80211/rate.c
88229 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88230
88231 ASSERT_RTNL();
88232
88233 - if (local->open_count)
88234 + if (local_read(&local->open_count))
88235 return -EBUSY;
88236
88237 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88238 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88239 index c97a065..ff61928 100644
88240 --- a/net/mac80211/rc80211_pid_debugfs.c
88241 +++ b/net/mac80211/rc80211_pid_debugfs.c
88242 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88243
88244 spin_unlock_irqrestore(&events->lock, status);
88245
88246 - if (copy_to_user(buf, pb, p))
88247 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88248 return -EFAULT;
88249
88250 return p;
88251 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88252 index 0f38f43..e53d4a8 100644
88253 --- a/net/mac80211/util.c
88254 +++ b/net/mac80211/util.c
88255 @@ -1388,7 +1388,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88256 }
88257 #endif
88258 /* everything else happens only if HW was up & running */
88259 - if (!local->open_count)
88260 + if (!local_read(&local->open_count))
88261 goto wake_up;
88262
88263 /*
88264 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88265 index 56d22ca..87c778f 100644
88266 --- a/net/netfilter/Kconfig
88267 +++ b/net/netfilter/Kconfig
88268 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
88269
88270 To compile it as a module, choose M here. If unsure, say N.
88271
88272 +config NETFILTER_XT_MATCH_GRADM
88273 + tristate '"gradm" match support'
88274 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88275 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88276 + ---help---
88277 + The gradm match allows to match on grsecurity RBAC being enabled.
88278 + It is useful when iptables rules are applied early on bootup to
88279 + prevent connections to the machine (except from a trusted host)
88280 + while the RBAC system is disabled.
88281 +
88282 config NETFILTER_XT_MATCH_HASHLIMIT
88283 tristate '"hashlimit" match support'
88284 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88285 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88286 index a1abf87..dbcb7ee 100644
88287 --- a/net/netfilter/Makefile
88288 +++ b/net/netfilter/Makefile
88289 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88290 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88291 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88292 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88293 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88294 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88295 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88296 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88297 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88298 index 1ba9dbc..e39f4ca 100644
88299 --- a/net/netfilter/ipset/ip_set_core.c
88300 +++ b/net/netfilter/ipset/ip_set_core.c
88301 @@ -1801,7 +1801,7 @@ done:
88302 return ret;
88303 }
88304
88305 -static struct nf_sockopt_ops so_set __read_mostly = {
88306 +static struct nf_sockopt_ops so_set = {
88307 .pf = PF_INET,
88308 .get_optmin = SO_IP_SET,
88309 .get_optmax = SO_IP_SET + 1,
88310 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88311 index 704e514..d644cc2 100644
88312 --- a/net/netfilter/ipvs/ip_vs_conn.c
88313 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88314 @@ -551,7 +551,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88315 /* Increase the refcnt counter of the dest */
88316 atomic_inc(&dest->refcnt);
88317
88318 - conn_flags = atomic_read(&dest->conn_flags);
88319 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88320 if (cp->protocol != IPPROTO_UDP)
88321 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88322 flags = cp->flags;
88323 @@ -895,7 +895,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88324 atomic_set(&cp->refcnt, 1);
88325
88326 atomic_set(&cp->n_control, 0);
88327 - atomic_set(&cp->in_pkts, 0);
88328 + atomic_set_unchecked(&cp->in_pkts, 0);
88329
88330 atomic_inc(&ipvs->conn_count);
88331 if (flags & IP_VS_CONN_F_NO_CPORT)
88332 @@ -1174,7 +1174,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
88333
88334 /* Don't drop the entry if its number of incoming packets is not
88335 located in [0, 8] */
88336 - i = atomic_read(&cp->in_pkts);
88337 + i = atomic_read_unchecked(&cp->in_pkts);
88338 if (i > 8 || i < 0) return 0;
88339
88340 if (!todrop_rate[i]) return 0;
88341 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
88342 index 61f49d2..6c8c5bc 100644
88343 --- a/net/netfilter/ipvs/ip_vs_core.c
88344 +++ b/net/netfilter/ipvs/ip_vs_core.c
88345 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
88346 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
88347 /* do not touch skb anymore */
88348
88349 - atomic_inc(&cp->in_pkts);
88350 + atomic_inc_unchecked(&cp->in_pkts);
88351 ip_vs_conn_put(cp);
88352 return ret;
88353 }
88354 @@ -1689,7 +1689,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
88355 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
88356 pkts = sysctl_sync_threshold(ipvs);
88357 else
88358 - pkts = atomic_add_return(1, &cp->in_pkts);
88359 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88360
88361 if (ipvs->sync_state & IP_VS_STATE_MASTER)
88362 ip_vs_sync_conn(net, cp, pkts);
88363 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
88364 index 9e2d1cc..7f8f569 100644
88365 --- a/net/netfilter/ipvs/ip_vs_ctl.c
88366 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
88367 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
88368 ip_vs_rs_hash(ipvs, dest);
88369 write_unlock_bh(&ipvs->rs_lock);
88370 }
88371 - atomic_set(&dest->conn_flags, conn_flags);
88372 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
88373
88374 /* bind the service */
88375 if (!dest->svc) {
88376 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
88377 * align with netns init in ip_vs_control_net_init()
88378 */
88379
88380 -static struct ctl_table vs_vars[] = {
88381 +static ctl_table_no_const vs_vars[] __read_only = {
88382 {
88383 .procname = "amemthresh",
88384 .maxlen = sizeof(int),
88385 @@ -2087,7 +2087,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88386 " %-7s %-6d %-10d %-10d\n",
88387 &dest->addr.in6,
88388 ntohs(dest->port),
88389 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88390 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88391 atomic_read(&dest->weight),
88392 atomic_read(&dest->activeconns),
88393 atomic_read(&dest->inactconns));
88394 @@ -2098,7 +2098,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88395 "%-7s %-6d %-10d %-10d\n",
88396 ntohl(dest->addr.ip),
88397 ntohs(dest->port),
88398 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88399 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88400 atomic_read(&dest->weight),
88401 atomic_read(&dest->activeconns),
88402 atomic_read(&dest->inactconns));
88403 @@ -2568,7 +2568,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
88404
88405 entry.addr = dest->addr.ip;
88406 entry.port = dest->port;
88407 - entry.conn_flags = atomic_read(&dest->conn_flags);
88408 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
88409 entry.weight = atomic_read(&dest->weight);
88410 entry.u_threshold = dest->u_threshold;
88411 entry.l_threshold = dest->l_threshold;
88412 @@ -3104,7 +3104,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
88413 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
88414 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
88415 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
88416 - (atomic_read(&dest->conn_flags) &
88417 + (atomic_read_unchecked(&dest->conn_flags) &
88418 IP_VS_CONN_F_FWD_MASK)) ||
88419 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
88420 atomic_read(&dest->weight)) ||
88421 @@ -3694,7 +3694,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
88422 {
88423 int idx;
88424 struct netns_ipvs *ipvs = net_ipvs(net);
88425 - struct ctl_table *tbl;
88426 + ctl_table_no_const *tbl;
88427
88428 atomic_set(&ipvs->dropentry, 0);
88429 spin_lock_init(&ipvs->dropentry_lock);
88430 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
88431 index fdd89b9..bd96aa9 100644
88432 --- a/net/netfilter/ipvs/ip_vs_lblc.c
88433 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
88434 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
88435 * IPVS LBLC sysctl table
88436 */
88437 #ifdef CONFIG_SYSCTL
88438 -static ctl_table vs_vars_table[] = {
88439 +static ctl_table_no_const vs_vars_table[] __read_only = {
88440 {
88441 .procname = "lblc_expiration",
88442 .data = NULL,
88443 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
88444 index c03b6a3..8ce3681 100644
88445 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
88446 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
88447 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
88448 * IPVS LBLCR sysctl table
88449 */
88450
88451 -static ctl_table vs_vars_table[] = {
88452 +static ctl_table_no_const vs_vars_table[] __read_only = {
88453 {
88454 .procname = "lblcr_expiration",
88455 .data = NULL,
88456 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
88457 index 44fd10c..2a163b3 100644
88458 --- a/net/netfilter/ipvs/ip_vs_sync.c
88459 +++ b/net/netfilter/ipvs/ip_vs_sync.c
88460 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
88461 cp = cp->control;
88462 if (cp) {
88463 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88464 - pkts = atomic_add_return(1, &cp->in_pkts);
88465 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88466 else
88467 pkts = sysctl_sync_threshold(ipvs);
88468 ip_vs_sync_conn(net, cp->control, pkts);
88469 @@ -758,7 +758,7 @@ control:
88470 if (!cp)
88471 return;
88472 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88473 - pkts = atomic_add_return(1, &cp->in_pkts);
88474 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88475 else
88476 pkts = sysctl_sync_threshold(ipvs);
88477 goto sloop;
88478 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
88479
88480 if (opt)
88481 memcpy(&cp->in_seq, opt, sizeof(*opt));
88482 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88483 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88484 cp->state = state;
88485 cp->old_state = cp->state;
88486 /*
88487 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
88488 index ee6b7a9..f9a89f6 100644
88489 --- a/net/netfilter/ipvs/ip_vs_xmit.c
88490 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
88491 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
88492 else
88493 rc = NF_ACCEPT;
88494 /* do not touch skb anymore */
88495 - atomic_inc(&cp->in_pkts);
88496 + atomic_inc_unchecked(&cp->in_pkts);
88497 goto out;
88498 }
88499
88500 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
88501 else
88502 rc = NF_ACCEPT;
88503 /* do not touch skb anymore */
88504 - atomic_inc(&cp->in_pkts);
88505 + atomic_inc_unchecked(&cp->in_pkts);
88506 goto out;
88507 }
88508
88509 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
88510 index 2d3030a..7ba1c0a 100644
88511 --- a/net/netfilter/nf_conntrack_acct.c
88512 +++ b/net/netfilter/nf_conntrack_acct.c
88513 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
88514 #ifdef CONFIG_SYSCTL
88515 static int nf_conntrack_acct_init_sysctl(struct net *net)
88516 {
88517 - struct ctl_table *table;
88518 + ctl_table_no_const *table;
88519
88520 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
88521 GFP_KERNEL);
88522 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
88523 index c8e001a..f842a8b 100644
88524 --- a/net/netfilter/nf_conntrack_core.c
88525 +++ b/net/netfilter/nf_conntrack_core.c
88526 @@ -1594,6 +1594,10 @@ void nf_conntrack_init_end(void)
88527 #define DYING_NULLS_VAL ((1<<30)+1)
88528 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
88529
88530 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88531 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
88532 +#endif
88533 +
88534 int nf_conntrack_init_net(struct net *net)
88535 {
88536 int ret;
88537 @@ -1608,7 +1612,11 @@ int nf_conntrack_init_net(struct net *net)
88538 goto err_stat;
88539 }
88540
88541 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88542 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
88543 +#else
88544 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
88545 +#endif
88546 if (!net->ct.slabname) {
88547 ret = -ENOMEM;
88548 goto err_slabname;
88549 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
88550 index b5d2eb8..61ef19a 100644
88551 --- a/net/netfilter/nf_conntrack_ecache.c
88552 +++ b/net/netfilter/nf_conntrack_ecache.c
88553 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
88554 #ifdef CONFIG_SYSCTL
88555 static int nf_conntrack_event_init_sysctl(struct net *net)
88556 {
88557 - struct ctl_table *table;
88558 + ctl_table_no_const *table;
88559
88560 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
88561 GFP_KERNEL);
88562 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
88563 index 94b4b98..97cf0ad 100644
88564 --- a/net/netfilter/nf_conntrack_helper.c
88565 +++ b/net/netfilter/nf_conntrack_helper.c
88566 @@ -56,7 +56,7 @@ static struct ctl_table helper_sysctl_table[] = {
88567
88568 static int nf_conntrack_helper_init_sysctl(struct net *net)
88569 {
88570 - struct ctl_table *table;
88571 + ctl_table_no_const *table;
88572
88573 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
88574 GFP_KERNEL);
88575 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
88576 index 58ab405..50eb8d3 100644
88577 --- a/net/netfilter/nf_conntrack_proto.c
88578 +++ b/net/netfilter/nf_conntrack_proto.c
88579 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
88580
88581 static void
88582 nf_ct_unregister_sysctl(struct ctl_table_header **header,
88583 - struct ctl_table **table,
88584 + ctl_table_no_const **table,
88585 unsigned int users)
88586 {
88587 if (users > 0)
88588 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
88589 index fedee39..d62a93d 100644
88590 --- a/net/netfilter/nf_conntrack_standalone.c
88591 +++ b/net/netfilter/nf_conntrack_standalone.c
88592 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
88593
88594 static int nf_conntrack_standalone_init_sysctl(struct net *net)
88595 {
88596 - struct ctl_table *table;
88597 + ctl_table_no_const *table;
88598
88599 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
88600 GFP_KERNEL);
88601 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
88602 index 902fb0a..87f7fdb 100644
88603 --- a/net/netfilter/nf_conntrack_timestamp.c
88604 +++ b/net/netfilter/nf_conntrack_timestamp.c
88605 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
88606 #ifdef CONFIG_SYSCTL
88607 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
88608 {
88609 - struct ctl_table *table;
88610 + ctl_table_no_const *table;
88611
88612 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
88613 GFP_KERNEL);
88614 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
88615 index 9e31269..bc4c1b7 100644
88616 --- a/net/netfilter/nf_log.c
88617 +++ b/net/netfilter/nf_log.c
88618 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
88619
88620 #ifdef CONFIG_SYSCTL
88621 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
88622 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
88623 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
88624 static struct ctl_table_header *nf_log_dir_header;
88625
88626 static int nf_log_proc_dostring(ctl_table *table, int write,
88627 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
88628 rcu_assign_pointer(nf_loggers[tindex], logger);
88629 mutex_unlock(&nf_log_mutex);
88630 } else {
88631 + ctl_table_no_const nf_log_table = *table;
88632 +
88633 mutex_lock(&nf_log_mutex);
88634 logger = rcu_dereference_protected(nf_loggers[tindex],
88635 lockdep_is_held(&nf_log_mutex));
88636 if (!logger)
88637 - table->data = "NONE";
88638 + nf_log_table.data = "NONE";
88639 else
88640 - table->data = logger->name;
88641 - r = proc_dostring(table, write, buffer, lenp, ppos);
88642 + nf_log_table.data = logger->name;
88643 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
88644 mutex_unlock(&nf_log_mutex);
88645 }
88646
88647 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
88648 index f042ae5..30ea486 100644
88649 --- a/net/netfilter/nf_sockopt.c
88650 +++ b/net/netfilter/nf_sockopt.c
88651 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
88652 }
88653 }
88654
88655 - list_add(&reg->list, &nf_sockopts);
88656 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
88657 out:
88658 mutex_unlock(&nf_sockopt_mutex);
88659 return ret;
88660 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
88661 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
88662 {
88663 mutex_lock(&nf_sockopt_mutex);
88664 - list_del(&reg->list);
88665 + pax_list_del((struct list_head *)&reg->list);
88666 mutex_unlock(&nf_sockopt_mutex);
88667 }
88668 EXPORT_SYMBOL(nf_unregister_sockopt);
88669 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
88670 index f248db5..3778ad9 100644
88671 --- a/net/netfilter/nfnetlink_log.c
88672 +++ b/net/netfilter/nfnetlink_log.c
88673 @@ -72,7 +72,7 @@ struct nfulnl_instance {
88674 };
88675
88676 static DEFINE_SPINLOCK(instances_lock);
88677 -static atomic_t global_seq;
88678 +static atomic_unchecked_t global_seq;
88679
88680 #define INSTANCE_BUCKETS 16
88681 static struct hlist_head instance_table[INSTANCE_BUCKETS];
88682 @@ -536,7 +536,7 @@ __build_packet_message(struct nfulnl_instance *inst,
88683 /* global sequence number */
88684 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
88685 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
88686 - htonl(atomic_inc_return(&global_seq))))
88687 + htonl(atomic_inc_return_unchecked(&global_seq))))
88688 goto nla_put_failure;
88689
88690 if (data_len) {
88691 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
88692 new file mode 100644
88693 index 0000000..c566332
88694 --- /dev/null
88695 +++ b/net/netfilter/xt_gradm.c
88696 @@ -0,0 +1,51 @@
88697 +/*
88698 + * gradm match for netfilter
88699 + * Copyright © Zbigniew Krzystolik, 2010
88700 + *
88701 + * This program is free software; you can redistribute it and/or modify
88702 + * it under the terms of the GNU General Public License; either version
88703 + * 2 or 3 as published by the Free Software Foundation.
88704 + */
88705 +#include <linux/module.h>
88706 +#include <linux/moduleparam.h>
88707 +#include <linux/skbuff.h>
88708 +#include <linux/netfilter/x_tables.h>
88709 +#include <linux/grsecurity.h>
88710 +#include <linux/netfilter/xt_gradm.h>
88711 +
88712 +static bool
88713 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
88714 +{
88715 + const struct xt_gradm_mtinfo *info = par->matchinfo;
88716 + bool retval = false;
88717 + if (gr_acl_is_enabled())
88718 + retval = true;
88719 + return retval ^ info->invflags;
88720 +}
88721 +
88722 +static struct xt_match gradm_mt_reg __read_mostly = {
88723 + .name = "gradm",
88724 + .revision = 0,
88725 + .family = NFPROTO_UNSPEC,
88726 + .match = gradm_mt,
88727 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
88728 + .me = THIS_MODULE,
88729 +};
88730 +
88731 +static int __init gradm_mt_init(void)
88732 +{
88733 + return xt_register_match(&gradm_mt_reg);
88734 +}
88735 +
88736 +static void __exit gradm_mt_exit(void)
88737 +{
88738 + xt_unregister_match(&gradm_mt_reg);
88739 +}
88740 +
88741 +module_init(gradm_mt_init);
88742 +module_exit(gradm_mt_exit);
88743 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
88744 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
88745 +MODULE_LICENSE("GPL");
88746 +MODULE_ALIAS("ipt_gradm");
88747 +MODULE_ALIAS("ip6t_gradm");
88748 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
88749 index 4fe4fb4..87a89e5 100644
88750 --- a/net/netfilter/xt_statistic.c
88751 +++ b/net/netfilter/xt_statistic.c
88752 @@ -19,7 +19,7 @@
88753 #include <linux/module.h>
88754
88755 struct xt_statistic_priv {
88756 - atomic_t count;
88757 + atomic_unchecked_t count;
88758 } ____cacheline_aligned_in_smp;
88759
88760 MODULE_LICENSE("GPL");
88761 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
88762 break;
88763 case XT_STATISTIC_MODE_NTH:
88764 do {
88765 - oval = atomic_read(&info->master->count);
88766 + oval = atomic_read_unchecked(&info->master->count);
88767 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
88768 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
88769 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
88770 if (nval == 0)
88771 ret = !ret;
88772 break;
88773 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
88774 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
88775 if (info->master == NULL)
88776 return -ENOMEM;
88777 - atomic_set(&info->master->count, info->u.nth.count);
88778 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
88779
88780 return 0;
88781 }
88782 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
88783 index 1e3fd5b..ad397ea 100644
88784 --- a/net/netlink/af_netlink.c
88785 +++ b/net/netlink/af_netlink.c
88786 @@ -781,7 +781,7 @@ static void netlink_overrun(struct sock *sk)
88787 sk->sk_error_report(sk);
88788 }
88789 }
88790 - atomic_inc(&sk->sk_drops);
88791 + atomic_inc_unchecked(&sk->sk_drops);
88792 }
88793
88794 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
88795 @@ -2063,7 +2063,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
88796 sk_wmem_alloc_get(s),
88797 nlk->cb,
88798 atomic_read(&s->sk_refcnt),
88799 - atomic_read(&s->sk_drops),
88800 + atomic_read_unchecked(&s->sk_drops),
88801 sock_i_ino(s)
88802 );
88803
88804 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
88805 index 5a55be3..7630745 100644
88806 --- a/net/netlink/genetlink.c
88807 +++ b/net/netlink/genetlink.c
88808 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
88809 goto errout;
88810 }
88811
88812 + pax_open_kernel();
88813 if (ops->dumpit)
88814 - ops->flags |= GENL_CMD_CAP_DUMP;
88815 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
88816 if (ops->doit)
88817 - ops->flags |= GENL_CMD_CAP_DO;
88818 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
88819 if (ops->policy)
88820 - ops->flags |= GENL_CMD_CAP_HASPOL;
88821 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
88822 + pax_close_kernel();
88823
88824 genl_lock();
88825 - list_add_tail(&ops->ops_list, &family->ops_list);
88826 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
88827 genl_unlock();
88828
88829 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
88830 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
88831 err = 0;
88832 errout:
88833 return err;
88834 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
88835 genl_lock();
88836 list_for_each_entry(rc, &family->ops_list, ops_list) {
88837 if (rc == ops) {
88838 - list_del(&ops->ops_list);
88839 + pax_list_del((struct list_head *)&ops->ops_list);
88840 genl_unlock();
88841 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
88842 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
88843 return 0;
88844 }
88845 }
88846 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
88847 index 103bd70..f21aad3 100644
88848 --- a/net/netrom/af_netrom.c
88849 +++ b/net/netrom/af_netrom.c
88850 @@ -834,6 +834,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88851 struct sock *sk = sock->sk;
88852 struct nr_sock *nr = nr_sk(sk);
88853
88854 + memset(sax, 0, sizeof(*sax));
88855 lock_sock(sk);
88856 if (peer != 0) {
88857 if (sk->sk_state != TCP_ESTABLISHED) {
88858 @@ -848,7 +849,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88859 *uaddr_len = sizeof(struct full_sockaddr_ax25);
88860 } else {
88861 sax->fsa_ax25.sax25_family = AF_NETROM;
88862 - sax->fsa_ax25.sax25_ndigis = 0;
88863 sax->fsa_ax25.sax25_call = nr->source_addr;
88864 *uaddr_len = sizeof(struct sockaddr_ax25);
88865 }
88866 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
88867 index f83e172..b57140d 100644
88868 --- a/net/packet/af_packet.c
88869 +++ b/net/packet/af_packet.c
88870 @@ -1571,7 +1571,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88871
88872 spin_lock(&sk->sk_receive_queue.lock);
88873 po->stats.tp_packets++;
88874 - skb->dropcount = atomic_read(&sk->sk_drops);
88875 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
88876 __skb_queue_tail(&sk->sk_receive_queue, skb);
88877 spin_unlock(&sk->sk_receive_queue.lock);
88878 sk->sk_data_ready(sk, skb->len);
88879 @@ -1580,7 +1580,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88880 drop_n_acct:
88881 spin_lock(&sk->sk_receive_queue.lock);
88882 po->stats.tp_drops++;
88883 - atomic_inc(&sk->sk_drops);
88884 + atomic_inc_unchecked(&sk->sk_drops);
88885 spin_unlock(&sk->sk_receive_queue.lock);
88886
88887 drop_n_restore:
88888 @@ -2558,6 +2558,7 @@ out:
88889
88890 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88891 {
88892 + struct sock_extended_err ee;
88893 struct sock_exterr_skb *serr;
88894 struct sk_buff *skb, *skb2;
88895 int copied, err;
88896 @@ -2579,8 +2580,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88897 sock_recv_timestamp(msg, sk, skb);
88898
88899 serr = SKB_EXT_ERR(skb);
88900 + ee = serr->ee;
88901 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
88902 - sizeof(serr->ee), &serr->ee);
88903 + sizeof ee, &ee);
88904
88905 msg->msg_flags |= MSG_ERRQUEUE;
88906 err = copied;
88907 @@ -3205,7 +3207,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88908 case PACKET_HDRLEN:
88909 if (len > sizeof(int))
88910 len = sizeof(int);
88911 - if (copy_from_user(&val, optval, len))
88912 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
88913 return -EFAULT;
88914 switch (val) {
88915 case TPACKET_V1:
88916 @@ -3247,7 +3249,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88917 len = lv;
88918 if (put_user(len, optlen))
88919 return -EFAULT;
88920 - if (copy_to_user(optval, data, len))
88921 + if (len > sizeof(st) || copy_to_user(optval, data, len))
88922 return -EFAULT;
88923 return 0;
88924 }
88925 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
88926 index 5a940db..d6a502d 100644
88927 --- a/net/phonet/af_phonet.c
88928 +++ b/net/phonet/af_phonet.c
88929 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
88930 {
88931 int err = 0;
88932
88933 - if (protocol >= PHONET_NPROTO)
88934 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88935 return -EINVAL;
88936
88937 err = proto_register(pp->prot, 1);
88938 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
88939 index e774117..900b8b7 100644
88940 --- a/net/phonet/pep.c
88941 +++ b/net/phonet/pep.c
88942 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88943
88944 case PNS_PEP_CTRL_REQ:
88945 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
88946 - atomic_inc(&sk->sk_drops);
88947 + atomic_inc_unchecked(&sk->sk_drops);
88948 break;
88949 }
88950 __skb_pull(skb, 4);
88951 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88952 }
88953
88954 if (pn->rx_credits == 0) {
88955 - atomic_inc(&sk->sk_drops);
88956 + atomic_inc_unchecked(&sk->sk_drops);
88957 err = -ENOBUFS;
88958 break;
88959 }
88960 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
88961 }
88962
88963 if (pn->rx_credits == 0) {
88964 - atomic_inc(&sk->sk_drops);
88965 + atomic_inc_unchecked(&sk->sk_drops);
88966 err = NET_RX_DROP;
88967 break;
88968 }
88969 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
88970 index 1afd138..0b42453 100644
88971 --- a/net/phonet/socket.c
88972 +++ b/net/phonet/socket.c
88973 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
88974 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
88975 sock_i_ino(sk),
88976 atomic_read(&sk->sk_refcnt), sk,
88977 - atomic_read(&sk->sk_drops), &len);
88978 + atomic_read_unchecked(&sk->sk_drops), &len);
88979 }
88980 seq_printf(seq, "%*s\n", 127 - len, "");
88981 return 0;
88982 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
88983 index d6bbbbd..61561e4 100644
88984 --- a/net/phonet/sysctl.c
88985 +++ b/net/phonet/sysctl.c
88986 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
88987 {
88988 int ret;
88989 int range[2] = {local_port_range[0], local_port_range[1]};
88990 - ctl_table tmp = {
88991 + ctl_table_no_const tmp = {
88992 .data = &range,
88993 .maxlen = sizeof(range),
88994 .mode = table->mode,
88995 diff --git a/net/rds/cong.c b/net/rds/cong.c
88996 index e5b65ac..f3b6fb7 100644
88997 --- a/net/rds/cong.c
88998 +++ b/net/rds/cong.c
88999 @@ -78,7 +78,7 @@
89000 * finds that the saved generation number is smaller than the global generation
89001 * number, it wakes up the process.
89002 */
89003 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89004 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89005
89006 /*
89007 * Congestion monitoring
89008 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89009 rdsdebug("waking map %p for %pI4\n",
89010 map, &map->m_addr);
89011 rds_stats_inc(s_cong_update_received);
89012 - atomic_inc(&rds_cong_generation);
89013 + atomic_inc_unchecked(&rds_cong_generation);
89014 if (waitqueue_active(&map->m_waitq))
89015 wake_up(&map->m_waitq);
89016 if (waitqueue_active(&rds_poll_waitq))
89017 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89018
89019 int rds_cong_updated_since(unsigned long *recent)
89020 {
89021 - unsigned long gen = atomic_read(&rds_cong_generation);
89022 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89023
89024 if (likely(*recent == gen))
89025 return 0;
89026 diff --git a/net/rds/ib.h b/net/rds/ib.h
89027 index 7280ab8..e04f4ea 100644
89028 --- a/net/rds/ib.h
89029 +++ b/net/rds/ib.h
89030 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89031 /* sending acks */
89032 unsigned long i_ack_flags;
89033 #ifdef KERNEL_HAS_ATOMIC64
89034 - atomic64_t i_ack_next; /* next ACK to send */
89035 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89036 #else
89037 spinlock_t i_ack_lock; /* protect i_ack_next */
89038 u64 i_ack_next; /* next ACK to send */
89039 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89040 index 31b74f5..dc1fbfa 100644
89041 --- a/net/rds/ib_cm.c
89042 +++ b/net/rds/ib_cm.c
89043 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89044 /* Clear the ACK state */
89045 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89046 #ifdef KERNEL_HAS_ATOMIC64
89047 - atomic64_set(&ic->i_ack_next, 0);
89048 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89049 #else
89050 ic->i_ack_next = 0;
89051 #endif
89052 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89053 index 8eb9501..0c386ff 100644
89054 --- a/net/rds/ib_recv.c
89055 +++ b/net/rds/ib_recv.c
89056 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89057 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89058 int ack_required)
89059 {
89060 - atomic64_set(&ic->i_ack_next, seq);
89061 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89062 if (ack_required) {
89063 smp_mb__before_clear_bit();
89064 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89065 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89066 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89067 smp_mb__after_clear_bit();
89068
89069 - return atomic64_read(&ic->i_ack_next);
89070 + return atomic64_read_unchecked(&ic->i_ack_next);
89071 }
89072 #endif
89073
89074 diff --git a/net/rds/iw.h b/net/rds/iw.h
89075 index 04ce3b1..48119a6 100644
89076 --- a/net/rds/iw.h
89077 +++ b/net/rds/iw.h
89078 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89079 /* sending acks */
89080 unsigned long i_ack_flags;
89081 #ifdef KERNEL_HAS_ATOMIC64
89082 - atomic64_t i_ack_next; /* next ACK to send */
89083 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89084 #else
89085 spinlock_t i_ack_lock; /* protect i_ack_next */
89086 u64 i_ack_next; /* next ACK to send */
89087 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89088 index a91e1db..cf3053f 100644
89089 --- a/net/rds/iw_cm.c
89090 +++ b/net/rds/iw_cm.c
89091 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89092 /* Clear the ACK state */
89093 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89094 #ifdef KERNEL_HAS_ATOMIC64
89095 - atomic64_set(&ic->i_ack_next, 0);
89096 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89097 #else
89098 ic->i_ack_next = 0;
89099 #endif
89100 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89101 index 4503335..db566b4 100644
89102 --- a/net/rds/iw_recv.c
89103 +++ b/net/rds/iw_recv.c
89104 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89105 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89106 int ack_required)
89107 {
89108 - atomic64_set(&ic->i_ack_next, seq);
89109 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89110 if (ack_required) {
89111 smp_mb__before_clear_bit();
89112 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89113 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89114 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89115 smp_mb__after_clear_bit();
89116
89117 - return atomic64_read(&ic->i_ack_next);
89118 + return atomic64_read_unchecked(&ic->i_ack_next);
89119 }
89120 #endif
89121
89122 diff --git a/net/rds/rds.h b/net/rds/rds.h
89123 index ec1d731..90a3a8d 100644
89124 --- a/net/rds/rds.h
89125 +++ b/net/rds/rds.h
89126 @@ -449,7 +449,7 @@ struct rds_transport {
89127 void (*sync_mr)(void *trans_private, int direction);
89128 void (*free_mr)(void *trans_private, int invalidate);
89129 void (*flush_mrs)(void);
89130 -};
89131 +} __do_const;
89132
89133 struct rds_sock {
89134 struct sock rs_sk;
89135 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89136 index edac9ef..16bcb98 100644
89137 --- a/net/rds/tcp.c
89138 +++ b/net/rds/tcp.c
89139 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89140 int val = 1;
89141
89142 set_fs(KERNEL_DS);
89143 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89144 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89145 sizeof(val));
89146 set_fs(oldfs);
89147 }
89148 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89149 index 81cf5a4..b5826ff 100644
89150 --- a/net/rds/tcp_send.c
89151 +++ b/net/rds/tcp_send.c
89152 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89153
89154 oldfs = get_fs();
89155 set_fs(KERNEL_DS);
89156 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89157 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89158 sizeof(val));
89159 set_fs(oldfs);
89160 }
89161 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89162 index e61aa60..f07cc89 100644
89163 --- a/net/rxrpc/af_rxrpc.c
89164 +++ b/net/rxrpc/af_rxrpc.c
89165 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89166 __be32 rxrpc_epoch;
89167
89168 /* current debugging ID */
89169 -atomic_t rxrpc_debug_id;
89170 +atomic_unchecked_t rxrpc_debug_id;
89171
89172 /* count of skbs currently in use */
89173 atomic_t rxrpc_n_skbs;
89174 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89175 index e4d9cbc..b229649 100644
89176 --- a/net/rxrpc/ar-ack.c
89177 +++ b/net/rxrpc/ar-ack.c
89178 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89179
89180 _enter("{%d,%d,%d,%d},",
89181 call->acks_hard, call->acks_unacked,
89182 - atomic_read(&call->sequence),
89183 + atomic_read_unchecked(&call->sequence),
89184 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89185
89186 stop = 0;
89187 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89188
89189 /* each Tx packet has a new serial number */
89190 sp->hdr.serial =
89191 - htonl(atomic_inc_return(&call->conn->serial));
89192 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89193
89194 hdr = (struct rxrpc_header *) txb->head;
89195 hdr->serial = sp->hdr.serial;
89196 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89197 */
89198 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89199 {
89200 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89201 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89202 }
89203
89204 /*
89205 @@ -629,7 +629,7 @@ process_further:
89206
89207 latest = ntohl(sp->hdr.serial);
89208 hard = ntohl(ack.firstPacket);
89209 - tx = atomic_read(&call->sequence);
89210 + tx = atomic_read_unchecked(&call->sequence);
89211
89212 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89213 latest,
89214 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89215 goto maybe_reschedule;
89216
89217 send_ACK_with_skew:
89218 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89219 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89220 ntohl(ack.serial));
89221 send_ACK:
89222 mtu = call->conn->trans->peer->if_mtu;
89223 @@ -1173,7 +1173,7 @@ send_ACK:
89224 ackinfo.rxMTU = htonl(5692);
89225 ackinfo.jumbo_max = htonl(4);
89226
89227 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89228 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89229 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89230 ntohl(hdr.serial),
89231 ntohs(ack.maxSkew),
89232 @@ -1191,7 +1191,7 @@ send_ACK:
89233 send_message:
89234 _debug("send message");
89235
89236 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89237 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89238 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89239 send_message_2:
89240
89241 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89242 index a3bbb36..3341fb9 100644
89243 --- a/net/rxrpc/ar-call.c
89244 +++ b/net/rxrpc/ar-call.c
89245 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89246 spin_lock_init(&call->lock);
89247 rwlock_init(&call->state_lock);
89248 atomic_set(&call->usage, 1);
89249 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89250 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89251 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89252
89253 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89254 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89255 index 4106ca9..a338d7a 100644
89256 --- a/net/rxrpc/ar-connection.c
89257 +++ b/net/rxrpc/ar-connection.c
89258 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89259 rwlock_init(&conn->lock);
89260 spin_lock_init(&conn->state_lock);
89261 atomic_set(&conn->usage, 1);
89262 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89263 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89264 conn->avail_calls = RXRPC_MAXCALLS;
89265 conn->size_align = 4;
89266 conn->header_size = sizeof(struct rxrpc_header);
89267 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89268 index e7ed43a..6afa140 100644
89269 --- a/net/rxrpc/ar-connevent.c
89270 +++ b/net/rxrpc/ar-connevent.c
89271 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89272
89273 len = iov[0].iov_len + iov[1].iov_len;
89274
89275 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89276 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89277 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89278
89279 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89280 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89281 index 529572f..c758ca7 100644
89282 --- a/net/rxrpc/ar-input.c
89283 +++ b/net/rxrpc/ar-input.c
89284 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89285 /* track the latest serial number on this connection for ACK packet
89286 * information */
89287 serial = ntohl(sp->hdr.serial);
89288 - hi_serial = atomic_read(&call->conn->hi_serial);
89289 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
89290 while (serial > hi_serial)
89291 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
89292 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
89293 serial);
89294
89295 /* request ACK generation for any ACK or DATA packet that requests
89296 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
89297 index a693aca..81e7293 100644
89298 --- a/net/rxrpc/ar-internal.h
89299 +++ b/net/rxrpc/ar-internal.h
89300 @@ -272,8 +272,8 @@ struct rxrpc_connection {
89301 int error; /* error code for local abort */
89302 int debug_id; /* debug ID for printks */
89303 unsigned int call_counter; /* call ID counter */
89304 - atomic_t serial; /* packet serial number counter */
89305 - atomic_t hi_serial; /* highest serial number received */
89306 + atomic_unchecked_t serial; /* packet serial number counter */
89307 + atomic_unchecked_t hi_serial; /* highest serial number received */
89308 u8 avail_calls; /* number of calls available */
89309 u8 size_align; /* data size alignment (for security) */
89310 u8 header_size; /* rxrpc + security header size */
89311 @@ -346,7 +346,7 @@ struct rxrpc_call {
89312 spinlock_t lock;
89313 rwlock_t state_lock; /* lock for state transition */
89314 atomic_t usage;
89315 - atomic_t sequence; /* Tx data packet sequence counter */
89316 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
89317 u32 abort_code; /* local/remote abort code */
89318 enum { /* current state of call */
89319 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
89320 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
89321 */
89322 extern atomic_t rxrpc_n_skbs;
89323 extern __be32 rxrpc_epoch;
89324 -extern atomic_t rxrpc_debug_id;
89325 +extern atomic_unchecked_t rxrpc_debug_id;
89326 extern struct workqueue_struct *rxrpc_workqueue;
89327
89328 /*
89329 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
89330 index 87f7135..74d3703 100644
89331 --- a/net/rxrpc/ar-local.c
89332 +++ b/net/rxrpc/ar-local.c
89333 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
89334 spin_lock_init(&local->lock);
89335 rwlock_init(&local->services_lock);
89336 atomic_set(&local->usage, 1);
89337 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
89338 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89339 memcpy(&local->srx, srx, sizeof(*srx));
89340 }
89341
89342 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
89343 index e1ac183..b43e10e 100644
89344 --- a/net/rxrpc/ar-output.c
89345 +++ b/net/rxrpc/ar-output.c
89346 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
89347 sp->hdr.cid = call->cid;
89348 sp->hdr.callNumber = call->call_id;
89349 sp->hdr.seq =
89350 - htonl(atomic_inc_return(&call->sequence));
89351 + htonl(atomic_inc_return_unchecked(&call->sequence));
89352 sp->hdr.serial =
89353 - htonl(atomic_inc_return(&conn->serial));
89354 + htonl(atomic_inc_return_unchecked(&conn->serial));
89355 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
89356 sp->hdr.userStatus = 0;
89357 sp->hdr.securityIndex = conn->security_ix;
89358 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
89359 index bebaa43..2644591 100644
89360 --- a/net/rxrpc/ar-peer.c
89361 +++ b/net/rxrpc/ar-peer.c
89362 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
89363 INIT_LIST_HEAD(&peer->error_targets);
89364 spin_lock_init(&peer->lock);
89365 atomic_set(&peer->usage, 1);
89366 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
89367 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89368 memcpy(&peer->srx, srx, sizeof(*srx));
89369
89370 rxrpc_assess_MTU_size(peer);
89371 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
89372 index 38047f7..9f48511 100644
89373 --- a/net/rxrpc/ar-proc.c
89374 +++ b/net/rxrpc/ar-proc.c
89375 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
89376 atomic_read(&conn->usage),
89377 rxrpc_conn_states[conn->state],
89378 key_serial(conn->key),
89379 - atomic_read(&conn->serial),
89380 - atomic_read(&conn->hi_serial));
89381 + atomic_read_unchecked(&conn->serial),
89382 + atomic_read_unchecked(&conn->hi_serial));
89383
89384 return 0;
89385 }
89386 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
89387 index 92df566..87ec1bf 100644
89388 --- a/net/rxrpc/ar-transport.c
89389 +++ b/net/rxrpc/ar-transport.c
89390 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
89391 spin_lock_init(&trans->client_lock);
89392 rwlock_init(&trans->conn_lock);
89393 atomic_set(&trans->usage, 1);
89394 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
89395 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89396
89397 if (peer->srx.transport.family == AF_INET) {
89398 switch (peer->srx.transport_type) {
89399 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
89400 index f226709..0e735a8 100644
89401 --- a/net/rxrpc/rxkad.c
89402 +++ b/net/rxrpc/rxkad.c
89403 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
89404
89405 len = iov[0].iov_len + iov[1].iov_len;
89406
89407 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89408 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89409 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
89410
89411 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89412 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
89413
89414 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
89415
89416 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
89417 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89418 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
89419
89420 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
89421 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
89422 index 391a245..296b3d7 100644
89423 --- a/net/sctp/ipv6.c
89424 +++ b/net/sctp/ipv6.c
89425 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
89426 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
89427 };
89428
89429 -static struct sctp_af sctp_af_inet6 = {
89430 +static struct sctp_af sctp_af_inet6 __read_only = {
89431 .sa_family = AF_INET6,
89432 .sctp_xmit = sctp_v6_xmit,
89433 .setsockopt = ipv6_setsockopt,
89434 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
89435 #endif
89436 };
89437
89438 -static struct sctp_pf sctp_pf_inet6 = {
89439 +static struct sctp_pf sctp_pf_inet6 __read_only = {
89440 .event_msgname = sctp_inet6_event_msgname,
89441 .skb_msgname = sctp_inet6_skb_msgname,
89442 .af_supported = sctp_inet6_af_supported,
89443 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
89444
89445 void sctp_v6_pf_exit(void)
89446 {
89447 - list_del(&sctp_af_inet6.list);
89448 + pax_list_del(&sctp_af_inet6.list);
89449 }
89450
89451 /* Initialize IPv6 support and register with socket layer. */
89452 diff --git a/net/sctp/probe.c b/net/sctp/probe.c
89453 index ad0dba8..e62c225 100644
89454 --- a/net/sctp/probe.c
89455 +++ b/net/sctp/probe.c
89456 @@ -63,7 +63,7 @@ static struct {
89457 struct timespec tstart;
89458 } sctpw;
89459
89460 -static void printl(const char *fmt, ...)
89461 +static __printf(1, 2) void printl(const char *fmt, ...)
89462 {
89463 va_list args;
89464 int len;
89465 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
89466 index ab3bba8..2fbab4e 100644
89467 --- a/net/sctp/proc.c
89468 +++ b/net/sctp/proc.c
89469 @@ -336,7 +336,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
89470 seq_printf(seq,
89471 "%8pK %8pK %-3d %-3d %-2d %-4d "
89472 "%4d %8d %8d %7d %5lu %-5d %5d ",
89473 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
89474 + assoc, sk,
89475 + sctp_sk(sk)->type, sk->sk_state,
89476 assoc->state, hash,
89477 assoc->assoc_id,
89478 assoc->sndbuf_used,
89479 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
89480 index 1c2e46c..f91cf5e 100644
89481 --- a/net/sctp/protocol.c
89482 +++ b/net/sctp/protocol.c
89483 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
89484 return 0;
89485 }
89486
89487 + pax_open_kernel();
89488 INIT_LIST_HEAD(&af->list);
89489 - list_add_tail(&af->list, &sctp_address_families);
89490 + pax_close_kernel();
89491 + pax_list_add_tail(&af->list, &sctp_address_families);
89492 return 1;
89493 }
89494
89495 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
89496
89497 static struct sctp_af sctp_af_inet;
89498
89499 -static struct sctp_pf sctp_pf_inet = {
89500 +static struct sctp_pf sctp_pf_inet __read_only = {
89501 .event_msgname = sctp_inet_event_msgname,
89502 .skb_msgname = sctp_inet_skb_msgname,
89503 .af_supported = sctp_inet_af_supported,
89504 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
89505 };
89506
89507 /* IPv4 address related functions. */
89508 -static struct sctp_af sctp_af_inet = {
89509 +static struct sctp_af sctp_af_inet __read_only = {
89510 .sa_family = AF_INET,
89511 .sctp_xmit = sctp_v4_xmit,
89512 .setsockopt = ip_setsockopt,
89513 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
89514
89515 static void sctp_v4_pf_exit(void)
89516 {
89517 - list_del(&sctp_af_inet.list);
89518 + pax_list_del(&sctp_af_inet.list);
89519 }
89520
89521 static int sctp_v4_protosw_init(void)
89522 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
89523 index 8aab894..f6b7e7d 100644
89524 --- a/net/sctp/sm_sideeffect.c
89525 +++ b/net/sctp/sm_sideeffect.c
89526 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
89527 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
89528 }
89529
89530 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89531 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89532 NULL,
89533 sctp_generate_t1_cookie_event,
89534 sctp_generate_t1_init_event,
89535 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
89536 index b907073..57fef6c 100644
89537 --- a/net/sctp/socket.c
89538 +++ b/net/sctp/socket.c
89539 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
89540 {
89541 struct sctp_association *asoc;
89542 struct sctp_ulpevent *event;
89543 + struct sctp_event_subscribe subscribe;
89544
89545 if (optlen > sizeof(struct sctp_event_subscribe))
89546 return -EINVAL;
89547 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
89548 + if (copy_from_user(&subscribe, optval, optlen))
89549 return -EFAULT;
89550 + sctp_sk(sk)->subscribe = subscribe;
89551
89552 /*
89553 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
89554 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
89555 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89556 int __user *optlen)
89557 {
89558 + struct sctp_event_subscribe subscribe;
89559 +
89560 if (len <= 0)
89561 return -EINVAL;
89562 if (len > sizeof(struct sctp_event_subscribe))
89563 len = sizeof(struct sctp_event_subscribe);
89564 if (put_user(len, optlen))
89565 return -EFAULT;
89566 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
89567 + subscribe = sctp_sk(sk)->subscribe;
89568 + if (copy_to_user(optval, &subscribe, len))
89569 return -EFAULT;
89570 return 0;
89571 }
89572 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89573 */
89574 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
89575 {
89576 + __u32 autoclose;
89577 +
89578 /* Applicable to UDP-style socket only */
89579 if (sctp_style(sk, TCP))
89580 return -EOPNOTSUPP;
89581 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
89582 len = sizeof(int);
89583 if (put_user(len, optlen))
89584 return -EFAULT;
89585 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
89586 + autoclose = sctp_sk(sk)->autoclose;
89587 + if (copy_to_user(optval, &autoclose, sizeof(int)))
89588 return -EFAULT;
89589 return 0;
89590 }
89591 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
89592 */
89593 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
89594 {
89595 + struct sctp_initmsg initmsg;
89596 +
89597 if (len < sizeof(struct sctp_initmsg))
89598 return -EINVAL;
89599 len = sizeof(struct sctp_initmsg);
89600 if (put_user(len, optlen))
89601 return -EFAULT;
89602 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
89603 + initmsg = sctp_sk(sk)->initmsg;
89604 + if (copy_to_user(optval, &initmsg, len))
89605 return -EFAULT;
89606 return 0;
89607 }
89608 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
89609 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
89610 if (space_left < addrlen)
89611 return -ENOMEM;
89612 + if (addrlen > sizeof(temp) || addrlen < 0)
89613 + return -EFAULT;
89614 if (copy_to_user(to, &temp, addrlen))
89615 return -EFAULT;
89616 to += addrlen;
89617 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
89618 index bf3c6e8..376d8d0 100644
89619 --- a/net/sctp/sysctl.c
89620 +++ b/net/sctp/sysctl.c
89621 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89622 {
89623 struct net *net = current->nsproxy->net_ns;
89624 char tmp[8];
89625 - ctl_table tbl;
89626 + ctl_table_no_const tbl;
89627 int ret;
89628 int changed = 0;
89629 char *none = "none";
89630 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89631
89632 int sctp_sysctl_net_register(struct net *net)
89633 {
89634 - struct ctl_table *table;
89635 + ctl_table_no_const *table;
89636 int i;
89637
89638 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
89639 diff --git a/net/socket.c b/net/socket.c
89640 index 88f759a..c6933de 100644
89641 --- a/net/socket.c
89642 +++ b/net/socket.c
89643 @@ -88,6 +88,7 @@
89644 #include <linux/magic.h>
89645 #include <linux/slab.h>
89646 #include <linux/xattr.h>
89647 +#include <linux/in.h>
89648
89649 #include <asm/uaccess.h>
89650 #include <asm/unistd.h>
89651 @@ -105,6 +106,8 @@
89652 #include <linux/sockios.h>
89653 #include <linux/atalk.h>
89654
89655 +#include <linux/grsock.h>
89656 +
89657 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
89658 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
89659 unsigned long nr_segs, loff_t pos);
89660 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
89661 &sockfs_dentry_operations, SOCKFS_MAGIC);
89662 }
89663
89664 -static struct vfsmount *sock_mnt __read_mostly;
89665 +struct vfsmount *sock_mnt __read_mostly;
89666
89667 static struct file_system_type sock_fs_type = {
89668 .name = "sockfs",
89669 @@ -1268,6 +1271,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
89670 return -EAFNOSUPPORT;
89671 if (type < 0 || type >= SOCK_MAX)
89672 return -EINVAL;
89673 + if (protocol < 0)
89674 + return -EINVAL;
89675
89676 /* Compatibility.
89677
89678 @@ -1399,6 +1404,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
89679 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
89680 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
89681
89682 + if(!gr_search_socket(family, type, protocol)) {
89683 + retval = -EACCES;
89684 + goto out;
89685 + }
89686 +
89687 + if (gr_handle_sock_all(family, type, protocol)) {
89688 + retval = -EACCES;
89689 + goto out;
89690 + }
89691 +
89692 retval = sock_create(family, type, protocol, &sock);
89693 if (retval < 0)
89694 goto out;
89695 @@ -1526,6 +1541,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89696 if (sock) {
89697 err = move_addr_to_kernel(umyaddr, addrlen, &address);
89698 if (err >= 0) {
89699 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
89700 + err = -EACCES;
89701 + goto error;
89702 + }
89703 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
89704 + if (err)
89705 + goto error;
89706 +
89707 err = security_socket_bind(sock,
89708 (struct sockaddr *)&address,
89709 addrlen);
89710 @@ -1534,6 +1557,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89711 (struct sockaddr *)
89712 &address, addrlen);
89713 }
89714 +error:
89715 fput_light(sock->file, fput_needed);
89716 }
89717 return err;
89718 @@ -1557,10 +1581,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
89719 if ((unsigned int)backlog > somaxconn)
89720 backlog = somaxconn;
89721
89722 + if (gr_handle_sock_server_other(sock->sk)) {
89723 + err = -EPERM;
89724 + goto error;
89725 + }
89726 +
89727 + err = gr_search_listen(sock);
89728 + if (err)
89729 + goto error;
89730 +
89731 err = security_socket_listen(sock, backlog);
89732 if (!err)
89733 err = sock->ops->listen(sock, backlog);
89734
89735 +error:
89736 fput_light(sock->file, fput_needed);
89737 }
89738 return err;
89739 @@ -1604,6 +1638,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
89740 newsock->type = sock->type;
89741 newsock->ops = sock->ops;
89742
89743 + if (gr_handle_sock_server_other(sock->sk)) {
89744 + err = -EPERM;
89745 + sock_release(newsock);
89746 + goto out_put;
89747 + }
89748 +
89749 + err = gr_search_accept(sock);
89750 + if (err) {
89751 + sock_release(newsock);
89752 + goto out_put;
89753 + }
89754 +
89755 /*
89756 * We don't need try_module_get here, as the listening socket (sock)
89757 * has the protocol module (sock->ops->owner) held.
89758 @@ -1649,6 +1695,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
89759 fd_install(newfd, newfile);
89760 err = newfd;
89761
89762 + gr_attach_curr_ip(newsock->sk);
89763 +
89764 out_put:
89765 fput_light(sock->file, fput_needed);
89766 out:
89767 @@ -1681,6 +1729,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
89768 int, addrlen)
89769 {
89770 struct socket *sock;
89771 + struct sockaddr *sck;
89772 struct sockaddr_storage address;
89773 int err, fput_needed;
89774
89775 @@ -1691,6 +1740,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
89776 if (err < 0)
89777 goto out_put;
89778
89779 + sck = (struct sockaddr *)&address;
89780 +
89781 + if (gr_handle_sock_client(sck)) {
89782 + err = -EACCES;
89783 + goto out_put;
89784 + }
89785 +
89786 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
89787 + if (err)
89788 + goto out_put;
89789 +
89790 err =
89791 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
89792 if (err)
89793 @@ -1772,6 +1832,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
89794 * the protocol.
89795 */
89796
89797 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
89798 +
89799 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
89800 unsigned int, flags, struct sockaddr __user *, addr,
89801 int, addr_len)
89802 @@ -1838,7 +1900,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
89803 struct socket *sock;
89804 struct iovec iov;
89805 struct msghdr msg;
89806 - struct sockaddr_storage address;
89807 + struct sockaddr_storage address = { };
89808 int err, err2;
89809 int fput_needed;
89810
89811 @@ -2045,7 +2107,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
89812 * checking falls down on this.
89813 */
89814 if (copy_from_user(ctl_buf,
89815 - (void __user __force *)msg_sys->msg_control,
89816 + (void __force_user *)msg_sys->msg_control,
89817 ctl_len))
89818 goto out_freectl;
89819 msg_sys->msg_control = ctl_buf;
89820 @@ -2185,7 +2247,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
89821 int err, total_len, len;
89822
89823 /* kernel mode address */
89824 - struct sockaddr_storage addr;
89825 + struct sockaddr_storage addr = { };
89826
89827 /* user mode address pointers */
89828 struct sockaddr __user *uaddr;
89829 @@ -2213,7 +2275,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
89830 * kernel msghdr to use the kernel address space)
89831 */
89832
89833 - uaddr = (__force void __user *)msg_sys->msg_name;
89834 + uaddr = (void __force_user *)msg_sys->msg_name;
89835 uaddr_len = COMPAT_NAMELEN(msg);
89836 if (MSG_CMSG_COMPAT & flags) {
89837 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
89838 @@ -2952,7 +3014,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
89839 old_fs = get_fs();
89840 set_fs(KERNEL_DS);
89841 err = dev_ioctl(net, cmd,
89842 - (struct ifreq __user __force *) &kifr);
89843 + (struct ifreq __force_user *) &kifr);
89844 set_fs(old_fs);
89845
89846 return err;
89847 @@ -3061,7 +3123,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
89848
89849 old_fs = get_fs();
89850 set_fs(KERNEL_DS);
89851 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
89852 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
89853 set_fs(old_fs);
89854
89855 if (cmd == SIOCGIFMAP && !err) {
89856 @@ -3166,7 +3228,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
89857 ret |= __get_user(rtdev, &(ur4->rt_dev));
89858 if (rtdev) {
89859 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
89860 - r4.rt_dev = (char __user __force *)devname;
89861 + r4.rt_dev = (char __force_user *)devname;
89862 devname[15] = 0;
89863 } else
89864 r4.rt_dev = NULL;
89865 @@ -3392,8 +3454,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
89866 int __user *uoptlen;
89867 int err;
89868
89869 - uoptval = (char __user __force *) optval;
89870 - uoptlen = (int __user __force *) optlen;
89871 + uoptval = (char __force_user *) optval;
89872 + uoptlen = (int __force_user *) optlen;
89873
89874 set_fs(KERNEL_DS);
89875 if (level == SOL_SOCKET)
89876 @@ -3413,7 +3475,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
89877 char __user *uoptval;
89878 int err;
89879
89880 - uoptval = (char __user __force *) optval;
89881 + uoptval = (char __force_user *) optval;
89882
89883 set_fs(KERNEL_DS);
89884 if (level == SOL_SOCKET)
89885 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
89886 index d5f35f1..da2680b5 100644
89887 --- a/net/sunrpc/clnt.c
89888 +++ b/net/sunrpc/clnt.c
89889 @@ -1283,7 +1283,9 @@ call_start(struct rpc_task *task)
89890 (RPC_IS_ASYNC(task) ? "async" : "sync"));
89891
89892 /* Increment call count */
89893 - task->tk_msg.rpc_proc->p_count++;
89894 + pax_open_kernel();
89895 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
89896 + pax_close_kernel();
89897 clnt->cl_stats->rpccnt++;
89898 task->tk_action = call_reserve;
89899 }
89900 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
89901 index f8529fc..ce8c643 100644
89902 --- a/net/sunrpc/sched.c
89903 +++ b/net/sunrpc/sched.c
89904 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
89905 #ifdef RPC_DEBUG
89906 static void rpc_task_set_debuginfo(struct rpc_task *task)
89907 {
89908 - static atomic_t rpc_pid;
89909 + static atomic_unchecked_t rpc_pid;
89910
89911 - task->tk_pid = atomic_inc_return(&rpc_pid);
89912 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
89913 }
89914 #else
89915 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
89916 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
89917 index 89a588b..ba2cef8 100644
89918 --- a/net/sunrpc/svc.c
89919 +++ b/net/sunrpc/svc.c
89920 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
89921 svc_putnl(resv, RPC_SUCCESS);
89922
89923 /* Bump per-procedure stats counter */
89924 - procp->pc_count++;
89925 + pax_open_kernel();
89926 + (*(unsigned int *)&procp->pc_count)++;
89927 + pax_close_kernel();
89928
89929 /* Initialize storage for argp and resp */
89930 memset(rqstp->rq_argp, 0, procp->pc_argsize);
89931 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
89932 index 8343737..677025e 100644
89933 --- a/net/sunrpc/xprtrdma/svc_rdma.c
89934 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
89935 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
89936 static unsigned int min_max_inline = 4096;
89937 static unsigned int max_max_inline = 65536;
89938
89939 -atomic_t rdma_stat_recv;
89940 -atomic_t rdma_stat_read;
89941 -atomic_t rdma_stat_write;
89942 -atomic_t rdma_stat_sq_starve;
89943 -atomic_t rdma_stat_rq_starve;
89944 -atomic_t rdma_stat_rq_poll;
89945 -atomic_t rdma_stat_rq_prod;
89946 -atomic_t rdma_stat_sq_poll;
89947 -atomic_t rdma_stat_sq_prod;
89948 +atomic_unchecked_t rdma_stat_recv;
89949 +atomic_unchecked_t rdma_stat_read;
89950 +atomic_unchecked_t rdma_stat_write;
89951 +atomic_unchecked_t rdma_stat_sq_starve;
89952 +atomic_unchecked_t rdma_stat_rq_starve;
89953 +atomic_unchecked_t rdma_stat_rq_poll;
89954 +atomic_unchecked_t rdma_stat_rq_prod;
89955 +atomic_unchecked_t rdma_stat_sq_poll;
89956 +atomic_unchecked_t rdma_stat_sq_prod;
89957
89958 /* Temporary NFS request map and context caches */
89959 struct kmem_cache *svc_rdma_map_cachep;
89960 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
89961 len -= *ppos;
89962 if (len > *lenp)
89963 len = *lenp;
89964 - if (len && copy_to_user(buffer, str_buf, len))
89965 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
89966 return -EFAULT;
89967 *lenp = len;
89968 *ppos += len;
89969 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
89970 {
89971 .procname = "rdma_stat_read",
89972 .data = &rdma_stat_read,
89973 - .maxlen = sizeof(atomic_t),
89974 + .maxlen = sizeof(atomic_unchecked_t),
89975 .mode = 0644,
89976 .proc_handler = read_reset_stat,
89977 },
89978 {
89979 .procname = "rdma_stat_recv",
89980 .data = &rdma_stat_recv,
89981 - .maxlen = sizeof(atomic_t),
89982 + .maxlen = sizeof(atomic_unchecked_t),
89983 .mode = 0644,
89984 .proc_handler = read_reset_stat,
89985 },
89986 {
89987 .procname = "rdma_stat_write",
89988 .data = &rdma_stat_write,
89989 - .maxlen = sizeof(atomic_t),
89990 + .maxlen = sizeof(atomic_unchecked_t),
89991 .mode = 0644,
89992 .proc_handler = read_reset_stat,
89993 },
89994 {
89995 .procname = "rdma_stat_sq_starve",
89996 .data = &rdma_stat_sq_starve,
89997 - .maxlen = sizeof(atomic_t),
89998 + .maxlen = sizeof(atomic_unchecked_t),
89999 .mode = 0644,
90000 .proc_handler = read_reset_stat,
90001 },
90002 {
90003 .procname = "rdma_stat_rq_starve",
90004 .data = &rdma_stat_rq_starve,
90005 - .maxlen = sizeof(atomic_t),
90006 + .maxlen = sizeof(atomic_unchecked_t),
90007 .mode = 0644,
90008 .proc_handler = read_reset_stat,
90009 },
90010 {
90011 .procname = "rdma_stat_rq_poll",
90012 .data = &rdma_stat_rq_poll,
90013 - .maxlen = sizeof(atomic_t),
90014 + .maxlen = sizeof(atomic_unchecked_t),
90015 .mode = 0644,
90016 .proc_handler = read_reset_stat,
90017 },
90018 {
90019 .procname = "rdma_stat_rq_prod",
90020 .data = &rdma_stat_rq_prod,
90021 - .maxlen = sizeof(atomic_t),
90022 + .maxlen = sizeof(atomic_unchecked_t),
90023 .mode = 0644,
90024 .proc_handler = read_reset_stat,
90025 },
90026 {
90027 .procname = "rdma_stat_sq_poll",
90028 .data = &rdma_stat_sq_poll,
90029 - .maxlen = sizeof(atomic_t),
90030 + .maxlen = sizeof(atomic_unchecked_t),
90031 .mode = 0644,
90032 .proc_handler = read_reset_stat,
90033 },
90034 {
90035 .procname = "rdma_stat_sq_prod",
90036 .data = &rdma_stat_sq_prod,
90037 - .maxlen = sizeof(atomic_t),
90038 + .maxlen = sizeof(atomic_unchecked_t),
90039 .mode = 0644,
90040 .proc_handler = read_reset_stat,
90041 },
90042 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90043 index 0ce7552..d074459 100644
90044 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90045 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90046 @@ -501,7 +501,7 @@ next_sge:
90047 svc_rdma_put_context(ctxt, 0);
90048 goto out;
90049 }
90050 - atomic_inc(&rdma_stat_read);
90051 + atomic_inc_unchecked(&rdma_stat_read);
90052
90053 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90054 chl_map->ch[ch_no].count -= read_wr.num_sge;
90055 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90056 dto_q);
90057 list_del_init(&ctxt->dto_q);
90058 } else {
90059 - atomic_inc(&rdma_stat_rq_starve);
90060 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90061 clear_bit(XPT_DATA, &xprt->xpt_flags);
90062 ctxt = NULL;
90063 }
90064 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90065 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90066 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90067 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90068 - atomic_inc(&rdma_stat_recv);
90069 + atomic_inc_unchecked(&rdma_stat_recv);
90070
90071 /* Build up the XDR from the receive buffers. */
90072 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90073 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90074 index c1d124d..acfc59e 100644
90075 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90076 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90077 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90078 write_wr.wr.rdma.remote_addr = to;
90079
90080 /* Post It */
90081 - atomic_inc(&rdma_stat_write);
90082 + atomic_inc_unchecked(&rdma_stat_write);
90083 if (svc_rdma_send(xprt, &write_wr))
90084 goto err;
90085 return 0;
90086 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90087 index 62e4f9b..dd3f2d7 100644
90088 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90089 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90090 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90091 return;
90092
90093 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90094 - atomic_inc(&rdma_stat_rq_poll);
90095 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90096
90097 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90098 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90099 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90100 }
90101
90102 if (ctxt)
90103 - atomic_inc(&rdma_stat_rq_prod);
90104 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90105
90106 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90107 /*
90108 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90109 return;
90110
90111 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90112 - atomic_inc(&rdma_stat_sq_poll);
90113 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90114 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90115 if (wc.status != IB_WC_SUCCESS)
90116 /* Close the transport */
90117 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90118 }
90119
90120 if (ctxt)
90121 - atomic_inc(&rdma_stat_sq_prod);
90122 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90123 }
90124
90125 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90126 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90127 spin_lock_bh(&xprt->sc_lock);
90128 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90129 spin_unlock_bh(&xprt->sc_lock);
90130 - atomic_inc(&rdma_stat_sq_starve);
90131 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90132
90133 /* See if we can opportunistically reap SQ WR to make room */
90134 sq_cq_reap(xprt);
90135 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90136 index 9bc6db0..47ac8c0 100644
90137 --- a/net/sysctl_net.c
90138 +++ b/net/sysctl_net.c
90139 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90140 kgid_t root_gid = make_kgid(net->user_ns, 0);
90141
90142 /* Allow network administrator to have same access as root. */
90143 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90144 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90145 uid_eq(root_uid, current_uid())) {
90146 int mode = (table->mode >> 6) & 7;
90147 return (mode << 6) | (mode << 3) | mode;
90148 diff --git a/net/tipc/link.c b/net/tipc/link.c
90149 index daa6080..2bbbe70 100644
90150 --- a/net/tipc/link.c
90151 +++ b/net/tipc/link.c
90152 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90153 struct tipc_msg fragm_hdr;
90154 struct sk_buff *buf, *buf_chain, *prev;
90155 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90156 - const unchar *sect_crs;
90157 + const unchar __user *sect_crs;
90158 int curr_sect;
90159 u32 fragm_no;
90160
90161 @@ -1242,7 +1242,7 @@ again:
90162
90163 if (!sect_rest) {
90164 sect_rest = msg_sect[++curr_sect].iov_len;
90165 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90166 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90167 }
90168
90169 if (sect_rest < fragm_rest)
90170 @@ -1261,7 +1261,7 @@ error:
90171 }
90172 } else
90173 skb_copy_to_linear_data_offset(buf, fragm_crs,
90174 - sect_crs, sz);
90175 + (const void __force_kernel *)sect_crs, sz);
90176 sect_crs += sz;
90177 sect_rest -= sz;
90178 fragm_crs += sz;
90179 @@ -2306,8 +2306,11 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
90180 struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf);
90181 u32 msg_typ = msg_type(tunnel_msg);
90182 u32 msg_count = msg_msgcnt(tunnel_msg);
90183 + u32 bearer_id = msg_bearer_id(tunnel_msg);
90184
90185 - dest_link = (*l_ptr)->owner->links[msg_bearer_id(tunnel_msg)];
90186 + if (bearer_id >= MAX_BEARERS)
90187 + goto exit;
90188 + dest_link = (*l_ptr)->owner->links[bearer_id];
90189 if (!dest_link)
90190 goto exit;
90191 if (dest_link == *l_ptr) {
90192 @@ -2521,14 +2524,16 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
90193 struct tipc_msg *imsg = (struct tipc_msg *)msg_data(fragm);
90194 u32 msg_sz = msg_size(imsg);
90195 u32 fragm_sz = msg_data_sz(fragm);
90196 - u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
90197 + u32 exp_fragm_cnt;
90198 u32 max = TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE;
90199 +
90200 if (msg_type(imsg) == TIPC_MCAST_MSG)
90201 max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE;
90202 - if (msg_size(imsg) > max) {
90203 + if (fragm_sz == 0 || msg_size(imsg) > max) {
90204 kfree_skb(fbuf);
90205 return 0;
90206 }
90207 + exp_fragm_cnt = msg_sz / fragm_sz + !!(msg_sz % fragm_sz);
90208 pbuf = tipc_buf_acquire(msg_size(imsg));
90209 if (pbuf != NULL) {
90210 pbuf->next = *pending;
90211 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90212 index f2db8a8..9245aa4 100644
90213 --- a/net/tipc/msg.c
90214 +++ b/net/tipc/msg.c
90215 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90216 msg_sect[cnt].iov_len);
90217 else
90218 skb_copy_to_linear_data_offset(*buf, pos,
90219 - msg_sect[cnt].iov_base,
90220 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90221 msg_sect[cnt].iov_len);
90222 pos += msg_sect[cnt].iov_len;
90223 }
90224 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90225 index 6b42d47..2ac24d5 100644
90226 --- a/net/tipc/subscr.c
90227 +++ b/net/tipc/subscr.c
90228 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90229 {
90230 struct iovec msg_sect;
90231
90232 - msg_sect.iov_base = (void *)&sub->evt;
90233 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90234 msg_sect.iov_len = sizeof(struct tipc_event);
90235
90236 sub->evt.event = htohl(event, sub->swap);
90237 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90238 index 2db702d..09a77488 100644
90239 --- a/net/unix/af_unix.c
90240 +++ b/net/unix/af_unix.c
90241 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
90242 err = -ECONNREFUSED;
90243 if (!S_ISSOCK(inode->i_mode))
90244 goto put_fail;
90245 +
90246 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90247 + err = -EACCES;
90248 + goto put_fail;
90249 + }
90250 +
90251 u = unix_find_socket_byinode(inode);
90252 if (!u)
90253 goto put_fail;
90254 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
90255 if (u) {
90256 struct dentry *dentry;
90257 dentry = unix_sk(u)->path.dentry;
90258 +
90259 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90260 + err = -EPERM;
90261 + sock_put(u);
90262 + goto fail;
90263 + }
90264 +
90265 if (dentry)
90266 touch_atime(&unix_sk(u)->path);
90267 } else
90268 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90269 */
90270 err = security_path_mknod(&path, dentry, mode, 0);
90271 if (!err) {
90272 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90273 + err = -EACCES;
90274 + goto out;
90275 + }
90276 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90277 if (!err) {
90278 res->mnt = mntget(path.mnt);
90279 res->dentry = dget(dentry);
90280 + gr_handle_create(dentry, path.mnt);
90281 }
90282 }
90283 +out:
90284 done_path_create(&path, dentry);
90285 return err;
90286 }
90287 @@ -2323,9 +2342,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90288 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90289 "Inode Path\n");
90290 else {
90291 - struct sock *s = v;
90292 + struct sock *s = v, *peer;
90293 struct unix_sock *u = unix_sk(s);
90294 unix_state_lock(s);
90295 + peer = unix_peer(s);
90296 + unix_state_unlock(s);
90297 +
90298 + unix_state_double_lock(s, peer);
90299
90300 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
90301 s,
90302 @@ -2352,8 +2375,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90303 }
90304 for ( ; i < len; i++)
90305 seq_putc(seq, u->addr->name->sun_path[i]);
90306 - }
90307 - unix_state_unlock(s);
90308 + } else if (peer)
90309 + seq_printf(seq, " P%lu", sock_i_ino(peer));
90310 +
90311 + unix_state_double_unlock(s, peer);
90312 seq_putc(seq, '\n');
90313 }
90314
90315 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
90316 index 8800604..0526440 100644
90317 --- a/net/unix/sysctl_net_unix.c
90318 +++ b/net/unix/sysctl_net_unix.c
90319 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
90320
90321 int __net_init unix_sysctl_register(struct net *net)
90322 {
90323 - struct ctl_table *table;
90324 + ctl_table_no_const *table;
90325
90326 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
90327 if (table == NULL)
90328 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
90329 index c8717c1..08539f5 100644
90330 --- a/net/wireless/wext-core.c
90331 +++ b/net/wireless/wext-core.c
90332 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90333 */
90334
90335 /* Support for very large requests */
90336 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
90337 - (user_length > descr->max_tokens)) {
90338 + if (user_length > descr->max_tokens) {
90339 /* Allow userspace to GET more than max so
90340 * we can support any size GET requests.
90341 * There is still a limit : -ENOMEM.
90342 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90343 }
90344 }
90345
90346 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
90347 - /*
90348 - * If this is a GET, but not NOMAX, it means that the extra
90349 - * data is not bounded by userspace, but by max_tokens. Thus
90350 - * set the length to max_tokens. This matches the extra data
90351 - * allocation.
90352 - * The driver should fill it with the number of tokens it
90353 - * provided, and it may check iwp->length rather than having
90354 - * knowledge of max_tokens. If the driver doesn't change the
90355 - * iwp->length, this ioctl just copies back max_token tokens
90356 - * filled with zeroes. Hopefully the driver isn't claiming
90357 - * them to be valid data.
90358 - */
90359 - iwp->length = descr->max_tokens;
90360 - }
90361 -
90362 err = handler(dev, info, (union iwreq_data *) iwp, extra);
90363
90364 iwp->length += essid_compat;
90365 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
90366 index 167c67d..3f2ae427 100644
90367 --- a/net/xfrm/xfrm_policy.c
90368 +++ b/net/xfrm/xfrm_policy.c
90369 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
90370 {
90371 policy->walk.dead = 1;
90372
90373 - atomic_inc(&policy->genid);
90374 + atomic_inc_unchecked(&policy->genid);
90375
90376 del_timer(&policy->polq.hold_timer);
90377 xfrm_queue_purge(&policy->polq.hold_queue);
90378 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
90379 hlist_add_head(&policy->bydst, chain);
90380 xfrm_pol_hold(policy);
90381 net->xfrm.policy_count[dir]++;
90382 - atomic_inc(&flow_cache_genid);
90383 + atomic_inc_unchecked(&flow_cache_genid);
90384 rt_genid_bump(net);
90385 if (delpol) {
90386 xfrm_policy_requeue(delpol, policy);
90387 @@ -1611,7 +1611,7 @@ free_dst:
90388 goto out;
90389 }
90390
90391 -static int inline
90392 +static inline int
90393 xfrm_dst_alloc_copy(void **target, const void *src, int size)
90394 {
90395 if (!*target) {
90396 @@ -1623,7 +1623,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
90397 return 0;
90398 }
90399
90400 -static int inline
90401 +static inline int
90402 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90403 {
90404 #ifdef CONFIG_XFRM_SUB_POLICY
90405 @@ -1635,7 +1635,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90406 #endif
90407 }
90408
90409 -static int inline
90410 +static inline int
90411 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
90412 {
90413 #ifdef CONFIG_XFRM_SUB_POLICY
90414 @@ -1729,7 +1729,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
90415
90416 xdst->num_pols = num_pols;
90417 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
90418 - xdst->policy_genid = atomic_read(&pols[0]->genid);
90419 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
90420
90421 return xdst;
90422 }
90423 @@ -2598,7 +2598,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
90424 if (xdst->xfrm_genid != dst->xfrm->genid)
90425 return 0;
90426 if (xdst->num_pols > 0 &&
90427 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
90428 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
90429 return 0;
90430
90431 mtu = dst_mtu(dst->child);
90432 @@ -2686,8 +2686,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
90433 dst_ops->link_failure = xfrm_link_failure;
90434 if (likely(dst_ops->neigh_lookup == NULL))
90435 dst_ops->neigh_lookup = xfrm_neigh_lookup;
90436 - if (likely(afinfo->garbage_collect == NULL))
90437 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90438 + if (likely(afinfo->garbage_collect == NULL)) {
90439 + pax_open_kernel();
90440 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90441 + pax_close_kernel();
90442 + }
90443 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
90444 }
90445 spin_unlock(&xfrm_policy_afinfo_lock);
90446 @@ -2741,7 +2744,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
90447 dst_ops->check = NULL;
90448 dst_ops->negative_advice = NULL;
90449 dst_ops->link_failure = NULL;
90450 - afinfo->garbage_collect = NULL;
90451 + pax_open_kernel();
90452 + *(void **)&afinfo->garbage_collect = NULL;
90453 + pax_close_kernel();
90454 }
90455 return err;
90456 }
90457 @@ -3124,7 +3129,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
90458 sizeof(pol->xfrm_vec[i].saddr));
90459 pol->xfrm_vec[i].encap_family = mp->new_family;
90460 /* flush bundles */
90461 - atomic_inc(&pol->genid);
90462 + atomic_inc_unchecked(&pol->genid);
90463 }
90464 }
90465
90466 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
90467 index 2c341bd..4404211 100644
90468 --- a/net/xfrm/xfrm_state.c
90469 +++ b/net/xfrm/xfrm_state.c
90470 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
90471
90472 if (unlikely(afinfo == NULL))
90473 return -EAFNOSUPPORT;
90474 - typemap = afinfo->type_map;
90475 + typemap = (const struct xfrm_type **)afinfo->type_map;
90476 spin_lock_bh(&xfrm_type_lock);
90477
90478 - if (likely(typemap[type->proto] == NULL))
90479 + if (likely(typemap[type->proto] == NULL)) {
90480 + pax_open_kernel();
90481 typemap[type->proto] = type;
90482 - else
90483 + pax_close_kernel();
90484 + } else
90485 err = -EEXIST;
90486 spin_unlock_bh(&xfrm_type_lock);
90487 xfrm_state_put_afinfo(afinfo);
90488 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
90489
90490 if (unlikely(afinfo == NULL))
90491 return -EAFNOSUPPORT;
90492 - typemap = afinfo->type_map;
90493 + typemap = (const struct xfrm_type **)afinfo->type_map;
90494 spin_lock_bh(&xfrm_type_lock);
90495
90496 if (unlikely(typemap[type->proto] != type))
90497 err = -ENOENT;
90498 - else
90499 + else {
90500 + pax_open_kernel();
90501 typemap[type->proto] = NULL;
90502 + pax_close_kernel();
90503 + }
90504 spin_unlock_bh(&xfrm_type_lock);
90505 xfrm_state_put_afinfo(afinfo);
90506 return err;
90507 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
90508 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
90509 {
90510 struct xfrm_state_afinfo *afinfo;
90511 - const struct xfrm_type **typemap;
90512 const struct xfrm_type *type;
90513 int modload_attempted = 0;
90514
90515 @@ -222,9 +226,8 @@ retry:
90516 afinfo = xfrm_state_get_afinfo(family);
90517 if (unlikely(afinfo == NULL))
90518 return NULL;
90519 - typemap = afinfo->type_map;
90520
90521 - type = typemap[proto];
90522 + type = afinfo->type_map[proto];
90523 if (unlikely(type && !try_module_get(type->owner)))
90524 type = NULL;
90525 if (!type && !modload_attempted) {
90526 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90527 return -EAFNOSUPPORT;
90528
90529 err = -EEXIST;
90530 - modemap = afinfo->mode_map;
90531 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90532 spin_lock_bh(&xfrm_mode_lock);
90533 if (modemap[mode->encap])
90534 goto out;
90535 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90536 if (!try_module_get(afinfo->owner))
90537 goto out;
90538
90539 - mode->afinfo = afinfo;
90540 + pax_open_kernel();
90541 + *(const void **)&mode->afinfo = afinfo;
90542 modemap[mode->encap] = mode;
90543 + pax_close_kernel();
90544 err = 0;
90545
90546 out:
90547 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
90548 return -EAFNOSUPPORT;
90549
90550 err = -ENOENT;
90551 - modemap = afinfo->mode_map;
90552 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90553 spin_lock_bh(&xfrm_mode_lock);
90554 if (likely(modemap[mode->encap] == mode)) {
90555 + pax_open_kernel();
90556 modemap[mode->encap] = NULL;
90557 + pax_close_kernel();
90558 module_put(mode->afinfo->owner);
90559 err = 0;
90560 }
90561 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
90562 index 05a6e3d..6716ec9 100644
90563 --- a/net/xfrm/xfrm_sysctl.c
90564 +++ b/net/xfrm/xfrm_sysctl.c
90565 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
90566
90567 int __net_init xfrm_sysctl_init(struct net *net)
90568 {
90569 - struct ctl_table *table;
90570 + ctl_table_no_const *table;
90571
90572 __xfrm_sysctl_init(net);
90573
90574 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
90575 index 0e801c3..5c8ad3b 100644
90576 --- a/scripts/Makefile.build
90577 +++ b/scripts/Makefile.build
90578 @@ -111,7 +111,7 @@ endif
90579 endif
90580
90581 # Do not include host rules unless needed
90582 -ifneq ($(hostprogs-y)$(hostprogs-m),)
90583 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
90584 include scripts/Makefile.host
90585 endif
90586
90587 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
90588 index 686cb0d..9d653bf 100644
90589 --- a/scripts/Makefile.clean
90590 +++ b/scripts/Makefile.clean
90591 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
90592 __clean-files := $(extra-y) $(always) \
90593 $(targets) $(clean-files) \
90594 $(host-progs) \
90595 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
90596 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
90597 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
90598
90599 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
90600
90601 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
90602 index 1ac414f..38575f7 100644
90603 --- a/scripts/Makefile.host
90604 +++ b/scripts/Makefile.host
90605 @@ -31,6 +31,8 @@
90606 # Note: Shared libraries consisting of C++ files are not supported
90607
90608 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
90609 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
90610 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
90611
90612 # C code
90613 # Executables compiled from a single .c file
90614 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
90615 # Shared libaries (only .c supported)
90616 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
90617 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
90618 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
90619 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
90620 # Remove .so files from "xxx-objs"
90621 host-cobjs := $(filter-out %.so,$(host-cobjs))
90622 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
90623
90624 -#Object (.o) files used by the shared libaries
90625 +# Object (.o) files used by the shared libaries
90626 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
90627 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
90628
90629 # output directory for programs/.o files
90630 # hostprogs-y := tools/build may have been specified. Retrieve directory
90631 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
90632 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
90633 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
90634 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
90635 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
90636 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
90637 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
90638 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
90639
90640 obj-dirs += $(host-objdirs)
90641 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
90642 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
90643 $(call if_changed_dep,host-cshobjs)
90644
90645 +# Compile .c file, create position independent .o file
90646 +# host-cxxshobjs -> .o
90647 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
90648 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
90649 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
90650 + $(call if_changed_dep,host-cxxshobjs)
90651 +
90652 # Link a shared library, based on position independent .o files
90653 # *.o -> .so shared library (host-cshlib)
90654 quiet_cmd_host-cshlib = HOSTLLD -shared $@
90655 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
90656 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
90657 $(call if_changed,host-cshlib)
90658
90659 +# Link a shared library, based on position independent .o files
90660 +# *.o -> .so shared library (host-cxxshlib)
90661 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
90662 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
90663 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
90664 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
90665 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
90666 + $(call if_changed,host-cxxshlib)
90667 +
90668 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
90669 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
90670 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
90671
90672 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
90673 index 7f6425e..9864506 100644
90674 --- a/scripts/basic/fixdep.c
90675 +++ b/scripts/basic/fixdep.c
90676 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
90677 /*
90678 * Lookup a value in the configuration string.
90679 */
90680 -static int is_defined_config(const char *name, int len, unsigned int hash)
90681 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
90682 {
90683 struct item *aux;
90684
90685 @@ -211,10 +211,10 @@ static void clear_config(void)
90686 /*
90687 * Record the use of a CONFIG_* word.
90688 */
90689 -static void use_config(const char *m, int slen)
90690 +static void use_config(const char *m, unsigned int slen)
90691 {
90692 unsigned int hash = strhash(m, slen);
90693 - int c, i;
90694 + unsigned int c, i;
90695
90696 if (is_defined_config(m, slen, hash))
90697 return;
90698 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
90699
90700 static void parse_config_file(const char *map, size_t len)
90701 {
90702 - const int *end = (const int *) (map + len);
90703 + const unsigned int *end = (const unsigned int *) (map + len);
90704 /* start at +1, so that p can never be < map */
90705 - const int *m = (const int *) map + 1;
90706 + const unsigned int *m = (const unsigned int *) map + 1;
90707 const char *p, *q;
90708
90709 for (; m < end; m++) {
90710 @@ -406,7 +406,7 @@ static void print_deps(void)
90711 static void traps(void)
90712 {
90713 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
90714 - int *p = (int *)test;
90715 + unsigned int *p = (unsigned int *)test;
90716
90717 if (*p != INT_CONF) {
90718 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
90719 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
90720 new file mode 100644
90721 index 0000000..5e0222d
90722 --- /dev/null
90723 +++ b/scripts/gcc-plugin.sh
90724 @@ -0,0 +1,17 @@
90725 +#!/bin/bash
90726 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
90727 +#include "gcc-plugin.h"
90728 +#include "tree.h"
90729 +#include "tm.h"
90730 +#include "rtl.h"
90731 +#ifdef ENABLE_BUILD_WITH_CXX
90732 +#warning $2
90733 +#else
90734 +#warning $1
90735 +#endif
90736 +EOF`
90737 +if [ $? -eq 0 ]
90738 +then
90739 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
90740 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
90741 +fi
90742 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
90743 index 581ca99..a6ff02e 100644
90744 --- a/scripts/headers_install.pl
90745 +++ b/scripts/headers_install.pl
90746 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
90747 $line =~ s/([\s(])__user\s/$1/g;
90748 $line =~ s/([\s(])__force\s/$1/g;
90749 $line =~ s/([\s(])__iomem\s/$1/g;
90750 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
90751 $line =~ s/\s__attribute_const__\s/ /g;
90752 $line =~ s/\s__attribute_const__$//g;
90753 $line =~ s/\b__packed\b/__attribute__((packed))/g;
90754 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
90755 index 3d569d6..0c09522 100644
90756 --- a/scripts/link-vmlinux.sh
90757 +++ b/scripts/link-vmlinux.sh
90758 @@ -159,7 +159,7 @@ else
90759 fi;
90760
90761 # final build of init/
90762 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
90763 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
90764
90765 kallsymso=""
90766 kallsyms_vmlinux=""
90767 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
90768 index 771ac17..9f0d3ee 100644
90769 --- a/scripts/mod/file2alias.c
90770 +++ b/scripts/mod/file2alias.c
90771 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
90772 unsigned long size, unsigned long id_size,
90773 void *symval)
90774 {
90775 - int i;
90776 + unsigned int i;
90777
90778 if (size % id_size || size < id_size) {
90779 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
90780 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
90781 /* USB is special because the bcdDevice can be matched against a numeric range */
90782 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
90783 static void do_usb_entry(void *symval,
90784 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
90785 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
90786 unsigned char range_lo, unsigned char range_hi,
90787 unsigned char max, struct module *mod)
90788 {
90789 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
90790 {
90791 unsigned int devlo, devhi;
90792 unsigned char chi, clo, max;
90793 - int ndigits;
90794 + unsigned int ndigits;
90795
90796 DEF_FIELD(symval, usb_device_id, match_flags);
90797 DEF_FIELD(symval, usb_device_id, idVendor);
90798 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
90799 for (i = 0; i < count; i++) {
90800 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
90801 char acpi_id[sizeof(*id)];
90802 - int j;
90803 + unsigned int j;
90804
90805 buf_printf(&mod->dev_table_buf,
90806 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
90807 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
90808
90809 for (j = 0; j < PNP_MAX_DEVICES; j++) {
90810 const char *id = (char *)(*devs)[j].id;
90811 - int i2, j2;
90812 + unsigned int i2, j2;
90813 int dup = 0;
90814
90815 if (!id[0])
90816 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
90817 /* add an individual alias for every device entry */
90818 if (!dup) {
90819 char acpi_id[PNP_ID_LEN];
90820 - int k;
90821 + unsigned int k;
90822
90823 buf_printf(&mod->dev_table_buf,
90824 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
90825 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
90826 static int do_dmi_entry(const char *filename, void *symval,
90827 char *alias)
90828 {
90829 - int i, j;
90830 + unsigned int i, j;
90831 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
90832 sprintf(alias, "dmi*");
90833
90834 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
90835 index 78b30c1..536850d 100644
90836 --- a/scripts/mod/modpost.c
90837 +++ b/scripts/mod/modpost.c
90838 @@ -931,6 +931,7 @@ enum mismatch {
90839 ANY_INIT_TO_ANY_EXIT,
90840 ANY_EXIT_TO_ANY_INIT,
90841 EXPORT_TO_INIT_EXIT,
90842 + DATA_TO_TEXT
90843 };
90844
90845 struct sectioncheck {
90846 @@ -1045,6 +1046,12 @@ const struct sectioncheck sectioncheck[] = {
90847 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
90848 .mismatch = EXPORT_TO_INIT_EXIT,
90849 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
90850 +},
90851 +/* Do not reference code from writable data */
90852 +{
90853 + .fromsec = { DATA_SECTIONS, NULL },
90854 + .tosec = { TEXT_SECTIONS, NULL },
90855 + .mismatch = DATA_TO_TEXT
90856 }
90857 };
90858
90859 @@ -1167,10 +1174,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
90860 continue;
90861 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
90862 continue;
90863 - if (sym->st_value == addr)
90864 - return sym;
90865 /* Find a symbol nearby - addr are maybe negative */
90866 d = sym->st_value - addr;
90867 + if (d == 0)
90868 + return sym;
90869 if (d < 0)
90870 d = addr - sym->st_value;
90871 if (d < distance) {
90872 @@ -1449,6 +1456,14 @@ static void report_sec_mismatch(const char *modname,
90873 tosym, prl_to, prl_to, tosym);
90874 free(prl_to);
90875 break;
90876 + case DATA_TO_TEXT:
90877 +#if 0
90878 + fprintf(stderr,
90879 + "The %s %s:%s references\n"
90880 + "the %s %s:%s%s\n",
90881 + from, fromsec, fromsym, to, tosec, tosym, to_p);
90882 +#endif
90883 + break;
90884 }
90885 fprintf(stderr, "\n");
90886 }
90887 @@ -1683,7 +1698,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
90888 static void check_sec_ref(struct module *mod, const char *modname,
90889 struct elf_info *elf)
90890 {
90891 - int i;
90892 + unsigned int i;
90893 Elf_Shdr *sechdrs = elf->sechdrs;
90894
90895 /* Walk through all sections */
90896 @@ -1781,7 +1796,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
90897 va_end(ap);
90898 }
90899
90900 -void buf_write(struct buffer *buf, const char *s, int len)
90901 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
90902 {
90903 if (buf->size - buf->pos < len) {
90904 buf->size += len + SZ;
90905 @@ -1999,7 +2014,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
90906 if (fstat(fileno(file), &st) < 0)
90907 goto close_write;
90908
90909 - if (st.st_size != b->pos)
90910 + if (st.st_size != (off_t)b->pos)
90911 goto close_write;
90912
90913 tmp = NOFAIL(malloc(b->pos));
90914 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
90915 index 51207e4..f7d603d 100644
90916 --- a/scripts/mod/modpost.h
90917 +++ b/scripts/mod/modpost.h
90918 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
90919
90920 struct buffer {
90921 char *p;
90922 - int pos;
90923 - int size;
90924 + unsigned int pos;
90925 + unsigned int size;
90926 };
90927
90928 void __attribute__((format(printf, 2, 3)))
90929 buf_printf(struct buffer *buf, const char *fmt, ...);
90930
90931 void
90932 -buf_write(struct buffer *buf, const char *s, int len);
90933 +buf_write(struct buffer *buf, const char *s, unsigned int len);
90934
90935 struct module {
90936 struct module *next;
90937 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
90938 index 9dfcd6d..099068e 100644
90939 --- a/scripts/mod/sumversion.c
90940 +++ b/scripts/mod/sumversion.c
90941 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
90942 goto out;
90943 }
90944
90945 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
90946 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
90947 warn("writing sum in %s failed: %s\n",
90948 filename, strerror(errno));
90949 goto out;
90950 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
90951 index acb8650..b8c5f02 100644
90952 --- a/scripts/package/builddeb
90953 +++ b/scripts/package/builddeb
90954 @@ -246,6 +246,7 @@ fi
90955 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
90956 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
90957 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
90958 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
90959 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
90960 mkdir -p "$destdir"
90961 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
90962 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
90963 index 68bb4ef..2f419e1 100644
90964 --- a/scripts/pnmtologo.c
90965 +++ b/scripts/pnmtologo.c
90966 @@ -244,14 +244,14 @@ static void write_header(void)
90967 fprintf(out, " * Linux logo %s\n", logoname);
90968 fputs(" */\n\n", out);
90969 fputs("#include <linux/linux_logo.h>\n\n", out);
90970 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
90971 + fprintf(out, "static unsigned char %s_data[] = {\n",
90972 logoname);
90973 }
90974
90975 static void write_footer(void)
90976 {
90977 fputs("\n};\n\n", out);
90978 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
90979 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
90980 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
90981 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
90982 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
90983 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
90984 fputs("\n};\n\n", out);
90985
90986 /* write logo clut */
90987 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
90988 + fprintf(out, "static unsigned char %s_clut[] = {\n",
90989 logoname);
90990 write_hex_cnt = 0;
90991 for (i = 0; i < logo_clutsize; i++) {
90992 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
90993 index f5eb43d..1814de8 100644
90994 --- a/scripts/sortextable.h
90995 +++ b/scripts/sortextable.h
90996 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
90997 const char *secstrtab;
90998 const char *strtab;
90999 char *extab_image;
91000 - int extab_index = 0;
91001 - int i;
91002 - int idx;
91003 + unsigned int extab_index = 0;
91004 + unsigned int i;
91005 + unsigned int idx;
91006
91007 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91008 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91009 diff --git a/security/Kconfig b/security/Kconfig
91010 index e9c6ac7..e6254cf 100644
91011 --- a/security/Kconfig
91012 +++ b/security/Kconfig
91013 @@ -4,6 +4,944 @@
91014
91015 menu "Security options"
91016
91017 +menu "Grsecurity"
91018 +
91019 + config ARCH_TRACK_EXEC_LIMIT
91020 + bool
91021 +
91022 + config PAX_KERNEXEC_PLUGIN
91023 + bool
91024 +
91025 + config PAX_PER_CPU_PGD
91026 + bool
91027 +
91028 + config TASK_SIZE_MAX_SHIFT
91029 + int
91030 + depends on X86_64
91031 + default 47 if !PAX_PER_CPU_PGD
91032 + default 42 if PAX_PER_CPU_PGD
91033 +
91034 + config PAX_ENABLE_PAE
91035 + bool
91036 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91037 +
91038 + config PAX_USERCOPY_SLABS
91039 + bool
91040 +
91041 +config GRKERNSEC
91042 + bool "Grsecurity"
91043 + select CRYPTO
91044 + select CRYPTO_SHA256
91045 + select PROC_FS
91046 + select STOP_MACHINE
91047 + select TTY
91048 + help
91049 + If you say Y here, you will be able to configure many features
91050 + that will enhance the security of your system. It is highly
91051 + recommended that you say Y here and read through the help
91052 + for each option so that you fully understand the features and
91053 + can evaluate their usefulness for your machine.
91054 +
91055 +choice
91056 + prompt "Configuration Method"
91057 + depends on GRKERNSEC
91058 + default GRKERNSEC_CONFIG_CUSTOM
91059 + help
91060 +
91061 +config GRKERNSEC_CONFIG_AUTO
91062 + bool "Automatic"
91063 + help
91064 + If you choose this configuration method, you'll be able to answer a small
91065 + number of simple questions about how you plan to use this kernel.
91066 + The settings of grsecurity and PaX will be automatically configured for
91067 + the highest commonly-used settings within the provided constraints.
91068 +
91069 + If you require additional configuration, custom changes can still be made
91070 + from the "custom configuration" menu.
91071 +
91072 +config GRKERNSEC_CONFIG_CUSTOM
91073 + bool "Custom"
91074 + help
91075 + If you choose this configuration method, you'll be able to configure all
91076 + grsecurity and PaX settings manually. Via this method, no options are
91077 + automatically enabled.
91078 +
91079 +endchoice
91080 +
91081 +choice
91082 + prompt "Usage Type"
91083 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91084 + default GRKERNSEC_CONFIG_SERVER
91085 + help
91086 +
91087 +config GRKERNSEC_CONFIG_SERVER
91088 + bool "Server"
91089 + help
91090 + Choose this option if you plan to use this kernel on a server.
91091 +
91092 +config GRKERNSEC_CONFIG_DESKTOP
91093 + bool "Desktop"
91094 + help
91095 + Choose this option if you plan to use this kernel on a desktop.
91096 +
91097 +endchoice
91098 +
91099 +choice
91100 + prompt "Virtualization Type"
91101 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91102 + default GRKERNSEC_CONFIG_VIRT_NONE
91103 + help
91104 +
91105 +config GRKERNSEC_CONFIG_VIRT_NONE
91106 + bool "None"
91107 + help
91108 + Choose this option if this kernel will be run on bare metal.
91109 +
91110 +config GRKERNSEC_CONFIG_VIRT_GUEST
91111 + bool "Guest"
91112 + help
91113 + Choose this option if this kernel will be run as a VM guest.
91114 +
91115 +config GRKERNSEC_CONFIG_VIRT_HOST
91116 + bool "Host"
91117 + help
91118 + Choose this option if this kernel will be run as a VM host.
91119 +
91120 +endchoice
91121 +
91122 +choice
91123 + prompt "Virtualization Hardware"
91124 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91125 + help
91126 +
91127 +config GRKERNSEC_CONFIG_VIRT_EPT
91128 + bool "EPT/RVI Processor Support"
91129 + depends on X86
91130 + help
91131 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91132 + hardware virtualization. This allows for additional kernel hardening protections
91133 + to operate without additional performance impact.
91134 +
91135 + To see if your Intel processor supports EPT, see:
91136 + http://ark.intel.com/Products/VirtualizationTechnology
91137 + (Most Core i3/5/7 support EPT)
91138 +
91139 + To see if your AMD processor supports RVI, see:
91140 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91141 +
91142 +config GRKERNSEC_CONFIG_VIRT_SOFT
91143 + bool "First-gen/No Hardware Virtualization"
91144 + help
91145 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91146 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91147 +
91148 +endchoice
91149 +
91150 +choice
91151 + prompt "Virtualization Software"
91152 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91153 + help
91154 +
91155 +config GRKERNSEC_CONFIG_VIRT_XEN
91156 + bool "Xen"
91157 + help
91158 + Choose this option if this kernel is running as a Xen guest or host.
91159 +
91160 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91161 + bool "VMWare"
91162 + help
91163 + Choose this option if this kernel is running as a VMWare guest or host.
91164 +
91165 +config GRKERNSEC_CONFIG_VIRT_KVM
91166 + bool "KVM"
91167 + help
91168 + Choose this option if this kernel is running as a KVM guest or host.
91169 +
91170 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91171 + bool "VirtualBox"
91172 + help
91173 + Choose this option if this kernel is running as a VirtualBox guest or host.
91174 +
91175 +endchoice
91176 +
91177 +choice
91178 + prompt "Required Priorities"
91179 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91180 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91181 + help
91182 +
91183 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91184 + bool "Performance"
91185 + help
91186 + Choose this option if performance is of highest priority for this deployment
91187 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91188 + clearing of structures intended for userland, and freed memory sanitizing will
91189 + be disabled.
91190 +
91191 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91192 + bool "Security"
91193 + help
91194 + Choose this option if security is of highest priority for this deployment of
91195 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91196 + for userland, and freed memory sanitizing will be enabled for this kernel.
91197 + In a worst-case scenario, these features can introduce a 20% performance hit
91198 + (UDEREF on x64 contributing half of this hit).
91199 +
91200 +endchoice
91201 +
91202 +menu "Default Special Groups"
91203 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91204 +
91205 +config GRKERNSEC_PROC_GID
91206 + int "GID exempted from /proc restrictions"
91207 + default 1001
91208 + help
91209 + Setting this GID determines which group will be exempted from
91210 + grsecurity's /proc restrictions, allowing users of the specified
91211 + group to view network statistics and the existence of other users'
91212 + processes on the system. This GID may also be chosen at boot time
91213 + via "grsec_proc_gid=" on the kernel commandline.
91214 +
91215 +config GRKERNSEC_TPE_UNTRUSTED_GID
91216 + int "GID for TPE-untrusted users"
91217 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91218 + default 1005
91219 + help
91220 + Setting this GID determines which group untrusted users should
91221 + be added to. These users will be placed under grsecurity's Trusted Path
91222 + Execution mechanism, preventing them from executing their own binaries.
91223 + The users will only be able to execute binaries in directories owned and
91224 + writable only by the root user. If the sysctl option is enabled, a sysctl
91225 + option with name "tpe_gid" is created.
91226 +
91227 +config GRKERNSEC_TPE_TRUSTED_GID
91228 + int "GID for TPE-trusted users"
91229 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91230 + default 1005
91231 + help
91232 + Setting this GID determines what group TPE restrictions will be
91233 + *disabled* for. If the sysctl option is enabled, a sysctl option
91234 + with name "tpe_gid" is created.
91235 +
91236 +config GRKERNSEC_SYMLINKOWN_GID
91237 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91238 + depends on GRKERNSEC_CONFIG_SERVER
91239 + default 1006
91240 + help
91241 + Setting this GID determines what group kernel-enforced
91242 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91243 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91244 +
91245 +
91246 +endmenu
91247 +
91248 +menu "Customize Configuration"
91249 +depends on GRKERNSEC
91250 +
91251 +menu "PaX"
91252 +
91253 +config PAX
91254 + bool "Enable various PaX features"
91255 + default y if GRKERNSEC_CONFIG_AUTO
91256 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91257 + help
91258 + This allows you to enable various PaX features. PaX adds
91259 + intrusion prevention mechanisms to the kernel that reduce
91260 + the risks posed by exploitable memory corruption bugs.
91261 +
91262 +menu "PaX Control"
91263 + depends on PAX
91264 +
91265 +config PAX_SOFTMODE
91266 + bool 'Support soft mode'
91267 + help
91268 + Enabling this option will allow you to run PaX in soft mode, that
91269 + is, PaX features will not be enforced by default, only on executables
91270 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91271 + support as they are the only way to mark executables for soft mode use.
91272 +
91273 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91274 + line option on boot. Furthermore you can control various PaX features
91275 + at runtime via the entries in /proc/sys/kernel/pax.
91276 +
91277 +config PAX_EI_PAX
91278 + bool 'Use legacy ELF header marking'
91279 + default y if GRKERNSEC_CONFIG_AUTO
91280 + help
91281 + Enabling this option will allow you to control PaX features on
91282 + a per executable basis via the 'chpax' utility available at
91283 + http://pax.grsecurity.net/. The control flags will be read from
91284 + an otherwise reserved part of the ELF header. This marking has
91285 + numerous drawbacks (no support for soft-mode, toolchain does not
91286 + know about the non-standard use of the ELF header) therefore it
91287 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91288 + support.
91289 +
91290 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
91291 + support as well, they will override the legacy EI_PAX marks.
91292 +
91293 + If you enable none of the marking options then all applications
91294 + will run with PaX enabled on them by default.
91295 +
91296 +config PAX_PT_PAX_FLAGS
91297 + bool 'Use ELF program header marking'
91298 + default y if GRKERNSEC_CONFIG_AUTO
91299 + help
91300 + Enabling this option will allow you to control PaX features on
91301 + a per executable basis via the 'paxctl' utility available at
91302 + http://pax.grsecurity.net/. The control flags will be read from
91303 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
91304 + has the benefits of supporting both soft mode and being fully
91305 + integrated into the toolchain (the binutils patch is available
91306 + from http://pax.grsecurity.net).
91307 +
91308 + Note that if you enable the legacy EI_PAX marking support as well,
91309 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
91310 +
91311 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91312 + must make sure that the marks are the same if a binary has both marks.
91313 +
91314 + If you enable none of the marking options then all applications
91315 + will run with PaX enabled on them by default.
91316 +
91317 +config PAX_XATTR_PAX_FLAGS
91318 + bool 'Use filesystem extended attributes marking'
91319 + default y if GRKERNSEC_CONFIG_AUTO
91320 + select CIFS_XATTR if CIFS
91321 + select EXT2_FS_XATTR if EXT2_FS
91322 + select EXT3_FS_XATTR if EXT3_FS
91323 + select EXT4_FS_XATTR if EXT4_FS
91324 + select JFFS2_FS_XATTR if JFFS2_FS
91325 + select REISERFS_FS_XATTR if REISERFS_FS
91326 + select SQUASHFS_XATTR if SQUASHFS
91327 + select TMPFS_XATTR if TMPFS
91328 + select UBIFS_FS_XATTR if UBIFS_FS
91329 + help
91330 + Enabling this option will allow you to control PaX features on
91331 + a per executable basis via the 'setfattr' utility. The control
91332 + flags will be read from the user.pax.flags extended attribute of
91333 + the file. This marking has the benefit of supporting binary-only
91334 + applications that self-check themselves (e.g., skype) and would
91335 + not tolerate chpax/paxctl changes. The main drawback is that
91336 + extended attributes are not supported by some filesystems (e.g.,
91337 + isofs, udf, vfat) so copying files through such filesystems will
91338 + lose the extended attributes and these PaX markings.
91339 +
91340 + Note that if you enable the legacy EI_PAX marking support as well,
91341 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
91342 +
91343 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91344 + must make sure that the marks are the same if a binary has both marks.
91345 +
91346 + If you enable none of the marking options then all applications
91347 + will run with PaX enabled on them by default.
91348 +
91349 +choice
91350 + prompt 'MAC system integration'
91351 + default PAX_HAVE_ACL_FLAGS
91352 + help
91353 + Mandatory Access Control systems have the option of controlling
91354 + PaX flags on a per executable basis, choose the method supported
91355 + by your particular system.
91356 +
91357 + - "none": if your MAC system does not interact with PaX,
91358 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
91359 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
91360 +
91361 + NOTE: this option is for developers/integrators only.
91362 +
91363 + config PAX_NO_ACL_FLAGS
91364 + bool 'none'
91365 +
91366 + config PAX_HAVE_ACL_FLAGS
91367 + bool 'direct'
91368 +
91369 + config PAX_HOOK_ACL_FLAGS
91370 + bool 'hook'
91371 +endchoice
91372 +
91373 +endmenu
91374 +
91375 +menu "Non-executable pages"
91376 + depends on PAX
91377 +
91378 +config PAX_NOEXEC
91379 + bool "Enforce non-executable pages"
91380 + default y if GRKERNSEC_CONFIG_AUTO
91381 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
91382 + help
91383 + By design some architectures do not allow for protecting memory
91384 + pages against execution or even if they do, Linux does not make
91385 + use of this feature. In practice this means that if a page is
91386 + readable (such as the stack or heap) it is also executable.
91387 +
91388 + There is a well known exploit technique that makes use of this
91389 + fact and a common programming mistake where an attacker can
91390 + introduce code of his choice somewhere in the attacked program's
91391 + memory (typically the stack or the heap) and then execute it.
91392 +
91393 + If the attacked program was running with different (typically
91394 + higher) privileges than that of the attacker, then he can elevate
91395 + his own privilege level (e.g. get a root shell, write to files for
91396 + which he does not have write access to, etc).
91397 +
91398 + Enabling this option will let you choose from various features
91399 + that prevent the injection and execution of 'foreign' code in
91400 + a program.
91401 +
91402 + This will also break programs that rely on the old behaviour and
91403 + expect that dynamically allocated memory via the malloc() family
91404 + of functions is executable (which it is not). Notable examples
91405 + are the XFree86 4.x server, the java runtime and wine.
91406 +
91407 +config PAX_PAGEEXEC
91408 + bool "Paging based non-executable pages"
91409 + default y if GRKERNSEC_CONFIG_AUTO
91410 + 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)
91411 + select S390_SWITCH_AMODE if S390
91412 + select S390_EXEC_PROTECT if S390
91413 + select ARCH_TRACK_EXEC_LIMIT if X86_32
91414 + help
91415 + This implementation is based on the paging feature of the CPU.
91416 + On i386 without hardware non-executable bit support there is a
91417 + variable but usually low performance impact, however on Intel's
91418 + P4 core based CPUs it is very high so you should not enable this
91419 + for kernels meant to be used on such CPUs.
91420 +
91421 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
91422 + with hardware non-executable bit support there is no performance
91423 + impact, on ppc the impact is negligible.
91424 +
91425 + Note that several architectures require various emulations due to
91426 + badly designed userland ABIs, this will cause a performance impact
91427 + but will disappear as soon as userland is fixed. For example, ppc
91428 + userland MUST have been built with secure-plt by a recent toolchain.
91429 +
91430 +config PAX_SEGMEXEC
91431 + bool "Segmentation based non-executable pages"
91432 + default y if GRKERNSEC_CONFIG_AUTO
91433 + depends on PAX_NOEXEC && X86_32
91434 + help
91435 + This implementation is based on the segmentation feature of the
91436 + CPU and has a very small performance impact, however applications
91437 + will be limited to a 1.5 GB address space instead of the normal
91438 + 3 GB.
91439 +
91440 +config PAX_EMUTRAMP
91441 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
91442 + default y if PARISC
91443 + help
91444 + There are some programs and libraries that for one reason or
91445 + another attempt to execute special small code snippets from
91446 + non-executable memory pages. Most notable examples are the
91447 + signal handler return code generated by the kernel itself and
91448 + the GCC trampolines.
91449 +
91450 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
91451 + such programs will no longer work under your kernel.
91452 +
91453 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
91454 + utilities to enable trampoline emulation for the affected programs
91455 + yet still have the protection provided by the non-executable pages.
91456 +
91457 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
91458 + your system will not even boot.
91459 +
91460 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
91461 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
91462 + for the affected files.
91463 +
91464 + NOTE: enabling this feature *may* open up a loophole in the
91465 + protection provided by non-executable pages that an attacker
91466 + could abuse. Therefore the best solution is to not have any
91467 + files on your system that would require this option. This can
91468 + be achieved by not using libc5 (which relies on the kernel
91469 + signal handler return code) and not using or rewriting programs
91470 + that make use of the nested function implementation of GCC.
91471 + Skilled users can just fix GCC itself so that it implements
91472 + nested function calls in a way that does not interfere with PaX.
91473 +
91474 +config PAX_EMUSIGRT
91475 + bool "Automatically emulate sigreturn trampolines"
91476 + depends on PAX_EMUTRAMP && PARISC
91477 + default y
91478 + help
91479 + Enabling this option will have the kernel automatically detect
91480 + and emulate signal return trampolines executing on the stack
91481 + that would otherwise lead to task termination.
91482 +
91483 + This solution is intended as a temporary one for users with
91484 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
91485 + Modula-3 runtime, etc) or executables linked to such, basically
91486 + everything that does not specify its own SA_RESTORER function in
91487 + normal executable memory like glibc 2.1+ does.
91488 +
91489 + On parisc you MUST enable this option, otherwise your system will
91490 + not even boot.
91491 +
91492 + NOTE: this feature cannot be disabled on a per executable basis
91493 + and since it *does* open up a loophole in the protection provided
91494 + by non-executable pages, the best solution is to not have any
91495 + files on your system that would require this option.
91496 +
91497 +config PAX_MPROTECT
91498 + bool "Restrict mprotect()"
91499 + default y if GRKERNSEC_CONFIG_AUTO
91500 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
91501 + help
91502 + Enabling this option will prevent programs from
91503 + - changing the executable status of memory pages that were
91504 + not originally created as executable,
91505 + - making read-only executable pages writable again,
91506 + - creating executable pages from anonymous memory,
91507 + - making read-only-after-relocations (RELRO) data pages writable again.
91508 +
91509 + You should say Y here to complete the protection provided by
91510 + the enforcement of non-executable pages.
91511 +
91512 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91513 + this feature on a per file basis.
91514 +
91515 +config PAX_MPROTECT_COMPAT
91516 + bool "Use legacy/compat protection demoting (read help)"
91517 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91518 + depends on PAX_MPROTECT
91519 + help
91520 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
91521 + by sending the proper error code to the application. For some broken
91522 + userland, this can cause problems with Python or other applications. The
91523 + current implementation however allows for applications like clamav to
91524 + detect if JIT compilation/execution is allowed and to fall back gracefully
91525 + to an interpreter-based mode if it does not. While we encourage everyone
91526 + to use the current implementation as-is and push upstream to fix broken
91527 + userland (note that the RWX logging option can assist with this), in some
91528 + environments this may not be possible. Having to disable MPROTECT
91529 + completely on certain binaries reduces the security benefit of PaX,
91530 + so this option is provided for those environments to revert to the old
91531 + behavior.
91532 +
91533 +config PAX_ELFRELOCS
91534 + bool "Allow ELF text relocations (read help)"
91535 + depends on PAX_MPROTECT
91536 + default n
91537 + help
91538 + Non-executable pages and mprotect() restrictions are effective
91539 + in preventing the introduction of new executable code into an
91540 + attacked task's address space. There remain only two venues
91541 + for this kind of attack: if the attacker can execute already
91542 + existing code in the attacked task then he can either have it
91543 + create and mmap() a file containing his code or have it mmap()
91544 + an already existing ELF library that does not have position
91545 + independent code in it and use mprotect() on it to make it
91546 + writable and copy his code there. While protecting against
91547 + the former approach is beyond PaX, the latter can be prevented
91548 + by having only PIC ELF libraries on one's system (which do not
91549 + need to relocate their code). If you are sure this is your case,
91550 + as is the case with all modern Linux distributions, then leave
91551 + this option disabled. You should say 'n' here.
91552 +
91553 +config PAX_ETEXECRELOCS
91554 + bool "Allow ELF ET_EXEC text relocations"
91555 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
91556 + select PAX_ELFRELOCS
91557 + default y
91558 + help
91559 + On some architectures there are incorrectly created applications
91560 + that require text relocations and would not work without enabling
91561 + this option. If you are an alpha, ia64 or parisc user, you should
91562 + enable this option and disable it once you have made sure that
91563 + none of your applications need it.
91564 +
91565 +config PAX_EMUPLT
91566 + bool "Automatically emulate ELF PLT"
91567 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
91568 + default y
91569 + help
91570 + Enabling this option will have the kernel automatically detect
91571 + and emulate the Procedure Linkage Table entries in ELF files.
91572 + On some architectures such entries are in writable memory, and
91573 + become non-executable leading to task termination. Therefore
91574 + it is mandatory that you enable this option on alpha, parisc,
91575 + sparc and sparc64, otherwise your system would not even boot.
91576 +
91577 + NOTE: this feature *does* open up a loophole in the protection
91578 + provided by the non-executable pages, therefore the proper
91579 + solution is to modify the toolchain to produce a PLT that does
91580 + not need to be writable.
91581 +
91582 +config PAX_DLRESOLVE
91583 + bool 'Emulate old glibc resolver stub'
91584 + depends on PAX_EMUPLT && SPARC
91585 + default n
91586 + help
91587 + This option is needed if userland has an old glibc (before 2.4)
91588 + that puts a 'save' instruction into the runtime generated resolver
91589 + stub that needs special emulation.
91590 +
91591 +config PAX_KERNEXEC
91592 + bool "Enforce non-executable kernel pages"
91593 + 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))
91594 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
91595 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
91596 + select PAX_KERNEXEC_PLUGIN if X86_64
91597 + help
91598 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
91599 + that is, enabling this option will make it harder to inject
91600 + and execute 'foreign' code in kernel memory itself.
91601 +
91602 +choice
91603 + prompt "Return Address Instrumentation Method"
91604 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
91605 + depends on PAX_KERNEXEC_PLUGIN
91606 + help
91607 + Select the method used to instrument function pointer dereferences.
91608 + Note that binary modules cannot be instrumented by this approach.
91609 +
91610 + Note that the implementation requires a gcc with plugin support,
91611 + i.e., gcc 4.5 or newer. You may need to install the supporting
91612 + headers explicitly in addition to the normal gcc package.
91613 +
91614 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
91615 + bool "bts"
91616 + help
91617 + This method is compatible with binary only modules but has
91618 + a higher runtime overhead.
91619 +
91620 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
91621 + bool "or"
91622 + depends on !PARAVIRT
91623 + help
91624 + This method is incompatible with binary only modules but has
91625 + a lower runtime overhead.
91626 +endchoice
91627 +
91628 +config PAX_KERNEXEC_PLUGIN_METHOD
91629 + string
91630 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
91631 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
91632 + default ""
91633 +
91634 +config PAX_KERNEXEC_MODULE_TEXT
91635 + int "Minimum amount of memory reserved for module code"
91636 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
91637 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91638 + depends on PAX_KERNEXEC && X86_32 && MODULES
91639 + help
91640 + Due to implementation details the kernel must reserve a fixed
91641 + amount of memory for module code at compile time that cannot be
91642 + changed at runtime. Here you can specify the minimum amount
91643 + in MB that will be reserved. Due to the same implementation
91644 + details this size will always be rounded up to the next 2/4 MB
91645 + boundary (depends on PAE) so the actually available memory for
91646 + module code will usually be more than this minimum.
91647 +
91648 + The default 4 MB should be enough for most users but if you have
91649 + an excessive number of modules (e.g., most distribution configs
91650 + compile many drivers as modules) or use huge modules such as
91651 + nvidia's kernel driver, you will need to adjust this amount.
91652 + A good rule of thumb is to look at your currently loaded kernel
91653 + modules and add up their sizes.
91654 +
91655 +endmenu
91656 +
91657 +menu "Address Space Layout Randomization"
91658 + depends on PAX
91659 +
91660 +config PAX_ASLR
91661 + bool "Address Space Layout Randomization"
91662 + default y if GRKERNSEC_CONFIG_AUTO
91663 + help
91664 + Many if not most exploit techniques rely on the knowledge of
91665 + certain addresses in the attacked program. The following options
91666 + will allow the kernel to apply a certain amount of randomization
91667 + to specific parts of the program thereby forcing an attacker to
91668 + guess them in most cases. Any failed guess will most likely crash
91669 + the attacked program which allows the kernel to detect such attempts
91670 + and react on them. PaX itself provides no reaction mechanisms,
91671 + instead it is strongly encouraged that you make use of Nergal's
91672 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
91673 + (http://www.grsecurity.net/) built-in crash detection features or
91674 + develop one yourself.
91675 +
91676 + By saying Y here you can choose to randomize the following areas:
91677 + - top of the task's kernel stack
91678 + - top of the task's userland stack
91679 + - base address for mmap() requests that do not specify one
91680 + (this includes all libraries)
91681 + - base address of the main executable
91682 +
91683 + It is strongly recommended to say Y here as address space layout
91684 + randomization has negligible impact on performance yet it provides
91685 + a very effective protection.
91686 +
91687 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91688 + this feature on a per file basis.
91689 +
91690 +config PAX_RANDKSTACK
91691 + bool "Randomize kernel stack base"
91692 + default y if GRKERNSEC_CONFIG_AUTO
91693 + depends on X86_TSC && X86
91694 + help
91695 + By saying Y here the kernel will randomize every task's kernel
91696 + stack on every system call. This will not only force an attacker
91697 + to guess it but also prevent him from making use of possible
91698 + leaked information about it.
91699 +
91700 + Since the kernel stack is a rather scarce resource, randomization
91701 + may cause unexpected stack overflows, therefore you should very
91702 + carefully test your system. Note that once enabled in the kernel
91703 + configuration, this feature cannot be disabled on a per file basis.
91704 +
91705 +config PAX_RANDUSTACK
91706 + bool "Randomize user stack base"
91707 + default y if GRKERNSEC_CONFIG_AUTO
91708 + depends on PAX_ASLR
91709 + help
91710 + By saying Y here the kernel will randomize every task's userland
91711 + stack. The randomization is done in two steps where the second
91712 + one may apply a big amount of shift to the top of the stack and
91713 + cause problems for programs that want to use lots of memory (more
91714 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
91715 + For this reason the second step can be controlled by 'chpax' or
91716 + 'paxctl' on a per file basis.
91717 +
91718 +config PAX_RANDMMAP
91719 + bool "Randomize mmap() base"
91720 + default y if GRKERNSEC_CONFIG_AUTO
91721 + depends on PAX_ASLR
91722 + help
91723 + By saying Y here the kernel will use a randomized base address for
91724 + mmap() requests that do not specify one themselves. As a result
91725 + all dynamically loaded libraries will appear at random addresses
91726 + and therefore be harder to exploit by a technique where an attacker
91727 + attempts to execute library code for his purposes (e.g. spawn a
91728 + shell from an exploited program that is running at an elevated
91729 + privilege level).
91730 +
91731 + Furthermore, if a program is relinked as a dynamic ELF file, its
91732 + base address will be randomized as well, completing the full
91733 + randomization of the address space layout. Attacking such programs
91734 + becomes a guess game. You can find an example of doing this at
91735 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
91736 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
91737 +
91738 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
91739 + feature on a per file basis.
91740 +
91741 +endmenu
91742 +
91743 +menu "Miscellaneous hardening features"
91744 +
91745 +config PAX_MEMORY_SANITIZE
91746 + bool "Sanitize all freed memory"
91747 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91748 + depends on !HIBERNATION
91749 + help
91750 + By saying Y here the kernel will erase memory pages as soon as they
91751 + are freed. This in turn reduces the lifetime of data stored in the
91752 + pages, making it less likely that sensitive information such as
91753 + passwords, cryptographic secrets, etc stay in memory for too long.
91754 +
91755 + This is especially useful for programs whose runtime is short, long
91756 + lived processes and the kernel itself benefit from this as long as
91757 + they operate on whole memory pages and ensure timely freeing of pages
91758 + that may hold sensitive information.
91759 +
91760 + The tradeoff is performance impact, on a single CPU system kernel
91761 + compilation sees a 3% slowdown, other systems and workloads may vary
91762 + and you are advised to test this feature on your expected workload
91763 + before deploying it.
91764 +
91765 + Note that this feature does not protect data stored in live pages,
91766 + e.g., process memory swapped to disk may stay there for a long time.
91767 +
91768 +config PAX_MEMORY_STACKLEAK
91769 + bool "Sanitize kernel stack"
91770 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91771 + depends on X86
91772 + help
91773 + By saying Y here the kernel will erase the kernel stack before it
91774 + returns from a system call. This in turn reduces the information
91775 + that a kernel stack leak bug can reveal.
91776 +
91777 + Note that such a bug can still leak information that was put on
91778 + the stack by the current system call (the one eventually triggering
91779 + the bug) but traces of earlier system calls on the kernel stack
91780 + cannot leak anymore.
91781 +
91782 + The tradeoff is performance impact: on a single CPU system kernel
91783 + compilation sees a 1% slowdown, other systems and workloads may vary
91784 + and you are advised to test this feature on your expected workload
91785 + before deploying it.
91786 +
91787 + Note that the full feature requires a gcc with plugin support,
91788 + i.e., gcc 4.5 or newer. You may need to install the supporting
91789 + headers explicitly in addition to the normal gcc package. Using
91790 + older gcc versions means that functions with large enough stack
91791 + frames may leave uninitialized memory behind that may be exposed
91792 + to a later syscall leaking the stack.
91793 +
91794 +config PAX_MEMORY_STRUCTLEAK
91795 + bool "Forcibly initialize local variables copied to userland"
91796 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91797 + help
91798 + By saying Y here the kernel will zero initialize some local
91799 + variables that are going to be copied to userland. This in
91800 + turn prevents unintended information leakage from the kernel
91801 + stack should later code forget to explicitly set all parts of
91802 + the copied variable.
91803 +
91804 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
91805 + at a much smaller coverage.
91806 +
91807 + Note that the implementation requires a gcc with plugin support,
91808 + i.e., gcc 4.5 or newer. You may need to install the supporting
91809 + headers explicitly in addition to the normal gcc package.
91810 +
91811 +config PAX_MEMORY_UDEREF
91812 + bool "Prevent invalid userland pointer dereference"
91813 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
91814 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
91815 + select PAX_PER_CPU_PGD if X86_64
91816 + help
91817 + By saying Y here the kernel will be prevented from dereferencing
91818 + userland pointers in contexts where the kernel expects only kernel
91819 + pointers. This is both a useful runtime debugging feature and a
91820 + security measure that prevents exploiting a class of kernel bugs.
91821 +
91822 + The tradeoff is that some virtualization solutions may experience
91823 + a huge slowdown and therefore you should not enable this feature
91824 + for kernels meant to run in such environments. Whether a given VM
91825 + solution is affected or not is best determined by simply trying it
91826 + out, the performance impact will be obvious right on boot as this
91827 + mechanism engages from very early on. A good rule of thumb is that
91828 + VMs running on CPUs without hardware virtualization support (i.e.,
91829 + the majority of IA-32 CPUs) will likely experience the slowdown.
91830 +
91831 +config PAX_REFCOUNT
91832 + bool "Prevent various kernel object reference counter overflows"
91833 + default y if GRKERNSEC_CONFIG_AUTO
91834 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
91835 + help
91836 + By saying Y here the kernel will detect and prevent overflowing
91837 + various (but not all) kinds of object reference counters. Such
91838 + overflows can normally occur due to bugs only and are often, if
91839 + not always, exploitable.
91840 +
91841 + The tradeoff is that data structures protected by an overflowed
91842 + refcount will never be freed and therefore will leak memory. Note
91843 + that this leak also happens even without this protection but in
91844 + that case the overflow can eventually trigger the freeing of the
91845 + data structure while it is still being used elsewhere, resulting
91846 + in the exploitable situation that this feature prevents.
91847 +
91848 + Since this has a negligible performance impact, you should enable
91849 + this feature.
91850 +
91851 +config PAX_CONSTIFY_PLUGIN
91852 + bool "Automatically constify eligible structures"
91853 + default y
91854 + depends on !UML && PAX_KERNEXEC
91855 + help
91856 + By saying Y here the compiler will automatically constify a class
91857 + of types that contain only function pointers. This reduces the
91858 + kernel's attack surface and also produces a better memory layout.
91859 +
91860 + Note that the implementation requires a gcc with plugin support,
91861 + i.e., gcc 4.5 or newer. You may need to install the supporting
91862 + headers explicitly in addition to the normal gcc package.
91863 +
91864 + Note that if some code really has to modify constified variables
91865 + then the source code will have to be patched to allow it. Examples
91866 + can be found in PaX itself (the no_const attribute) and for some
91867 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
91868 +
91869 +config PAX_USERCOPY
91870 + bool "Harden heap object copies between kernel and userland"
91871 + default y if GRKERNSEC_CONFIG_AUTO
91872 + depends on ARM || IA64 || PPC || SPARC || X86
91873 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
91874 + select PAX_USERCOPY_SLABS
91875 + help
91876 + By saying Y here the kernel will enforce the size of heap objects
91877 + when they are copied in either direction between the kernel and
91878 + userland, even if only a part of the heap object is copied.
91879 +
91880 + Specifically, this checking prevents information leaking from the
91881 + kernel heap during kernel to userland copies (if the kernel heap
91882 + object is otherwise fully initialized) and prevents kernel heap
91883 + overflows during userland to kernel copies.
91884 +
91885 + Note that the current implementation provides the strictest bounds
91886 + checks for the SLUB allocator.
91887 +
91888 + Enabling this option also enables per-slab cache protection against
91889 + data in a given cache being copied into/out of via userland
91890 + accessors. Though the whitelist of regions will be reduced over
91891 + time, it notably protects important data structures like task structs.
91892 +
91893 + If frame pointers are enabled on x86, this option will also restrict
91894 + copies into and out of the kernel stack to local variables within a
91895 + single frame.
91896 +
91897 + Since this has a negligible performance impact, you should enable
91898 + this feature.
91899 +
91900 +config PAX_USERCOPY_DEBUG
91901 + bool
91902 + depends on X86 && PAX_USERCOPY
91903 + default n
91904 +
91905 +config PAX_SIZE_OVERFLOW
91906 + bool "Prevent various integer overflows in function size parameters"
91907 + default y if GRKERNSEC_CONFIG_AUTO
91908 + depends on X86
91909 + help
91910 + By saying Y here the kernel recomputes expressions of function
91911 + arguments marked by a size_overflow attribute with double integer
91912 + precision (DImode/TImode for 32/64 bit integer types).
91913 +
91914 + The recomputed argument is checked against TYPE_MAX and an event
91915 + is logged on overflow and the triggering process is killed.
91916 +
91917 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
91918 +
91919 + Note that the implementation requires a gcc with plugin support,
91920 + i.e., gcc 4.5 or newer. You may need to install the supporting
91921 + headers explicitly in addition to the normal gcc package.
91922 +
91923 +config PAX_LATENT_ENTROPY
91924 + bool "Generate some entropy during boot"
91925 + default y if GRKERNSEC_CONFIG_AUTO
91926 + help
91927 + By saying Y here the kernel will instrument early boot code to
91928 + extract some entropy from both original and artificially created
91929 + program state. This will help especially embedded systems where
91930 + there is little 'natural' source of entropy normally. The cost
91931 + is some slowdown of the boot process.
91932 +
91933 + When pax_extra_latent_entropy is passed on the kernel command line,
91934 + entropy will be extracted from up to the first 4GB of RAM while the
91935 + runtime memory allocator is being initialized. This costs even more
91936 + slowdown of the boot process.
91937 +
91938 + Note that the implementation requires a gcc with plugin support,
91939 + i.e., gcc 4.5 or newer. You may need to install the supporting
91940 + headers explicitly in addition to the normal gcc package.
91941 +
91942 + Note that entropy extracted this way is not cryptographically
91943 + secure!
91944 +
91945 +endmenu
91946 +
91947 +endmenu
91948 +
91949 +source grsecurity/Kconfig
91950 +
91951 +endmenu
91952 +
91953 +endmenu
91954 +
91955 source security/keys/Kconfig
91956
91957 config SECURITY_DMESG_RESTRICT
91958 @@ -103,7 +1041,7 @@ config INTEL_TXT
91959 config LSM_MMAP_MIN_ADDR
91960 int "Low address space for LSM to protect from user allocation"
91961 depends on SECURITY && SECURITY_SELINUX
91962 - default 32768 if ARM
91963 + default 32768 if ALPHA || ARM || PARISC || SPARC32
91964 default 65536
91965 help
91966 This is the portion of low virtual memory which should be protected
91967 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
91968 index b21830e..a7d1a17 100644
91969 --- a/security/apparmor/lsm.c
91970 +++ b/security/apparmor/lsm.c
91971 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
91972 return error;
91973 }
91974
91975 -static struct security_operations apparmor_ops = {
91976 +static struct security_operations apparmor_ops __read_only = {
91977 .name = "apparmor",
91978
91979 .ptrace_access_check = apparmor_ptrace_access_check,
91980 diff --git a/security/commoncap.c b/security/commoncap.c
91981 index c44b6fe..932df30 100644
91982 --- a/security/commoncap.c
91983 +++ b/security/commoncap.c
91984 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
91985 return 0;
91986 }
91987
91988 +/* returns:
91989 + 1 for suid privilege
91990 + 2 for sgid privilege
91991 + 3 for fscap privilege
91992 +*/
91993 +int is_privileged_binary(const struct dentry *dentry)
91994 +{
91995 + struct cpu_vfs_cap_data capdata;
91996 + struct inode *inode = dentry->d_inode;
91997 +
91998 + if (!inode || S_ISDIR(inode->i_mode))
91999 + return 0;
92000 +
92001 + if (inode->i_mode & S_ISUID)
92002 + return 1;
92003 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92004 + return 2;
92005 +
92006 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92007 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92008 + return 3;
92009 + }
92010 +
92011 + return 0;
92012 +}
92013 +
92014 /*
92015 * Attempt to get the on-exec apply capability sets for an executable file from
92016 * its xattrs and, if present, apply them to the proposed credentials being
92017 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92018 const struct cred *cred = current_cred();
92019 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92020
92021 + if (gr_acl_enable_at_secure())
92022 + return 1;
92023 +
92024 if (!uid_eq(cred->uid, root_uid)) {
92025 if (bprm->cap_effective)
92026 return 1;
92027 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
92028 index a41c9c1..83da6dd 100644
92029 --- a/security/integrity/ima/ima.h
92030 +++ b/security/integrity/ima/ima.h
92031 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
92032 extern spinlock_t ima_queue_lock;
92033
92034 struct ima_h_table {
92035 - atomic_long_t len; /* number of stored measurements in the list */
92036 - atomic_long_t violations;
92037 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
92038 + atomic_long_unchecked_t violations;
92039 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
92040 };
92041 extern struct ima_h_table ima_htable;
92042 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
92043 index 1c03e8f1..398a941 100644
92044 --- a/security/integrity/ima/ima_api.c
92045 +++ b/security/integrity/ima/ima_api.c
92046 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92047 int result;
92048
92049 /* can overflow, only indicator */
92050 - atomic_long_inc(&ima_htable.violations);
92051 + atomic_long_inc_unchecked(&ima_htable.violations);
92052
92053 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
92054 if (!entry) {
92055 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
92056 index 38477c9..87a60c7 100644
92057 --- a/security/integrity/ima/ima_fs.c
92058 +++ b/security/integrity/ima/ima_fs.c
92059 @@ -28,12 +28,12 @@
92060 static int valid_policy = 1;
92061 #define TMPBUFLEN 12
92062 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
92063 - loff_t *ppos, atomic_long_t *val)
92064 + loff_t *ppos, atomic_long_unchecked_t *val)
92065 {
92066 char tmpbuf[TMPBUFLEN];
92067 ssize_t len;
92068
92069 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
92070 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
92071 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
92072 }
92073
92074 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
92075 index ff63fe0..809cd96 100644
92076 --- a/security/integrity/ima/ima_queue.c
92077 +++ b/security/integrity/ima/ima_queue.c
92078 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
92079 INIT_LIST_HEAD(&qe->later);
92080 list_add_tail_rcu(&qe->later, &ima_measurements);
92081
92082 - atomic_long_inc(&ima_htable.len);
92083 + atomic_long_inc_unchecked(&ima_htable.len);
92084 key = ima_hash_key(entry->digest);
92085 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
92086 return 0;
92087 diff --git a/security/keys/compat.c b/security/keys/compat.c
92088 index d65fa7f..cbfe366 100644
92089 --- a/security/keys/compat.c
92090 +++ b/security/keys/compat.c
92091 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
92092 if (ret == 0)
92093 goto no_payload_free;
92094
92095 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92096 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92097 err:
92098 if (iov != iovstack)
92099 kfree(iov);
92100 diff --git a/security/keys/internal.h b/security/keys/internal.h
92101 index 8bbefc3..299d03f 100644
92102 --- a/security/keys/internal.h
92103 +++ b/security/keys/internal.h
92104 @@ -240,7 +240,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
92105 extern long keyctl_invalidate_key(key_serial_t);
92106
92107 extern long keyctl_instantiate_key_common(key_serial_t,
92108 - const struct iovec *,
92109 + const struct iovec __user *,
92110 unsigned, size_t, key_serial_t);
92111
92112 /*
92113 diff --git a/security/keys/key.c b/security/keys/key.c
92114 index 8fb7c7b..ba3610d 100644
92115 --- a/security/keys/key.c
92116 +++ b/security/keys/key.c
92117 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
92118
92119 atomic_set(&key->usage, 1);
92120 init_rwsem(&key->sem);
92121 - lockdep_set_class(&key->sem, &type->lock_class);
92122 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
92123 key->type = type;
92124 key->user = user;
92125 key->quotalen = quotalen;
92126 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
92127 struct key_type *p;
92128 int ret;
92129
92130 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
92131 + pax_open_kernel();
92132 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
92133 + pax_close_kernel();
92134
92135 ret = -EEXIST;
92136 down_write(&key_types_sem);
92137 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
92138 }
92139
92140 /* store the type */
92141 - list_add(&ktype->link, &key_types_list);
92142 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
92143
92144 pr_notice("Key type %s registered\n", ktype->name);
92145 ret = 0;
92146 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
92147 void unregister_key_type(struct key_type *ktype)
92148 {
92149 down_write(&key_types_sem);
92150 - list_del_init(&ktype->link);
92151 + pax_list_del_init((struct list_head *)&ktype->link);
92152 downgrade_write(&key_types_sem);
92153 key_gc_keytype(ktype);
92154 pr_notice("Key type %s unregistered\n", ktype->name);
92155 @@ -1084,10 +1086,10 @@ void __init key_init(void)
92156 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
92157
92158 /* add the special key types */
92159 - list_add_tail(&key_type_keyring.link, &key_types_list);
92160 - list_add_tail(&key_type_dead.link, &key_types_list);
92161 - list_add_tail(&key_type_user.link, &key_types_list);
92162 - list_add_tail(&key_type_logon.link, &key_types_list);
92163 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
92164 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
92165 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
92166 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
92167
92168 /* record the root user tracking */
92169 rb_link_node(&root_key_user.node,
92170 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
92171 index 4b5c948..2054dc1 100644
92172 --- a/security/keys/keyctl.c
92173 +++ b/security/keys/keyctl.c
92174 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
92175 /*
92176 * Copy the iovec data from userspace
92177 */
92178 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92179 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
92180 unsigned ioc)
92181 {
92182 for (; ioc > 0; ioc--) {
92183 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92184 * If successful, 0 will be returned.
92185 */
92186 long keyctl_instantiate_key_common(key_serial_t id,
92187 - const struct iovec *payload_iov,
92188 + const struct iovec __user *payload_iov,
92189 unsigned ioc,
92190 size_t plen,
92191 key_serial_t ringid)
92192 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
92193 [0].iov_len = plen
92194 };
92195
92196 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
92197 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
92198 }
92199
92200 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
92201 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
92202 if (ret == 0)
92203 goto no_payload_free;
92204
92205 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92206 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92207 err:
92208 if (iov != iovstack)
92209 kfree(iov);
92210 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
92211 index 6ece7f2..ecdb55c 100644
92212 --- a/security/keys/keyring.c
92213 +++ b/security/keys/keyring.c
92214 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
92215 ret = -EFAULT;
92216
92217 for (loop = 0; loop < klist->nkeys; loop++) {
92218 + key_serial_t serial;
92219 key = rcu_deref_link_locked(klist, loop,
92220 keyring);
92221 + serial = key->serial;
92222
92223 tmp = sizeof(key_serial_t);
92224 if (tmp > buflen)
92225 tmp = buflen;
92226
92227 - if (copy_to_user(buffer,
92228 - &key->serial,
92229 - tmp) != 0)
92230 + if (copy_to_user(buffer, &serial, tmp))
92231 goto error;
92232
92233 buflen -= tmp;
92234 diff --git a/security/min_addr.c b/security/min_addr.c
92235 index f728728..6457a0c 100644
92236 --- a/security/min_addr.c
92237 +++ b/security/min_addr.c
92238 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
92239 */
92240 static void update_mmap_min_addr(void)
92241 {
92242 +#ifndef SPARC
92243 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
92244 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
92245 mmap_min_addr = dac_mmap_min_addr;
92246 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
92247 #else
92248 mmap_min_addr = dac_mmap_min_addr;
92249 #endif
92250 +#endif
92251 }
92252
92253 /*
92254 diff --git a/security/security.c b/security/security.c
92255 index 03f248b..5710c33 100644
92256 --- a/security/security.c
92257 +++ b/security/security.c
92258 @@ -20,6 +20,7 @@
92259 #include <linux/ima.h>
92260 #include <linux/evm.h>
92261 #include <linux/fsnotify.h>
92262 +#include <linux/mm.h>
92263 #include <linux/mman.h>
92264 #include <linux/mount.h>
92265 #include <linux/personality.h>
92266 @@ -32,8 +33,8 @@
92267 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
92268 CONFIG_DEFAULT_SECURITY;
92269
92270 -static struct security_operations *security_ops;
92271 -static struct security_operations default_security_ops = {
92272 +static struct security_operations *security_ops __read_only;
92273 +static struct security_operations default_security_ops __read_only = {
92274 .name = "default",
92275 };
92276
92277 @@ -74,7 +75,9 @@ int __init security_init(void)
92278
92279 void reset_security_ops(void)
92280 {
92281 + pax_open_kernel();
92282 security_ops = &default_security_ops;
92283 + pax_close_kernel();
92284 }
92285
92286 /* Save user chosen LSM */
92287 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
92288 index 7171a95..c35e879 100644
92289 --- a/security/selinux/hooks.c
92290 +++ b/security/selinux/hooks.c
92291 @@ -96,8 +96,6 @@
92292
92293 #define NUM_SEL_MNT_OPTS 5
92294
92295 -extern struct security_operations *security_ops;
92296 -
92297 /* SECMARK reference count */
92298 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
92299
92300 @@ -5498,7 +5496,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
92301
92302 #endif
92303
92304 -static struct security_operations selinux_ops = {
92305 +static struct security_operations selinux_ops __read_only = {
92306 .name = "selinux",
92307
92308 .ptrace_access_check = selinux_ptrace_access_check,
92309 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
92310 index 65f67cb..3f141ef 100644
92311 --- a/security/selinux/include/xfrm.h
92312 +++ b/security/selinux/include/xfrm.h
92313 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
92314
92315 static inline void selinux_xfrm_notify_policyload(void)
92316 {
92317 - atomic_inc(&flow_cache_genid);
92318 + atomic_inc_unchecked(&flow_cache_genid);
92319 rt_genid_bump(&init_net);
92320 }
92321 #else
92322 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
92323 index fa64740..bc95b74 100644
92324 --- a/security/smack/smack_lsm.c
92325 +++ b/security/smack/smack_lsm.c
92326 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
92327 return 0;
92328 }
92329
92330 -struct security_operations smack_ops = {
92331 +struct security_operations smack_ops __read_only = {
92332 .name = "smack",
92333
92334 .ptrace_access_check = smack_ptrace_access_check,
92335 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
92336 index 390c646..f2f8db3 100644
92337 --- a/security/tomoyo/mount.c
92338 +++ b/security/tomoyo/mount.c
92339 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
92340 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
92341 need_dev = -1; /* dev_name is a directory */
92342 } else {
92343 + if (!capable(CAP_SYS_ADMIN)) {
92344 + error = -EPERM;
92345 + goto out;
92346 + }
92347 fstype = get_fs_type(type);
92348 if (!fstype) {
92349 error = -ENODEV;
92350 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
92351 index a2ee362..5754f34 100644
92352 --- a/security/tomoyo/tomoyo.c
92353 +++ b/security/tomoyo/tomoyo.c
92354 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
92355 * tomoyo_security_ops is a "struct security_operations" which is used for
92356 * registering TOMOYO.
92357 */
92358 -static struct security_operations tomoyo_security_ops = {
92359 +static struct security_operations tomoyo_security_ops __read_only = {
92360 .name = "tomoyo",
92361 .cred_alloc_blank = tomoyo_cred_alloc_blank,
92362 .cred_prepare = tomoyo_cred_prepare,
92363 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
92364 index 20ef514..4182bed 100644
92365 --- a/security/yama/Kconfig
92366 +++ b/security/yama/Kconfig
92367 @@ -1,6 +1,6 @@
92368 config SECURITY_YAMA
92369 bool "Yama support"
92370 - depends on SECURITY
92371 + depends on SECURITY && !GRKERNSEC
92372 select SECURITYFS
92373 select SECURITY_PATH
92374 default n
92375 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
92376 index 13c88fbc..f8c115e 100644
92377 --- a/security/yama/yama_lsm.c
92378 +++ b/security/yama/yama_lsm.c
92379 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
92380 }
92381
92382 #ifndef CONFIG_SECURITY_YAMA_STACKED
92383 -static struct security_operations yama_ops = {
92384 +static struct security_operations yama_ops __read_only = {
92385 .name = "yama",
92386
92387 .ptrace_access_check = yama_ptrace_access_check,
92388 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
92389 #endif
92390
92391 #ifdef CONFIG_SYSCTL
92392 +static int zero __read_only;
92393 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
92394 +
92395 static int yama_dointvec_minmax(struct ctl_table *table, int write,
92396 void __user *buffer, size_t *lenp, loff_t *ppos)
92397 {
92398 - int rc;
92399 + ctl_table_no_const yama_table;
92400
92401 if (write && !capable(CAP_SYS_PTRACE))
92402 return -EPERM;
92403
92404 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
92405 - if (rc)
92406 - return rc;
92407 -
92408 + yama_table = *table;
92409 /* Lock the max value if it ever gets set. */
92410 - if (write && *(int *)table->data == *(int *)table->extra2)
92411 - table->extra1 = table->extra2;
92412 -
92413 - return rc;
92414 + if (ptrace_scope == max_scope)
92415 + yama_table.extra1 = &max_scope;
92416 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
92417 }
92418
92419 -static int zero;
92420 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
92421 -
92422 struct ctl_path yama_sysctl_path[] = {
92423 { .procname = "kernel", },
92424 { .procname = "yama", },
92425 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
92426 index 4cedc69..e59d8a3 100644
92427 --- a/sound/aoa/codecs/onyx.c
92428 +++ b/sound/aoa/codecs/onyx.c
92429 @@ -54,7 +54,7 @@ struct onyx {
92430 spdif_locked:1,
92431 analog_locked:1,
92432 original_mute:2;
92433 - int open_count;
92434 + local_t open_count;
92435 struct codec_info *codec_info;
92436
92437 /* mutex serializes concurrent access to the device
92438 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
92439 struct onyx *onyx = cii->codec_data;
92440
92441 mutex_lock(&onyx->mutex);
92442 - onyx->open_count++;
92443 + local_inc(&onyx->open_count);
92444 mutex_unlock(&onyx->mutex);
92445
92446 return 0;
92447 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
92448 struct onyx *onyx = cii->codec_data;
92449
92450 mutex_lock(&onyx->mutex);
92451 - onyx->open_count--;
92452 - if (!onyx->open_count)
92453 + if (local_dec_and_test(&onyx->open_count))
92454 onyx->spdif_locked = onyx->analog_locked = 0;
92455 mutex_unlock(&onyx->mutex);
92456
92457 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
92458 index ffd2025..df062c9 100644
92459 --- a/sound/aoa/codecs/onyx.h
92460 +++ b/sound/aoa/codecs/onyx.h
92461 @@ -11,6 +11,7 @@
92462 #include <linux/i2c.h>
92463 #include <asm/pmac_low_i2c.h>
92464 #include <asm/prom.h>
92465 +#include <asm/local.h>
92466
92467 /* PCM3052 register definitions */
92468
92469 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
92470 index 4c1cc51..16040040 100644
92471 --- a/sound/core/oss/pcm_oss.c
92472 +++ b/sound/core/oss/pcm_oss.c
92473 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
92474 if (in_kernel) {
92475 mm_segment_t fs;
92476 fs = snd_enter_user();
92477 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92478 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92479 snd_leave_user(fs);
92480 } else {
92481 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92482 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92483 }
92484 if (ret != -EPIPE && ret != -ESTRPIPE)
92485 break;
92486 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
92487 if (in_kernel) {
92488 mm_segment_t fs;
92489 fs = snd_enter_user();
92490 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92491 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92492 snd_leave_user(fs);
92493 } else {
92494 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92495 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92496 }
92497 if (ret == -EPIPE) {
92498 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
92499 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
92500 struct snd_pcm_plugin_channel *channels;
92501 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
92502 if (!in_kernel) {
92503 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
92504 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
92505 return -EFAULT;
92506 buf = runtime->oss.buffer;
92507 }
92508 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
92509 }
92510 } else {
92511 tmp = snd_pcm_oss_write2(substream,
92512 - (const char __force *)buf,
92513 + (const char __force_kernel *)buf,
92514 runtime->oss.period_bytes, 0);
92515 if (tmp <= 0)
92516 goto err;
92517 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
92518 struct snd_pcm_runtime *runtime = substream->runtime;
92519 snd_pcm_sframes_t frames, frames1;
92520 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
92521 - char __user *final_dst = (char __force __user *)buf;
92522 + char __user *final_dst = (char __force_user *)buf;
92523 if (runtime->oss.plugin_first) {
92524 struct snd_pcm_plugin_channel *channels;
92525 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
92526 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
92527 xfer += tmp;
92528 runtime->oss.buffer_used -= tmp;
92529 } else {
92530 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
92531 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
92532 runtime->oss.period_bytes, 0);
92533 if (tmp <= 0)
92534 goto err;
92535 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
92536 size1);
92537 size1 /= runtime->channels; /* frames */
92538 fs = snd_enter_user();
92539 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
92540 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
92541 snd_leave_user(fs);
92542 }
92543 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
92544 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
92545 index af49721..e85058e 100644
92546 --- a/sound/core/pcm_compat.c
92547 +++ b/sound/core/pcm_compat.c
92548 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
92549 int err;
92550
92551 fs = snd_enter_user();
92552 - err = snd_pcm_delay(substream, &delay);
92553 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
92554 snd_leave_user(fs);
92555 if (err < 0)
92556 return err;
92557 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
92558 index eb560fa..69a4995 100644
92559 --- a/sound/core/pcm_native.c
92560 +++ b/sound/core/pcm_native.c
92561 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
92562 switch (substream->stream) {
92563 case SNDRV_PCM_STREAM_PLAYBACK:
92564 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
92565 - (void __user *)arg);
92566 + (void __force_user *)arg);
92567 break;
92568 case SNDRV_PCM_STREAM_CAPTURE:
92569 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
92570 - (void __user *)arg);
92571 + (void __force_user *)arg);
92572 break;
92573 default:
92574 result = -EINVAL;
92575 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
92576 index 040c60e..989a19a 100644
92577 --- a/sound/core/seq/seq_device.c
92578 +++ b/sound/core/seq/seq_device.c
92579 @@ -64,7 +64,7 @@ struct ops_list {
92580 int argsize; /* argument size */
92581
92582 /* operators */
92583 - struct snd_seq_dev_ops ops;
92584 + struct snd_seq_dev_ops *ops;
92585
92586 /* registered devices */
92587 struct list_head dev_list; /* list of devices */
92588 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
92589
92590 mutex_lock(&ops->reg_mutex);
92591 /* copy driver operators */
92592 - ops->ops = *entry;
92593 + ops->ops = entry;
92594 ops->driver |= DRIVER_LOADED;
92595 ops->argsize = argsize;
92596
92597 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
92598 dev->name, ops->id, ops->argsize, dev->argsize);
92599 return -EINVAL;
92600 }
92601 - if (ops->ops.init_device(dev) >= 0) {
92602 + if (ops->ops->init_device(dev) >= 0) {
92603 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
92604 ops->num_init_devices++;
92605 } else {
92606 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
92607 dev->name, ops->id, ops->argsize, dev->argsize);
92608 return -EINVAL;
92609 }
92610 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
92611 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
92612 dev->status = SNDRV_SEQ_DEVICE_FREE;
92613 dev->driver_data = NULL;
92614 ops->num_init_devices--;
92615 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
92616 index 4e0dd22..7a1f32c 100644
92617 --- a/sound/drivers/mts64.c
92618 +++ b/sound/drivers/mts64.c
92619 @@ -29,6 +29,7 @@
92620 #include <sound/initval.h>
92621 #include <sound/rawmidi.h>
92622 #include <sound/control.h>
92623 +#include <asm/local.h>
92624
92625 #define CARD_NAME "Miditerminal 4140"
92626 #define DRIVER_NAME "MTS64"
92627 @@ -67,7 +68,7 @@ struct mts64 {
92628 struct pardevice *pardev;
92629 int pardev_claimed;
92630
92631 - int open_count;
92632 + local_t open_count;
92633 int current_midi_output_port;
92634 int current_midi_input_port;
92635 u8 mode[MTS64_NUM_INPUT_PORTS];
92636 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
92637 {
92638 struct mts64 *mts = substream->rmidi->private_data;
92639
92640 - if (mts->open_count == 0) {
92641 + if (local_read(&mts->open_count) == 0) {
92642 /* We don't need a spinlock here, because this is just called
92643 if the device has not been opened before.
92644 So there aren't any IRQs from the device */
92645 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
92646
92647 msleep(50);
92648 }
92649 - ++(mts->open_count);
92650 + local_inc(&mts->open_count);
92651
92652 return 0;
92653 }
92654 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92655 struct mts64 *mts = substream->rmidi->private_data;
92656 unsigned long flags;
92657
92658 - --(mts->open_count);
92659 - if (mts->open_count == 0) {
92660 + if (local_dec_return(&mts->open_count) == 0) {
92661 /* We need the spinlock_irqsave here because we can still
92662 have IRQs at this point */
92663 spin_lock_irqsave(&mts->lock, flags);
92664 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92665
92666 msleep(500);
92667
92668 - } else if (mts->open_count < 0)
92669 - mts->open_count = 0;
92670 + } else if (local_read(&mts->open_count) < 0)
92671 + local_set(&mts->open_count, 0);
92672
92673 return 0;
92674 }
92675 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
92676 index b953fb4..1999c01 100644
92677 --- a/sound/drivers/opl4/opl4_lib.c
92678 +++ b/sound/drivers/opl4/opl4_lib.c
92679 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
92680 MODULE_DESCRIPTION("OPL4 driver");
92681 MODULE_LICENSE("GPL");
92682
92683 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
92684 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
92685 {
92686 int timeout = 10;
92687 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
92688 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
92689 index 991018d..8984740 100644
92690 --- a/sound/drivers/portman2x4.c
92691 +++ b/sound/drivers/portman2x4.c
92692 @@ -48,6 +48,7 @@
92693 #include <sound/initval.h>
92694 #include <sound/rawmidi.h>
92695 #include <sound/control.h>
92696 +#include <asm/local.h>
92697
92698 #define CARD_NAME "Portman 2x4"
92699 #define DRIVER_NAME "portman"
92700 @@ -85,7 +86,7 @@ struct portman {
92701 struct pardevice *pardev;
92702 int pardev_claimed;
92703
92704 - int open_count;
92705 + local_t open_count;
92706 int mode[PORTMAN_NUM_INPUT_PORTS];
92707 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
92708 };
92709 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
92710 index ea995af..f1bfa37 100644
92711 --- a/sound/firewire/amdtp.c
92712 +++ b/sound/firewire/amdtp.c
92713 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
92714 ptr = s->pcm_buffer_pointer + data_blocks;
92715 if (ptr >= pcm->runtime->buffer_size)
92716 ptr -= pcm->runtime->buffer_size;
92717 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
92718 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
92719
92720 s->pcm_period_pointer += data_blocks;
92721 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
92722 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
92723 */
92724 void amdtp_out_stream_update(struct amdtp_out_stream *s)
92725 {
92726 - ACCESS_ONCE(s->source_node_id_field) =
92727 + ACCESS_ONCE_RW(s->source_node_id_field) =
92728 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
92729 }
92730 EXPORT_SYMBOL(amdtp_out_stream_update);
92731 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
92732 index b680c5e..061b7a0 100644
92733 --- a/sound/firewire/amdtp.h
92734 +++ b/sound/firewire/amdtp.h
92735 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
92736 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
92737 struct snd_pcm_substream *pcm)
92738 {
92739 - ACCESS_ONCE(s->pcm) = pcm;
92740 + ACCESS_ONCE_RW(s->pcm) = pcm;
92741 }
92742
92743 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
92744 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
92745 index d428ffe..751ef78 100644
92746 --- a/sound/firewire/isight.c
92747 +++ b/sound/firewire/isight.c
92748 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
92749 ptr += count;
92750 if (ptr >= runtime->buffer_size)
92751 ptr -= runtime->buffer_size;
92752 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
92753 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
92754
92755 isight->period_counter += count;
92756 if (isight->period_counter >= runtime->period_size) {
92757 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
92758 if (err < 0)
92759 return err;
92760
92761 - ACCESS_ONCE(isight->pcm_active) = true;
92762 + ACCESS_ONCE_RW(isight->pcm_active) = true;
92763
92764 return 0;
92765 }
92766 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
92767 {
92768 struct isight *isight = substream->private_data;
92769
92770 - ACCESS_ONCE(isight->pcm_active) = false;
92771 + ACCESS_ONCE_RW(isight->pcm_active) = false;
92772
92773 mutex_lock(&isight->mutex);
92774 isight_stop_streaming(isight);
92775 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
92776
92777 switch (cmd) {
92778 case SNDRV_PCM_TRIGGER_START:
92779 - ACCESS_ONCE(isight->pcm_running) = true;
92780 + ACCESS_ONCE_RW(isight->pcm_running) = true;
92781 break;
92782 case SNDRV_PCM_TRIGGER_STOP:
92783 - ACCESS_ONCE(isight->pcm_running) = false;
92784 + ACCESS_ONCE_RW(isight->pcm_running) = false;
92785 break;
92786 default:
92787 return -EINVAL;
92788 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
92789 index 844a555..985ab83 100644
92790 --- a/sound/firewire/scs1x.c
92791 +++ b/sound/firewire/scs1x.c
92792 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
92793 {
92794 struct scs *scs = stream->rmidi->private_data;
92795
92796 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
92797 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
92798 if (up) {
92799 scs->output_idle = false;
92800 tasklet_schedule(&scs->tasklet);
92801 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
92802 {
92803 struct scs *scs = stream->rmidi->private_data;
92804
92805 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
92806 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
92807 }
92808
92809 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
92810 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
92811
92812 snd_card_disconnect(scs->card);
92813
92814 - ACCESS_ONCE(scs->output) = NULL;
92815 - ACCESS_ONCE(scs->input) = NULL;
92816 + ACCESS_ONCE_RW(scs->output) = NULL;
92817 + ACCESS_ONCE_RW(scs->input) = NULL;
92818
92819 wait_event(scs->idle_wait, scs->output_idle);
92820
92821 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
92822 index 048439a..3be9f6f 100644
92823 --- a/sound/oss/sb_audio.c
92824 +++ b/sound/oss/sb_audio.c
92825 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
92826 buf16 = (signed short *)(localbuf + localoffs);
92827 while (c)
92828 {
92829 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
92830 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
92831 if (copy_from_user(lbuf8,
92832 userbuf+useroffs + p,
92833 locallen))
92834 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
92835 index 7d8803a..559f8d0 100644
92836 --- a/sound/oss/swarm_cs4297a.c
92837 +++ b/sound/oss/swarm_cs4297a.c
92838 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
92839 {
92840 struct cs4297a_state *s;
92841 u32 pwr, id;
92842 - mm_segment_t fs;
92843 int rval;
92844 #ifndef CONFIG_BCM_CS4297A_CSWARM
92845 u64 cfg;
92846 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
92847 if (!rval) {
92848 char *sb1250_duart_present;
92849
92850 +#if 0
92851 + mm_segment_t fs;
92852 fs = get_fs();
92853 set_fs(KERNEL_DS);
92854 -#if 0
92855 val = SOUND_MASK_LINE;
92856 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
92857 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
92858 val = initvol[i].vol;
92859 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
92860 }
92861 + set_fs(fs);
92862 // cs4297a_write_ac97(s, 0x18, 0x0808);
92863 #else
92864 // cs4297a_write_ac97(s, 0x5e, 0x180);
92865 cs4297a_write_ac97(s, 0x02, 0x0808);
92866 cs4297a_write_ac97(s, 0x18, 0x0808);
92867 #endif
92868 - set_fs(fs);
92869
92870 list_add(&s->list, &cs4297a_devs);
92871
92872 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
92873 index 4631a23..001ae57 100644
92874 --- a/sound/pci/ymfpci/ymfpci.h
92875 +++ b/sound/pci/ymfpci/ymfpci.h
92876 @@ -358,7 +358,7 @@ struct snd_ymfpci {
92877 spinlock_t reg_lock;
92878 spinlock_t voice_lock;
92879 wait_queue_head_t interrupt_sleep;
92880 - atomic_t interrupt_sleep_count;
92881 + atomic_unchecked_t interrupt_sleep_count;
92882 struct snd_info_entry *proc_entry;
92883 const struct firmware *dsp_microcode;
92884 const struct firmware *controller_microcode;
92885 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
92886 index 22056c5..25d3244 100644
92887 --- a/sound/pci/ymfpci/ymfpci_main.c
92888 +++ b/sound/pci/ymfpci/ymfpci_main.c
92889 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
92890 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
92891 break;
92892 }
92893 - if (atomic_read(&chip->interrupt_sleep_count)) {
92894 - atomic_set(&chip->interrupt_sleep_count, 0);
92895 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92896 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92897 wake_up(&chip->interrupt_sleep);
92898 }
92899 __end:
92900 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
92901 continue;
92902 init_waitqueue_entry(&wait, current);
92903 add_wait_queue(&chip->interrupt_sleep, &wait);
92904 - atomic_inc(&chip->interrupt_sleep_count);
92905 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
92906 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
92907 remove_wait_queue(&chip->interrupt_sleep, &wait);
92908 }
92909 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
92910 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
92911 spin_unlock(&chip->reg_lock);
92912
92913 - if (atomic_read(&chip->interrupt_sleep_count)) {
92914 - atomic_set(&chip->interrupt_sleep_count, 0);
92915 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92916 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92917 wake_up(&chip->interrupt_sleep);
92918 }
92919 }
92920 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
92921 spin_lock_init(&chip->reg_lock);
92922 spin_lock_init(&chip->voice_lock);
92923 init_waitqueue_head(&chip->interrupt_sleep);
92924 - atomic_set(&chip->interrupt_sleep_count, 0);
92925 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92926 chip->card = card;
92927 chip->pci = pci;
92928 chip->irq = -1;
92929 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
92930 index 7decbd9..d17d9d0 100644
92931 --- a/sound/soc/fsl/fsl_ssi.c
92932 +++ b/sound/soc/fsl/fsl_ssi.c
92933 @@ -643,7 +643,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
92934 {
92935 struct fsl_ssi_private *ssi_private;
92936 int ret = 0;
92937 - struct device_attribute *dev_attr = NULL;
92938 + device_attribute_no_const *dev_attr = NULL;
92939 struct device_node *np = pdev->dev.of_node;
92940 const char *p, *sprop;
92941 const uint32_t *iprop;
92942 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
92943 new file mode 100644
92944 index 0000000..50f2f2f
92945 --- /dev/null
92946 +++ b/tools/gcc/.gitignore
92947 @@ -0,0 +1 @@
92948 +size_overflow_hash.h
92949 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
92950 new file mode 100644
92951 index 0000000..144dbee
92952 --- /dev/null
92953 +++ b/tools/gcc/Makefile
92954 @@ -0,0 +1,45 @@
92955 +#CC := gcc
92956 +#PLUGIN_SOURCE_FILES := pax_plugin.c
92957 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
92958 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
92959 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
92960 +
92961 +ifeq ($(PLUGINCC),$(HOSTCC))
92962 +HOSTLIBS := hostlibs
92963 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
92964 +else
92965 +HOSTLIBS := hostcxxlibs
92966 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
92967 +endif
92968 +
92969 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
92970 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
92971 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
92972 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
92973 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
92974 +$(HOSTLIBS)-y += colorize_plugin.so
92975 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
92976 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
92977 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
92978 +
92979 +always := $($(HOSTLIBS)-y)
92980 +
92981 +constify_plugin-objs := constify_plugin.o
92982 +stackleak_plugin-objs := stackleak_plugin.o
92983 +kallocstat_plugin-objs := kallocstat_plugin.o
92984 +kernexec_plugin-objs := kernexec_plugin.o
92985 +checker_plugin-objs := checker_plugin.o
92986 +colorize_plugin-objs := colorize_plugin.o
92987 +size_overflow_plugin-objs := size_overflow_plugin.o
92988 +latent_entropy_plugin-objs := latent_entropy_plugin.o
92989 +structleak_plugin-objs := structleak_plugin.o
92990 +
92991 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
92992 +
92993 +quiet_cmd_build_size_overflow_hash = GENHASH $@
92994 + cmd_build_size_overflow_hash = \
92995 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
92996 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
92997 + $(call if_changed,build_size_overflow_hash)
92998 +
92999 +targets += size_overflow_hash.h
93000 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
93001 new file mode 100644
93002 index 0000000..22f03c0
93003 --- /dev/null
93004 +++ b/tools/gcc/checker_plugin.c
93005 @@ -0,0 +1,172 @@
93006 +/*
93007 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
93008 + * Licensed under the GPL v2
93009 + *
93010 + * Note: the choice of the license means that the compilation process is
93011 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93012 + * but for the kernel it doesn't matter since it doesn't link against
93013 + * any of the gcc libraries
93014 + *
93015 + * gcc plugin to implement various sparse (source code checker) features
93016 + *
93017 + * TODO:
93018 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
93019 + *
93020 + * BUGS:
93021 + * - none known
93022 + */
93023 +#include "gcc-plugin.h"
93024 +#include "config.h"
93025 +#include "system.h"
93026 +#include "coretypes.h"
93027 +#include "tree.h"
93028 +#include "tree-pass.h"
93029 +#include "flags.h"
93030 +#include "intl.h"
93031 +#include "toplev.h"
93032 +#include "plugin.h"
93033 +//#include "expr.h" where are you...
93034 +#include "diagnostic.h"
93035 +#include "plugin-version.h"
93036 +#include "tm.h"
93037 +#include "function.h"
93038 +#include "basic-block.h"
93039 +#include "gimple.h"
93040 +#include "rtl.h"
93041 +#include "emit-rtl.h"
93042 +#include "tree-flow.h"
93043 +#include "target.h"
93044 +
93045 +extern void c_register_addr_space (const char *str, addr_space_t as);
93046 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
93047 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
93048 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
93049 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
93050 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
93051 +
93052 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93053 +extern rtx emit_move_insn(rtx x, rtx y);
93054 +
93055 +int plugin_is_GPL_compatible;
93056 +
93057 +static struct plugin_info checker_plugin_info = {
93058 + .version = "201111150100",
93059 + .help = NULL,
93060 +};
93061 +
93062 +#define ADDR_SPACE_KERNEL 0
93063 +#define ADDR_SPACE_FORCE_KERNEL 1
93064 +#define ADDR_SPACE_USER 2
93065 +#define ADDR_SPACE_FORCE_USER 3
93066 +#define ADDR_SPACE_IOMEM 0
93067 +#define ADDR_SPACE_FORCE_IOMEM 0
93068 +#define ADDR_SPACE_PERCPU 0
93069 +#define ADDR_SPACE_FORCE_PERCPU 0
93070 +#define ADDR_SPACE_RCU 0
93071 +#define ADDR_SPACE_FORCE_RCU 0
93072 +
93073 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
93074 +{
93075 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
93076 +}
93077 +
93078 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
93079 +{
93080 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
93081 +}
93082 +
93083 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
93084 +{
93085 + return default_addr_space_valid_pointer_mode(mode, as);
93086 +}
93087 +
93088 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
93089 +{
93090 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
93091 +}
93092 +
93093 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
93094 +{
93095 + return default_addr_space_legitimize_address(x, oldx, mode, as);
93096 +}
93097 +
93098 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
93099 +{
93100 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
93101 + return true;
93102 +
93103 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
93104 + return true;
93105 +
93106 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
93107 + return true;
93108 +
93109 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
93110 + return true;
93111 +
93112 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
93113 + return true;
93114 +
93115 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
93116 + return true;
93117 +
93118 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
93119 + return true;
93120 +
93121 + return subset == superset;
93122 +}
93123 +
93124 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
93125 +{
93126 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
93127 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
93128 +
93129 + return op;
93130 +}
93131 +
93132 +static void register_checker_address_spaces(void *event_data, void *data)
93133 +{
93134 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
93135 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
93136 + c_register_addr_space("__user", ADDR_SPACE_USER);
93137 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
93138 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
93139 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
93140 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
93141 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
93142 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
93143 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
93144 +
93145 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
93146 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
93147 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
93148 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
93149 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
93150 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
93151 + targetm.addr_space.convert = checker_addr_space_convert;
93152 +}
93153 +
93154 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93155 +{
93156 + const char * const plugin_name = plugin_info->base_name;
93157 + const int argc = plugin_info->argc;
93158 + const struct plugin_argument * const argv = plugin_info->argv;
93159 + int i;
93160 +
93161 + if (!plugin_default_version_check(version, &gcc_version)) {
93162 + error(G_("incompatible gcc/plugin versions"));
93163 + return 1;
93164 + }
93165 +
93166 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
93167 +
93168 + for (i = 0; i < argc; ++i)
93169 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93170 +
93171 + if (TARGET_64BIT == 0)
93172 + return 0;
93173 +
93174 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
93175 +
93176 + return 0;
93177 +}
93178 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
93179 new file mode 100644
93180 index 0000000..414fe5e
93181 --- /dev/null
93182 +++ b/tools/gcc/colorize_plugin.c
93183 @@ -0,0 +1,151 @@
93184 +/*
93185 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
93186 + * Licensed under the GPL v2
93187 + *
93188 + * Note: the choice of the license means that the compilation process is
93189 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93190 + * but for the kernel it doesn't matter since it doesn't link against
93191 + * any of the gcc libraries
93192 + *
93193 + * gcc plugin to colorize diagnostic output
93194 + *
93195 + */
93196 +
93197 +#include "gcc-plugin.h"
93198 +#include "config.h"
93199 +#include "system.h"
93200 +#include "coretypes.h"
93201 +#include "tree.h"
93202 +#include "tree-pass.h"
93203 +#include "flags.h"
93204 +#include "intl.h"
93205 +#include "toplev.h"
93206 +#include "plugin.h"
93207 +#include "diagnostic.h"
93208 +#include "plugin-version.h"
93209 +#include "tm.h"
93210 +
93211 +int plugin_is_GPL_compatible;
93212 +
93213 +static struct plugin_info colorize_plugin_info = {
93214 + .version = "201302112000",
93215 + .help = NULL,
93216 +};
93217 +
93218 +#define GREEN "\033[32m\033[2m"
93219 +#define LIGHTGREEN "\033[32m\033[1m"
93220 +#define YELLOW "\033[33m\033[2m"
93221 +#define LIGHTYELLOW "\033[33m\033[1m"
93222 +#define RED "\033[31m\033[2m"
93223 +#define LIGHTRED "\033[31m\033[1m"
93224 +#define BLUE "\033[34m\033[2m"
93225 +#define LIGHTBLUE "\033[34m\033[1m"
93226 +#define BRIGHT "\033[m\033[1m"
93227 +#define NORMAL "\033[m"
93228 +
93229 +static diagnostic_starter_fn old_starter;
93230 +static diagnostic_finalizer_fn old_finalizer;
93231 +
93232 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93233 +{
93234 + const char *color;
93235 + char *newprefix;
93236 +
93237 + switch (diagnostic->kind) {
93238 + case DK_NOTE:
93239 + color = LIGHTBLUE;
93240 + break;
93241 +
93242 + case DK_PEDWARN:
93243 + case DK_WARNING:
93244 + color = LIGHTYELLOW;
93245 + break;
93246 +
93247 + case DK_ERROR:
93248 + case DK_FATAL:
93249 + case DK_ICE:
93250 + case DK_PERMERROR:
93251 + case DK_SORRY:
93252 + color = LIGHTRED;
93253 + break;
93254 +
93255 + default:
93256 + color = NORMAL;
93257 + }
93258 +
93259 + old_starter(context, diagnostic);
93260 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
93261 + return;
93262 + pp_destroy_prefix(context->printer);
93263 + pp_set_prefix(context->printer, newprefix);
93264 +}
93265 +
93266 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93267 +{
93268 + old_finalizer(context, diagnostic);
93269 +}
93270 +
93271 +static void colorize_arm(void)
93272 +{
93273 + old_starter = diagnostic_starter(global_dc);
93274 + old_finalizer = diagnostic_finalizer(global_dc);
93275 +
93276 + diagnostic_starter(global_dc) = start_colorize;
93277 + diagnostic_finalizer(global_dc) = finalize_colorize;
93278 +}
93279 +
93280 +static unsigned int execute_colorize_rearm(void)
93281 +{
93282 + if (diagnostic_starter(global_dc) == start_colorize)
93283 + return 0;
93284 +
93285 + colorize_arm();
93286 + return 0;
93287 +}
93288 +
93289 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
93290 + .pass = {
93291 + .type = SIMPLE_IPA_PASS,
93292 + .name = "colorize_rearm",
93293 +#if BUILDING_GCC_VERSION >= 4008
93294 + .optinfo_flags = OPTGROUP_NONE,
93295 +#endif
93296 + .gate = NULL,
93297 + .execute = execute_colorize_rearm,
93298 + .sub = NULL,
93299 + .next = NULL,
93300 + .static_pass_number = 0,
93301 + .tv_id = TV_NONE,
93302 + .properties_required = 0,
93303 + .properties_provided = 0,
93304 + .properties_destroyed = 0,
93305 + .todo_flags_start = 0,
93306 + .todo_flags_finish = 0
93307 + }
93308 +};
93309 +
93310 +static void colorize_start_unit(void *gcc_data, void *user_data)
93311 +{
93312 + colorize_arm();
93313 +}
93314 +
93315 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93316 +{
93317 + const char * const plugin_name = plugin_info->base_name;
93318 + struct register_pass_info colorize_rearm_pass_info = {
93319 + .pass = &pass_ipa_colorize_rearm.pass,
93320 + .reference_pass_name = "*free_lang_data",
93321 + .ref_pass_instance_number = 1,
93322 + .pos_op = PASS_POS_INSERT_AFTER
93323 + };
93324 +
93325 + if (!plugin_default_version_check(version, &gcc_version)) {
93326 + error(G_("incompatible gcc/plugin versions"));
93327 + return 1;
93328 + }
93329 +
93330 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
93331 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
93332 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
93333 + return 0;
93334 +}
93335 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
93336 new file mode 100644
93337 index 0000000..c17312d
93338 --- /dev/null
93339 +++ b/tools/gcc/constify_plugin.c
93340 @@ -0,0 +1,560 @@
93341 +/*
93342 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
93343 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
93344 + * Licensed under the GPL v2, or (at your option) v3
93345 + *
93346 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
93347 + *
93348 + * Homepage:
93349 + * http://www.grsecurity.net/~ephox/const_plugin/
93350 + *
93351 + * Usage:
93352 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
93353 + * $ gcc -fplugin=constify_plugin.so test.c -O2
93354 + */
93355 +
93356 +#include "gcc-plugin.h"
93357 +#include "config.h"
93358 +#include "system.h"
93359 +#include "coretypes.h"
93360 +#include "tree.h"
93361 +#include "tree-pass.h"
93362 +#include "flags.h"
93363 +#include "intl.h"
93364 +#include "toplev.h"
93365 +#include "plugin.h"
93366 +#include "diagnostic.h"
93367 +#include "plugin-version.h"
93368 +#include "tm.h"
93369 +#include "function.h"
93370 +#include "basic-block.h"
93371 +#include "gimple.h"
93372 +#include "rtl.h"
93373 +#include "emit-rtl.h"
93374 +#include "tree-flow.h"
93375 +#include "target.h"
93376 +#include "langhooks.h"
93377 +
93378 +// should come from c-tree.h if only it were installed for gcc 4.5...
93379 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
93380 +
93381 +// unused type flag in all versions 4.5-4.8
93382 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
93383 +
93384 +int plugin_is_GPL_compatible;
93385 +
93386 +static struct plugin_info const_plugin_info = {
93387 + .version = "201305231310",
93388 + .help = "no-constify\tturn off constification\n",
93389 +};
93390 +
93391 +typedef struct {
93392 + bool has_fptr_field;
93393 + bool has_writable_field;
93394 + bool has_do_const_field;
93395 + bool has_no_const_field;
93396 +} constify_info;
93397 +
93398 +static const_tree get_field_type(const_tree field)
93399 +{
93400 + return strip_array_types(TREE_TYPE(field));
93401 +}
93402 +
93403 +static bool is_fptr(const_tree field)
93404 +{
93405 + const_tree ptr = get_field_type(field);
93406 +
93407 + if (TREE_CODE(ptr) != POINTER_TYPE)
93408 + return false;
93409 +
93410 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
93411 +}
93412 +
93413 +/*
93414 + * determine whether the given structure type meets the requirements for automatic constification,
93415 + * including the constification attributes on nested structure types
93416 + */
93417 +static void constifiable(const_tree node, constify_info *cinfo)
93418 +{
93419 + const_tree field;
93420 +
93421 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93422 +
93423 + // e.g., pointer to structure fields while still constructing the structure type
93424 + if (TYPE_FIELDS(node) == NULL_TREE)
93425 + return;
93426 +
93427 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
93428 + const_tree type = get_field_type(field);
93429 + enum tree_code code = TREE_CODE(type);
93430 +
93431 + if (node == type)
93432 + continue;
93433 +
93434 + if (is_fptr(field))
93435 + cinfo->has_fptr_field = true;
93436 + else if (!TREE_READONLY(field))
93437 + cinfo->has_writable_field = true;
93438 +
93439 + if (code == RECORD_TYPE || code == UNION_TYPE) {
93440 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93441 + cinfo->has_do_const_field = true;
93442 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
93443 + cinfo->has_no_const_field = true;
93444 + else
93445 + constifiable(type, cinfo);
93446 + }
93447 + }
93448 +}
93449 +
93450 +static bool constified(const_tree node)
93451 +{
93452 + constify_info cinfo = {
93453 + .has_fptr_field = false,
93454 + .has_writable_field = false,
93455 + .has_do_const_field = false,
93456 + .has_no_const_field = false
93457 + };
93458 +
93459 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93460 +
93461 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
93462 + gcc_assert(!TYPE_READONLY(node));
93463 + return false;
93464 + }
93465 +
93466 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
93467 + gcc_assert(TYPE_READONLY(node));
93468 + return true;
93469 + }
93470 +
93471 + constifiable(node, &cinfo);
93472 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
93473 + return false;
93474 +
93475 + return TYPE_READONLY(node);
93476 +}
93477 +
93478 +static void deconstify_tree(tree node);
93479 +
93480 +static void deconstify_type(tree type)
93481 +{
93482 + tree field;
93483 +
93484 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
93485 +
93486 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
93487 + const_tree fieldtype = get_field_type(field);
93488 +
93489 + // special case handling of simple ptr-to-same-array-type members
93490 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
93491 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
93492 +
93493 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
93494 + continue;
93495 + if (TREE_TYPE(TREE_TYPE(field)) == type)
93496 + continue;
93497 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
93498 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
93499 + TREE_TYPE(TREE_TYPE(field)) = type;
93500 + }
93501 + continue;
93502 + }
93503 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
93504 + continue;
93505 + if (!constified(fieldtype))
93506 + continue;
93507 +
93508 + deconstify_tree(field);
93509 + TREE_READONLY(field) = 0;
93510 + }
93511 + TYPE_READONLY(type) = 0;
93512 + C_TYPE_FIELDS_READONLY(type) = 0;
93513 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93514 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
93515 +}
93516 +
93517 +static void deconstify_tree(tree node)
93518 +{
93519 + tree old_type, new_type, field;
93520 +
93521 + old_type = TREE_TYPE(node);
93522 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
93523 + node = TREE_TYPE(node) = copy_node(old_type);
93524 + old_type = TREE_TYPE(old_type);
93525 + }
93526 +
93527 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
93528 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
93529 +
93530 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
93531 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
93532 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
93533 + DECL_FIELD_CONTEXT(field) = new_type;
93534 +
93535 + deconstify_type(new_type);
93536 +
93537 + TREE_TYPE(node) = new_type;
93538 +}
93539 +
93540 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93541 +{
93542 + tree type;
93543 + constify_info cinfo = {
93544 + .has_fptr_field = false,
93545 + .has_writable_field = false,
93546 + .has_do_const_field = false,
93547 + .has_no_const_field = false
93548 + };
93549 +
93550 + *no_add_attrs = true;
93551 + if (TREE_CODE(*node) == FUNCTION_DECL) {
93552 + error("%qE attribute does not apply to functions", name);
93553 + return NULL_TREE;
93554 + }
93555 +
93556 + if (TREE_CODE(*node) == PARM_DECL) {
93557 + error("%qE attribute does not apply to function parameters", name);
93558 + return NULL_TREE;
93559 + }
93560 +
93561 + if (TREE_CODE(*node) == VAR_DECL) {
93562 + error("%qE attribute does not apply to variables", name);
93563 + return NULL_TREE;
93564 + }
93565 +
93566 + if (TYPE_P(*node)) {
93567 + *no_add_attrs = false;
93568 + type = *node;
93569 + } else {
93570 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
93571 + type = TREE_TYPE(*node);
93572 + }
93573 +
93574 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
93575 + error("%qE attribute applies to struct and union types only", name);
93576 + return NULL_TREE;
93577 + }
93578 +
93579 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
93580 + error("%qE attribute is already applied to the type", name);
93581 + return NULL_TREE;
93582 + }
93583 +
93584 + if (TYPE_P(*node)) {
93585 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93586 + error("%qE attribute is incompatible with 'do_const'", name);
93587 + return NULL_TREE;
93588 + }
93589 +
93590 + constifiable(type, &cinfo);
93591 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93592 + deconstify_tree(*node);
93593 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
93594 + return NULL_TREE;
93595 + }
93596 +
93597 + error("%qE attribute used on type that is not constified", name);
93598 + return NULL_TREE;
93599 +}
93600 +
93601 +static void constify_type(tree type)
93602 +{
93603 + TYPE_READONLY(type) = 1;
93604 + C_TYPE_FIELDS_READONLY(type) = 1;
93605 + TYPE_CONSTIFY_VISITED(type) = 1;
93606 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
93607 +}
93608 +
93609 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93610 +{
93611 + *no_add_attrs = true;
93612 + if (!TYPE_P(*node)) {
93613 + error("%qE attribute applies to types only", name);
93614 + return NULL_TREE;
93615 + }
93616 +
93617 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
93618 + error("%qE attribute applies to struct and union types only", name);
93619 + return NULL_TREE;
93620 + }
93621 +
93622 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
93623 + error("%qE attribute is already applied to the type", name);
93624 + return NULL_TREE;
93625 + }
93626 +
93627 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
93628 + error("%qE attribute is incompatible with 'no_const'", name);
93629 + return NULL_TREE;
93630 + }
93631 +
93632 + *no_add_attrs = false;
93633 + return NULL_TREE;
93634 +}
93635 +
93636 +static struct attribute_spec no_const_attr = {
93637 + .name = "no_const",
93638 + .min_length = 0,
93639 + .max_length = 0,
93640 + .decl_required = false,
93641 + .type_required = false,
93642 + .function_type_required = false,
93643 + .handler = handle_no_const_attribute,
93644 +#if BUILDING_GCC_VERSION >= 4007
93645 + .affects_type_identity = true
93646 +#endif
93647 +};
93648 +
93649 +static struct attribute_spec do_const_attr = {
93650 + .name = "do_const",
93651 + .min_length = 0,
93652 + .max_length = 0,
93653 + .decl_required = false,
93654 + .type_required = false,
93655 + .function_type_required = false,
93656 + .handler = handle_do_const_attribute,
93657 +#if BUILDING_GCC_VERSION >= 4007
93658 + .affects_type_identity = true
93659 +#endif
93660 +};
93661 +
93662 +static void register_attributes(void *event_data, void *data)
93663 +{
93664 + register_attribute(&no_const_attr);
93665 + register_attribute(&do_const_attr);
93666 +}
93667 +
93668 +static void finish_type(void *event_data, void *data)
93669 +{
93670 + tree type = (tree)event_data;
93671 + constify_info cinfo = {
93672 + .has_fptr_field = false,
93673 + .has_writable_field = false,
93674 + .has_do_const_field = false,
93675 + .has_no_const_field = false
93676 + };
93677 +
93678 + if (type == NULL_TREE || type == error_mark_node)
93679 + return;
93680 +
93681 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
93682 + return;
93683 +
93684 + constifiable(type, &cinfo);
93685 +
93686 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
93687 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93688 + return;
93689 + if (cinfo.has_writable_field)
93690 + return;
93691 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
93692 + return;
93693 + }
93694 +
93695 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
93696 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
93697 + deconstify_type(type);
93698 + TYPE_CONSTIFY_VISITED(type) = 1;
93699 + } else
93700 + error("'no_const' attribute used on type that is not constified");
93701 + return;
93702 + }
93703 +
93704 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93705 + constify_type(type);
93706 + return;
93707 + }
93708 +
93709 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
93710 + constify_type(type);
93711 + return;
93712 + }
93713 +
93714 + deconstify_type(type);
93715 + TYPE_CONSTIFY_VISITED(type) = 1;
93716 +}
93717 +
93718 +static void check_global_variables(void)
93719 +{
93720 + struct varpool_node *node;
93721 +
93722 +#if BUILDING_GCC_VERSION <= 4007
93723 + for (node = varpool_nodes; node; node = node->next) {
93724 + tree var = node->decl;
93725 +#else
93726 + FOR_EACH_VARIABLE(node) {
93727 + tree var = node->symbol.decl;
93728 +#endif
93729 + tree type = TREE_TYPE(var);
93730 +
93731 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
93732 + continue;
93733 +
93734 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
93735 + continue;
93736 +
93737 + if (!TYPE_CONSTIFY_VISITED(type))
93738 + continue;
93739 +
93740 + if (DECL_EXTERNAL(var))
93741 + continue;
93742 +
93743 + if (DECL_INITIAL(var))
93744 + continue;
93745 +
93746 + // this works around a gcc bug/feature where uninitialized globals
93747 + // are moved into the .bss section regardless of any constification
93748 + DECL_INITIAL(var) = build_constructor(type, NULL);
93749 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
93750 + }
93751 +}
93752 +
93753 +static unsigned int check_local_variables(void)
93754 +{
93755 + unsigned int ret = 0;
93756 + tree var;
93757 +
93758 +#if BUILDING_GCC_VERSION == 4005
93759 + tree vars;
93760 +#else
93761 + unsigned int i;
93762 +#endif
93763 +
93764 +#if BUILDING_GCC_VERSION == 4005
93765 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
93766 + var = TREE_VALUE(vars);
93767 +#else
93768 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
93769 +#endif
93770 + tree type = TREE_TYPE(var);
93771 +
93772 + gcc_assert(DECL_P(var));
93773 + if (is_global_var(var))
93774 + continue;
93775 +
93776 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
93777 + continue;
93778 +
93779 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
93780 + continue;
93781 +
93782 + if (!TYPE_CONSTIFY_VISITED(type))
93783 + continue;
93784 +
93785 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
93786 + ret = 1;
93787 + }
93788 + return ret;
93789 +}
93790 +
93791 +static unsigned int check_variables(void)
93792 +{
93793 + check_global_variables();
93794 + return check_local_variables();
93795 +}
93796 +
93797 + unsigned int ret = 0;
93798 +static struct gimple_opt_pass pass_local_variable = {
93799 + {
93800 + .type = GIMPLE_PASS,
93801 + .name = "check_variables",
93802 +#if BUILDING_GCC_VERSION >= 4008
93803 + .optinfo_flags = OPTGROUP_NONE,
93804 +#endif
93805 + .gate = NULL,
93806 + .execute = check_variables,
93807 + .sub = NULL,
93808 + .next = NULL,
93809 + .static_pass_number = 0,
93810 + .tv_id = TV_NONE,
93811 + .properties_required = 0,
93812 + .properties_provided = 0,
93813 + .properties_destroyed = 0,
93814 + .todo_flags_start = 0,
93815 + .todo_flags_finish = 0
93816 + }
93817 +};
93818 +
93819 +static struct {
93820 + const char *name;
93821 + const char *asm_op;
93822 +} sections[] = {
93823 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
93824 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
93825 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
93826 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
93827 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
93828 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
93829 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
93830 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
93831 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
93832 +};
93833 +
93834 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
93835 +
93836 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
93837 +{
93838 + size_t i;
93839 +
93840 + for (i = 0; i < ARRAY_SIZE(sections); i++)
93841 + if (!strcmp(sections[i].name, name))
93842 + return 0;
93843 + return old_section_type_flags(decl, name, reloc);
93844 +}
93845 +
93846 +static void constify_start_unit(void *gcc_data, void *user_data)
93847 +{
93848 +// size_t i;
93849 +
93850 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
93851 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
93852 +// sections[i].section = get_section(sections[i].name, 0, NULL);
93853 +
93854 + old_section_type_flags = targetm.section_type_flags;
93855 + targetm.section_type_flags = constify_section_type_flags;
93856 +}
93857 +
93858 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93859 +{
93860 + const char * const plugin_name = plugin_info->base_name;
93861 + const int argc = plugin_info->argc;
93862 + const struct plugin_argument * const argv = plugin_info->argv;
93863 + int i;
93864 + bool constify = true;
93865 +
93866 + struct register_pass_info local_variable_pass_info = {
93867 + .pass = &pass_local_variable.pass,
93868 + .reference_pass_name = "ssa",
93869 + .ref_pass_instance_number = 1,
93870 + .pos_op = PASS_POS_INSERT_BEFORE
93871 + };
93872 +
93873 + if (!plugin_default_version_check(version, &gcc_version)) {
93874 + error(G_("incompatible gcc/plugin versions"));
93875 + return 1;
93876 + }
93877 +
93878 + for (i = 0; i < argc; ++i) {
93879 + if (!(strcmp(argv[i].key, "no-constify"))) {
93880 + constify = false;
93881 + continue;
93882 + }
93883 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93884 + }
93885 +
93886 + if (strcmp(lang_hooks.name, "GNU C")) {
93887 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
93888 + constify = false;
93889 + }
93890 +
93891 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
93892 + if (constify) {
93893 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
93894 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
93895 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
93896 + }
93897 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
93898 +
93899 + return 0;
93900 +}
93901 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
93902 new file mode 100644
93903 index 0000000..e518932
93904 --- /dev/null
93905 +++ b/tools/gcc/generate_size_overflow_hash.sh
93906 @@ -0,0 +1,94 @@
93907 +#!/bin/bash
93908 +
93909 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
93910 +
93911 +header1="size_overflow_hash.h"
93912 +database="size_overflow_hash.data"
93913 +n=65536
93914 +
93915 +usage() {
93916 +cat <<EOF
93917 +usage: $0 options
93918 +OPTIONS:
93919 + -h|--help help
93920 + -o header file
93921 + -d database file
93922 + -n hash array size
93923 +EOF
93924 + return 0
93925 +}
93926 +
93927 +while true
93928 +do
93929 + case "$1" in
93930 + -h|--help) usage && exit 0;;
93931 + -n) n=$2; shift 2;;
93932 + -o) header1="$2"; shift 2;;
93933 + -d) database="$2"; shift 2;;
93934 + --) shift 1; break ;;
93935 + *) break ;;
93936 + esac
93937 +done
93938 +
93939 +create_defines() {
93940 + for i in `seq 0 31`
93941 + do
93942 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
93943 + done
93944 + echo >> "$header1"
93945 +}
93946 +
93947 +create_structs() {
93948 + rm -f "$header1"
93949 +
93950 + create_defines
93951 +
93952 + cat "$database" | while read data
93953 + do
93954 + data_array=($data)
93955 + struct_hash_name="${data_array[0]}"
93956 + funcn="${data_array[1]}"
93957 + params="${data_array[2]}"
93958 + next="${data_array[4]}"
93959 +
93960 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
93961 +
93962 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
93963 + echo -en "\t.param\t= " >> "$header1"
93964 + line=
93965 + for param_num in ${params//-/ };
93966 + do
93967 + line="${line}PARAM"$param_num"|"
93968 + done
93969 +
93970 + echo -e "${line%?},\n};\n" >> "$header1"
93971 + done
93972 +}
93973 +
93974 +create_headers() {
93975 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
93976 +}
93977 +
93978 +create_array_elements() {
93979 + index=0
93980 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
93981 + do
93982 + data_array=($data)
93983 + i="${data_array[3]}"
93984 + hash="${data_array[0]}"
93985 + while [[ $index -lt $i ]]
93986 + do
93987 + echo -e "\t["$index"]\t= NULL," >> "$header1"
93988 + index=$(($index + 1))
93989 + done
93990 + index=$(($index + 1))
93991 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
93992 + done
93993 + echo '};' >> $header1
93994 +}
93995 +
93996 +create_structs
93997 +create_headers
93998 +create_array_elements
93999 +
94000 +exit 0
94001 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
94002 new file mode 100644
94003 index 0000000..568b360
94004 --- /dev/null
94005 +++ b/tools/gcc/kallocstat_plugin.c
94006 @@ -0,0 +1,170 @@
94007 +/*
94008 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94009 + * Licensed under the GPL v2
94010 + *
94011 + * Note: the choice of the license means that the compilation process is
94012 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94013 + * but for the kernel it doesn't matter since it doesn't link against
94014 + * any of the gcc libraries
94015 + *
94016 + * gcc plugin to find the distribution of k*alloc sizes
94017 + *
94018 + * TODO:
94019 + *
94020 + * BUGS:
94021 + * - none known
94022 + */
94023 +#include "gcc-plugin.h"
94024 +#include "config.h"
94025 +#include "system.h"
94026 +#include "coretypes.h"
94027 +#include "tree.h"
94028 +#include "tree-pass.h"
94029 +#include "flags.h"
94030 +#include "intl.h"
94031 +#include "toplev.h"
94032 +#include "plugin.h"
94033 +//#include "expr.h" where are you...
94034 +#include "diagnostic.h"
94035 +#include "plugin-version.h"
94036 +#include "tm.h"
94037 +#include "function.h"
94038 +#include "basic-block.h"
94039 +#include "gimple.h"
94040 +#include "rtl.h"
94041 +#include "emit-rtl.h"
94042 +
94043 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94044 +
94045 +int plugin_is_GPL_compatible;
94046 +
94047 +static const char * const kalloc_functions[] = {
94048 + "__kmalloc",
94049 + "kmalloc",
94050 + "kmalloc_large",
94051 + "kmalloc_node",
94052 + "kmalloc_order",
94053 + "kmalloc_order_trace",
94054 + "kmalloc_slab",
94055 + "kzalloc",
94056 + "kzalloc_node",
94057 +};
94058 +
94059 +static struct plugin_info kallocstat_plugin_info = {
94060 + .version = "201302112000",
94061 +};
94062 +
94063 +static unsigned int execute_kallocstat(void);
94064 +
94065 +static struct gimple_opt_pass kallocstat_pass = {
94066 + .pass = {
94067 + .type = GIMPLE_PASS,
94068 + .name = "kallocstat",
94069 +#if BUILDING_GCC_VERSION >= 4008
94070 + .optinfo_flags = OPTGROUP_NONE,
94071 +#endif
94072 + .gate = NULL,
94073 + .execute = execute_kallocstat,
94074 + .sub = NULL,
94075 + .next = NULL,
94076 + .static_pass_number = 0,
94077 + .tv_id = TV_NONE,
94078 + .properties_required = 0,
94079 + .properties_provided = 0,
94080 + .properties_destroyed = 0,
94081 + .todo_flags_start = 0,
94082 + .todo_flags_finish = 0
94083 + }
94084 +};
94085 +
94086 +static bool is_kalloc(const char *fnname)
94087 +{
94088 + size_t i;
94089 +
94090 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
94091 + if (!strcmp(fnname, kalloc_functions[i]))
94092 + return true;
94093 + return false;
94094 +}
94095 +
94096 +static unsigned int execute_kallocstat(void)
94097 +{
94098 + basic_block bb;
94099 +
94100 + // 1. loop through BBs and GIMPLE statements
94101 + FOR_EACH_BB(bb) {
94102 + gimple_stmt_iterator gsi;
94103 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94104 + // gimple match:
94105 + tree fndecl, size;
94106 + gimple call_stmt;
94107 + const char *fnname;
94108 +
94109 + // is it a call
94110 + call_stmt = gsi_stmt(gsi);
94111 + if (!is_gimple_call(call_stmt))
94112 + continue;
94113 + fndecl = gimple_call_fndecl(call_stmt);
94114 + if (fndecl == NULL_TREE)
94115 + continue;
94116 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
94117 + continue;
94118 +
94119 + // is it a call to k*alloc
94120 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
94121 + if (!is_kalloc(fnname))
94122 + continue;
94123 +
94124 + // is the size arg the result of a simple const assignment
94125 + size = gimple_call_arg(call_stmt, 0);
94126 + while (true) {
94127 + gimple def_stmt;
94128 + expanded_location xloc;
94129 + size_t size_val;
94130 +
94131 + if (TREE_CODE(size) != SSA_NAME)
94132 + break;
94133 + def_stmt = SSA_NAME_DEF_STMT(size);
94134 + if (!def_stmt || !is_gimple_assign(def_stmt))
94135 + break;
94136 + if (gimple_num_ops(def_stmt) != 2)
94137 + break;
94138 + size = gimple_assign_rhs1(def_stmt);
94139 + if (!TREE_CONSTANT(size))
94140 + continue;
94141 + xloc = expand_location(gimple_location(def_stmt));
94142 + if (!xloc.file)
94143 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
94144 + size_val = TREE_INT_CST_LOW(size);
94145 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
94146 + break;
94147 + }
94148 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94149 +//debug_tree(gimple_call_fn(call_stmt));
94150 +//print_node(stderr, "pax", fndecl, 4);
94151 + }
94152 + }
94153 +
94154 + return 0;
94155 +}
94156 +
94157 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94158 +{
94159 + const char * const plugin_name = plugin_info->base_name;
94160 + struct register_pass_info kallocstat_pass_info = {
94161 + .pass = &kallocstat_pass.pass,
94162 + .reference_pass_name = "ssa",
94163 + .ref_pass_instance_number = 1,
94164 + .pos_op = PASS_POS_INSERT_AFTER
94165 + };
94166 +
94167 + if (!plugin_default_version_check(version, &gcc_version)) {
94168 + error(G_("incompatible gcc/plugin versions"));
94169 + return 1;
94170 + }
94171 +
94172 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
94173 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
94174 +
94175 + return 0;
94176 +}
94177 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
94178 new file mode 100644
94179 index 0000000..0408e06
94180 --- /dev/null
94181 +++ b/tools/gcc/kernexec_plugin.c
94182 @@ -0,0 +1,465 @@
94183 +/*
94184 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94185 + * Licensed under the GPL v2
94186 + *
94187 + * Note: the choice of the license means that the compilation process is
94188 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94189 + * but for the kernel it doesn't matter since it doesn't link against
94190 + * any of the gcc libraries
94191 + *
94192 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
94193 + *
94194 + * TODO:
94195 + *
94196 + * BUGS:
94197 + * - none known
94198 + */
94199 +#include "gcc-plugin.h"
94200 +#include "config.h"
94201 +#include "system.h"
94202 +#include "coretypes.h"
94203 +#include "tree.h"
94204 +#include "tree-pass.h"
94205 +#include "flags.h"
94206 +#include "intl.h"
94207 +#include "toplev.h"
94208 +#include "plugin.h"
94209 +//#include "expr.h" where are you...
94210 +#include "diagnostic.h"
94211 +#include "plugin-version.h"
94212 +#include "tm.h"
94213 +#include "function.h"
94214 +#include "basic-block.h"
94215 +#include "gimple.h"
94216 +#include "rtl.h"
94217 +#include "emit-rtl.h"
94218 +#include "tree-flow.h"
94219 +
94220 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94221 +extern rtx emit_move_insn(rtx x, rtx y);
94222 +
94223 +#if BUILDING_GCC_VERSION <= 4006
94224 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
94225 +#endif
94226 +
94227 +#if BUILDING_GCC_VERSION >= 4008
94228 +#define TODO_dump_func 0
94229 +#endif
94230 +
94231 +int plugin_is_GPL_compatible;
94232 +
94233 +static struct plugin_info kernexec_plugin_info = {
94234 + .version = "201302112000",
94235 + .help = "method=[bts|or]\tinstrumentation method\n"
94236 +};
94237 +
94238 +static unsigned int execute_kernexec_reload(void);
94239 +static unsigned int execute_kernexec_fptr(void);
94240 +static unsigned int execute_kernexec_retaddr(void);
94241 +static bool kernexec_cmodel_check(void);
94242 +
94243 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
94244 +static void (*kernexec_instrument_retaddr)(rtx);
94245 +
94246 +static struct gimple_opt_pass kernexec_reload_pass = {
94247 + .pass = {
94248 + .type = GIMPLE_PASS,
94249 + .name = "kernexec_reload",
94250 +#if BUILDING_GCC_VERSION >= 4008
94251 + .optinfo_flags = OPTGROUP_NONE,
94252 +#endif
94253 + .gate = kernexec_cmodel_check,
94254 + .execute = execute_kernexec_reload,
94255 + .sub = NULL,
94256 + .next = NULL,
94257 + .static_pass_number = 0,
94258 + .tv_id = TV_NONE,
94259 + .properties_required = 0,
94260 + .properties_provided = 0,
94261 + .properties_destroyed = 0,
94262 + .todo_flags_start = 0,
94263 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94264 + }
94265 +};
94266 +
94267 +static struct gimple_opt_pass kernexec_fptr_pass = {
94268 + .pass = {
94269 + .type = GIMPLE_PASS,
94270 + .name = "kernexec_fptr",
94271 +#if BUILDING_GCC_VERSION >= 4008
94272 + .optinfo_flags = OPTGROUP_NONE,
94273 +#endif
94274 + .gate = kernexec_cmodel_check,
94275 + .execute = execute_kernexec_fptr,
94276 + .sub = NULL,
94277 + .next = NULL,
94278 + .static_pass_number = 0,
94279 + .tv_id = TV_NONE,
94280 + .properties_required = 0,
94281 + .properties_provided = 0,
94282 + .properties_destroyed = 0,
94283 + .todo_flags_start = 0,
94284 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94285 + }
94286 +};
94287 +
94288 +static struct rtl_opt_pass kernexec_retaddr_pass = {
94289 + .pass = {
94290 + .type = RTL_PASS,
94291 + .name = "kernexec_retaddr",
94292 +#if BUILDING_GCC_VERSION >= 4008
94293 + .optinfo_flags = OPTGROUP_NONE,
94294 +#endif
94295 + .gate = kernexec_cmodel_check,
94296 + .execute = execute_kernexec_retaddr,
94297 + .sub = NULL,
94298 + .next = NULL,
94299 + .static_pass_number = 0,
94300 + .tv_id = TV_NONE,
94301 + .properties_required = 0,
94302 + .properties_provided = 0,
94303 + .properties_destroyed = 0,
94304 + .todo_flags_start = 0,
94305 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
94306 + }
94307 +};
94308 +
94309 +static bool kernexec_cmodel_check(void)
94310 +{
94311 + tree section;
94312 +
94313 + if (ix86_cmodel != CM_KERNEL)
94314 + return false;
94315 +
94316 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
94317 + if (!section || !TREE_VALUE(section))
94318 + return true;
94319 +
94320 + section = TREE_VALUE(TREE_VALUE(section));
94321 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
94322 + return true;
94323 +
94324 + return false;
94325 +}
94326 +
94327 +/*
94328 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
94329 + */
94330 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
94331 +{
94332 + gimple asm_movabs_stmt;
94333 +
94334 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
94335 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
94336 + gimple_asm_set_volatile(asm_movabs_stmt, true);
94337 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
94338 + update_stmt(asm_movabs_stmt);
94339 +}
94340 +
94341 +/*
94342 + * find all asm() stmts that clobber r10 and add a reload of r10
94343 + */
94344 +static unsigned int execute_kernexec_reload(void)
94345 +{
94346 + basic_block bb;
94347 +
94348 + // 1. loop through BBs and GIMPLE statements
94349 + FOR_EACH_BB(bb) {
94350 + gimple_stmt_iterator gsi;
94351 +
94352 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94353 + // gimple match: __asm__ ("" : : : "r10");
94354 + gimple asm_stmt;
94355 + size_t nclobbers;
94356 +
94357 + // is it an asm ...
94358 + asm_stmt = gsi_stmt(gsi);
94359 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
94360 + continue;
94361 +
94362 + // ... clobbering r10
94363 + nclobbers = gimple_asm_nclobbers(asm_stmt);
94364 + while (nclobbers--) {
94365 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
94366 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
94367 + continue;
94368 + kernexec_reload_fptr_mask(&gsi);
94369 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
94370 + break;
94371 + }
94372 + }
94373 + }
94374 +
94375 + return 0;
94376 +}
94377 +
94378 +/*
94379 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
94380 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
94381 + */
94382 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
94383 +{
94384 + gimple assign_intptr, assign_new_fptr, call_stmt;
94385 + tree intptr, old_fptr, new_fptr, kernexec_mask;
94386 +
94387 + call_stmt = gsi_stmt(*gsi);
94388 + old_fptr = gimple_call_fn(call_stmt);
94389 +
94390 + // create temporary unsigned long variable used for bitops and cast fptr to it
94391 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
94392 +#if BUILDING_GCC_VERSION <= 4007
94393 + add_referenced_var(intptr);
94394 + mark_sym_for_renaming(intptr);
94395 +#endif
94396 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
94397 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94398 + update_stmt(assign_intptr);
94399 +
94400 + // apply logical or to temporary unsigned long and bitmask
94401 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
94402 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
94403 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
94404 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94405 + update_stmt(assign_intptr);
94406 +
94407 + // cast temporary unsigned long back to a temporary fptr variable
94408 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
94409 +#if BUILDING_GCC_VERSION <= 4007
94410 + add_referenced_var(new_fptr);
94411 + mark_sym_for_renaming(new_fptr);
94412 +#endif
94413 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
94414 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
94415 + update_stmt(assign_new_fptr);
94416 +
94417 + // replace call stmt fn with the new fptr
94418 + gimple_call_set_fn(call_stmt, new_fptr);
94419 + update_stmt(call_stmt);
94420 +}
94421 +
94422 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
94423 +{
94424 + gimple asm_or_stmt, call_stmt;
94425 + tree old_fptr, new_fptr, input, output;
94426 +#if BUILDING_GCC_VERSION <= 4007
94427 + VEC(tree, gc) *inputs = NULL;
94428 + VEC(tree, gc) *outputs = NULL;
94429 +#else
94430 + vec<tree, va_gc> *inputs = NULL;
94431 + vec<tree, va_gc> *outputs = NULL;
94432 +#endif
94433 +
94434 + call_stmt = gsi_stmt(*gsi);
94435 + old_fptr = gimple_call_fn(call_stmt);
94436 +
94437 + // create temporary fptr variable
94438 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
94439 +#if BUILDING_GCC_VERSION <= 4007
94440 + add_referenced_var(new_fptr);
94441 + mark_sym_for_renaming(new_fptr);
94442 +#endif
94443 +
94444 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
94445 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
94446 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
94447 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
94448 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
94449 +#if BUILDING_GCC_VERSION <= 4007
94450 + VEC_safe_push(tree, gc, inputs, input);
94451 + VEC_safe_push(tree, gc, outputs, output);
94452 +#else
94453 + vec_safe_push(inputs, input);
94454 + vec_safe_push(outputs, output);
94455 +#endif
94456 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
94457 + gimple_asm_set_volatile(asm_or_stmt, true);
94458 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
94459 + update_stmt(asm_or_stmt);
94460 +
94461 + // replace call stmt fn with the new fptr
94462 + gimple_call_set_fn(call_stmt, new_fptr);
94463 + update_stmt(call_stmt);
94464 +}
94465 +
94466 +/*
94467 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
94468 + */
94469 +static unsigned int execute_kernexec_fptr(void)
94470 +{
94471 + basic_block bb;
94472 +
94473 + // 1. loop through BBs and GIMPLE statements
94474 + FOR_EACH_BB(bb) {
94475 + gimple_stmt_iterator gsi;
94476 +
94477 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94478 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
94479 + tree fn;
94480 + gimple call_stmt;
94481 +
94482 + // is it a call ...
94483 + call_stmt = gsi_stmt(gsi);
94484 + if (!is_gimple_call(call_stmt))
94485 + continue;
94486 + fn = gimple_call_fn(call_stmt);
94487 + if (TREE_CODE(fn) == ADDR_EXPR)
94488 + continue;
94489 + if (TREE_CODE(fn) != SSA_NAME)
94490 + gcc_unreachable();
94491 +
94492 + // ... through a function pointer
94493 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
94494 + fn = SSA_NAME_VAR(fn);
94495 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
94496 + debug_tree(fn);
94497 + gcc_unreachable();
94498 + }
94499 + }
94500 + fn = TREE_TYPE(fn);
94501 + if (TREE_CODE(fn) != POINTER_TYPE)
94502 + continue;
94503 + fn = TREE_TYPE(fn);
94504 + if (TREE_CODE(fn) != FUNCTION_TYPE)
94505 + continue;
94506 +
94507 + kernexec_instrument_fptr(&gsi);
94508 +
94509 +//debug_tree(gimple_call_fn(call_stmt));
94510 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94511 + }
94512 + }
94513 +
94514 + return 0;
94515 +}
94516 +
94517 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
94518 +static void kernexec_instrument_retaddr_bts(rtx insn)
94519 +{
94520 + rtx btsq;
94521 + rtvec argvec, constraintvec, labelvec;
94522 + int line;
94523 +
94524 + // create asm volatile("btsq $63,(%%rsp)":::)
94525 + argvec = rtvec_alloc(0);
94526 + constraintvec = rtvec_alloc(0);
94527 + labelvec = rtvec_alloc(0);
94528 + line = expand_location(RTL_LOCATION(insn)).line;
94529 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94530 + MEM_VOLATILE_P(btsq) = 1;
94531 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
94532 + emit_insn_before(btsq, insn);
94533 +}
94534 +
94535 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
94536 +static void kernexec_instrument_retaddr_or(rtx insn)
94537 +{
94538 + rtx orq;
94539 + rtvec argvec, constraintvec, labelvec;
94540 + int line;
94541 +
94542 + // create asm volatile("orq %%r10,(%%rsp)":::)
94543 + argvec = rtvec_alloc(0);
94544 + constraintvec = rtvec_alloc(0);
94545 + labelvec = rtvec_alloc(0);
94546 + line = expand_location(RTL_LOCATION(insn)).line;
94547 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94548 + MEM_VOLATILE_P(orq) = 1;
94549 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
94550 + emit_insn_before(orq, insn);
94551 +}
94552 +
94553 +/*
94554 + * find all asm level function returns and forcibly set the highest bit of the return address
94555 + */
94556 +static unsigned int execute_kernexec_retaddr(void)
94557 +{
94558 + rtx insn;
94559 +
94560 + // 1. find function returns
94561 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
94562 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
94563 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
94564 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
94565 + rtx body;
94566 +
94567 + // is it a retn
94568 + if (!JUMP_P(insn))
94569 + continue;
94570 + body = PATTERN(insn);
94571 + if (GET_CODE(body) == PARALLEL)
94572 + body = XVECEXP(body, 0, 0);
94573 + if (!ANY_RETURN_P(body))
94574 + continue;
94575 + kernexec_instrument_retaddr(insn);
94576 + }
94577 +
94578 +// print_simple_rtl(stderr, get_insns());
94579 +// print_rtl(stderr, get_insns());
94580 +
94581 + return 0;
94582 +}
94583 +
94584 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94585 +{
94586 + const char * const plugin_name = plugin_info->base_name;
94587 + const int argc = plugin_info->argc;
94588 + const struct plugin_argument * const argv = plugin_info->argv;
94589 + int i;
94590 + struct register_pass_info kernexec_reload_pass_info = {
94591 + .pass = &kernexec_reload_pass.pass,
94592 + .reference_pass_name = "ssa",
94593 + .ref_pass_instance_number = 1,
94594 + .pos_op = PASS_POS_INSERT_AFTER
94595 + };
94596 + struct register_pass_info kernexec_fptr_pass_info = {
94597 + .pass = &kernexec_fptr_pass.pass,
94598 + .reference_pass_name = "ssa",
94599 + .ref_pass_instance_number = 1,
94600 + .pos_op = PASS_POS_INSERT_AFTER
94601 + };
94602 + struct register_pass_info kernexec_retaddr_pass_info = {
94603 + .pass = &kernexec_retaddr_pass.pass,
94604 + .reference_pass_name = "pro_and_epilogue",
94605 + .ref_pass_instance_number = 1,
94606 + .pos_op = PASS_POS_INSERT_AFTER
94607 + };
94608 +
94609 + if (!plugin_default_version_check(version, &gcc_version)) {
94610 + error(G_("incompatible gcc/plugin versions"));
94611 + return 1;
94612 + }
94613 +
94614 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
94615 +
94616 + if (TARGET_64BIT == 0)
94617 + return 0;
94618 +
94619 + for (i = 0; i < argc; ++i) {
94620 + if (!strcmp(argv[i].key, "method")) {
94621 + if (!argv[i].value) {
94622 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94623 + continue;
94624 + }
94625 + if (!strcmp(argv[i].value, "bts")) {
94626 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
94627 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
94628 + } else if (!strcmp(argv[i].value, "or")) {
94629 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
94630 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
94631 + fix_register("r10", 1, 1);
94632 + } else
94633 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
94634 + continue;
94635 + }
94636 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94637 + }
94638 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
94639 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
94640 +
94641 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
94642 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
94643 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
94644 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
94645 +
94646 + return 0;
94647 +}
94648 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
94649 new file mode 100644
94650 index 0000000..b5395ba
94651 --- /dev/null
94652 +++ b/tools/gcc/latent_entropy_plugin.c
94653 @@ -0,0 +1,327 @@
94654 +/*
94655 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
94656 + * Licensed under the GPL v2
94657 + *
94658 + * Note: the choice of the license means that the compilation process is
94659 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94660 + * but for the kernel it doesn't matter since it doesn't link against
94661 + * any of the gcc libraries
94662 + *
94663 + * gcc plugin to help generate a little bit of entropy from program state,
94664 + * used during boot in the kernel
94665 + *
94666 + * TODO:
94667 + * - add ipa pass to identify not explicitly marked candidate functions
94668 + * - mix in more program state (function arguments/return values, loop variables, etc)
94669 + * - more instrumentation control via attribute parameters
94670 + *
94671 + * BUGS:
94672 + * - LTO needs -flto-partition=none for now
94673 + */
94674 +#include "gcc-plugin.h"
94675 +#include "config.h"
94676 +#include "system.h"
94677 +#include "coretypes.h"
94678 +#include "tree.h"
94679 +#include "tree-pass.h"
94680 +#include "flags.h"
94681 +#include "intl.h"
94682 +#include "toplev.h"
94683 +#include "plugin.h"
94684 +//#include "expr.h" where are you...
94685 +#include "diagnostic.h"
94686 +#include "plugin-version.h"
94687 +#include "tm.h"
94688 +#include "function.h"
94689 +#include "basic-block.h"
94690 +#include "gimple.h"
94691 +#include "rtl.h"
94692 +#include "emit-rtl.h"
94693 +#include "tree-flow.h"
94694 +#include "langhooks.h"
94695 +
94696 +#if BUILDING_GCC_VERSION >= 4008
94697 +#define TODO_dump_func 0
94698 +#endif
94699 +
94700 +int plugin_is_GPL_compatible;
94701 +
94702 +static tree latent_entropy_decl;
94703 +
94704 +static struct plugin_info latent_entropy_plugin_info = {
94705 + .version = "201303102320",
94706 + .help = NULL
94707 +};
94708 +
94709 +static unsigned int execute_latent_entropy(void);
94710 +static bool gate_latent_entropy(void);
94711 +
94712 +static struct gimple_opt_pass latent_entropy_pass = {
94713 + .pass = {
94714 + .type = GIMPLE_PASS,
94715 + .name = "latent_entropy",
94716 +#if BUILDING_GCC_VERSION >= 4008
94717 + .optinfo_flags = OPTGROUP_NONE,
94718 +#endif
94719 + .gate = gate_latent_entropy,
94720 + .execute = execute_latent_entropy,
94721 + .sub = NULL,
94722 + .next = NULL,
94723 + .static_pass_number = 0,
94724 + .tv_id = TV_NONE,
94725 + .properties_required = PROP_gimple_leh | PROP_cfg,
94726 + .properties_provided = 0,
94727 + .properties_destroyed = 0,
94728 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
94729 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
94730 + }
94731 +};
94732 +
94733 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94734 +{
94735 + if (TREE_CODE(*node) != FUNCTION_DECL) {
94736 + *no_add_attrs = true;
94737 + error("%qE attribute only applies to functions", name);
94738 + }
94739 + return NULL_TREE;
94740 +}
94741 +
94742 +static struct attribute_spec latent_entropy_attr = {
94743 + .name = "latent_entropy",
94744 + .min_length = 0,
94745 + .max_length = 0,
94746 + .decl_required = true,
94747 + .type_required = false,
94748 + .function_type_required = false,
94749 + .handler = handle_latent_entropy_attribute,
94750 +#if BUILDING_GCC_VERSION >= 4007
94751 + .affects_type_identity = false
94752 +#endif
94753 +};
94754 +
94755 +static void register_attributes(void *event_data, void *data)
94756 +{
94757 + register_attribute(&latent_entropy_attr);
94758 +}
94759 +
94760 +static bool gate_latent_entropy(void)
94761 +{
94762 + tree latent_entropy_attr;
94763 +
94764 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
94765 + return latent_entropy_attr != NULL_TREE;
94766 +}
94767 +
94768 +static unsigned HOST_WIDE_INT seed;
94769 +static unsigned HOST_WIDE_INT get_random_const(void)
94770 +{
94771 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
94772 + return seed;
94773 +}
94774 +
94775 +static enum tree_code get_op(tree *rhs)
94776 +{
94777 + static enum tree_code op;
94778 + unsigned HOST_WIDE_INT random_const;
94779 +
94780 + random_const = get_random_const();
94781 +
94782 + switch (op) {
94783 + case BIT_XOR_EXPR:
94784 + op = PLUS_EXPR;
94785 + break;
94786 +
94787 + case PLUS_EXPR:
94788 + if (rhs) {
94789 + op = LROTATE_EXPR;
94790 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
94791 + break;
94792 + }
94793 +
94794 + case LROTATE_EXPR:
94795 + default:
94796 + op = BIT_XOR_EXPR;
94797 + break;
94798 + }
94799 + if (rhs)
94800 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
94801 + return op;
94802 +}
94803 +
94804 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
94805 +{
94806 + gimple_stmt_iterator gsi;
94807 + gimple assign;
94808 + tree addxorrol, rhs;
94809 + enum tree_code op;
94810 +
94811 + op = get_op(&rhs);
94812 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
94813 + assign = gimple_build_assign(local_entropy, addxorrol);
94814 +#if BUILDING_GCC_VERSION <= 4007
94815 + find_referenced_vars_in(assign);
94816 +#endif
94817 +//debug_bb(bb);
94818 + gsi = gsi_after_labels(bb);
94819 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
94820 + update_stmt(assign);
94821 +}
94822 +
94823 +static void perturb_latent_entropy(basic_block bb, tree rhs)
94824 +{
94825 + gimple_stmt_iterator gsi;
94826 + gimple assign;
94827 + tree addxorrol, temp;
94828 +
94829 + // 1. create temporary copy of latent_entropy
94830 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
94831 +#if BUILDING_GCC_VERSION <= 4007
94832 + add_referenced_var(temp);
94833 + mark_sym_for_renaming(temp);
94834 +#endif
94835 +
94836 + // 2. read...
94837 + assign = gimple_build_assign(temp, latent_entropy_decl);
94838 +#if BUILDING_GCC_VERSION <= 4007
94839 + find_referenced_vars_in(assign);
94840 +#endif
94841 + gsi = gsi_after_labels(bb);
94842 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94843 + update_stmt(assign);
94844 +
94845 + // 3. ...modify...
94846 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
94847 + assign = gimple_build_assign(temp, addxorrol);
94848 +#if BUILDING_GCC_VERSION <= 4007
94849 + find_referenced_vars_in(assign);
94850 +#endif
94851 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94852 + update_stmt(assign);
94853 +
94854 + // 4. ...write latent_entropy
94855 + assign = gimple_build_assign(latent_entropy_decl, temp);
94856 +#if BUILDING_GCC_VERSION <= 4007
94857 + find_referenced_vars_in(assign);
94858 +#endif
94859 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94860 + update_stmt(assign);
94861 +}
94862 +
94863 +static unsigned int execute_latent_entropy(void)
94864 +{
94865 + basic_block bb;
94866 + gimple assign;
94867 + gimple_stmt_iterator gsi;
94868 + tree local_entropy;
94869 +
94870 + if (!latent_entropy_decl) {
94871 + struct varpool_node *node;
94872 +
94873 +#if BUILDING_GCC_VERSION <= 4007
94874 + for (node = varpool_nodes; node; node = node->next) {
94875 + tree var = node->decl;
94876 +#else
94877 + FOR_EACH_VARIABLE(node) {
94878 + tree var = node->symbol.decl;
94879 +#endif
94880 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
94881 + continue;
94882 + latent_entropy_decl = var;
94883 +// debug_tree(var);
94884 + break;
94885 + }
94886 + if (!latent_entropy_decl) {
94887 +// debug_tree(current_function_decl);
94888 + return 0;
94889 + }
94890 + }
94891 +
94892 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
94893 +
94894 + // 1. create local entropy variable
94895 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
94896 +#if BUILDING_GCC_VERSION <= 4007
94897 + add_referenced_var(local_entropy);
94898 + mark_sym_for_renaming(local_entropy);
94899 +#endif
94900 +
94901 + // 2. initialize local entropy variable
94902 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
94903 + if (dom_info_available_p(CDI_DOMINATORS))
94904 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
94905 + gsi = gsi_start_bb(bb);
94906 +
94907 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
94908 +// gimple_set_location(assign, loc);
94909 +#if BUILDING_GCC_VERSION <= 4007
94910 + find_referenced_vars_in(assign);
94911 +#endif
94912 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94913 + update_stmt(assign);
94914 + bb = bb->next_bb;
94915 +
94916 + // 3. instrument each BB with an operation on the local entropy variable
94917 + while (bb != EXIT_BLOCK_PTR) {
94918 + perturb_local_entropy(bb, local_entropy);
94919 + bb = bb->next_bb;
94920 + };
94921 +
94922 + // 4. mix local entropy into the global entropy variable
94923 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
94924 + return 0;
94925 +}
94926 +
94927 +static void start_unit_callback(void *gcc_data, void *user_data)
94928 +{
94929 + tree latent_entropy_type;
94930 +
94931 +#if BUILDING_GCC_VERSION >= 4007
94932 + seed = get_random_seed(false);
94933 +#else
94934 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
94935 + seed *= seed;
94936 +#endif
94937 +
94938 + if (in_lto_p)
94939 + return;
94940 +
94941 + // extern volatile u64 latent_entropy
94942 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
94943 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
94944 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
94945 +
94946 + TREE_STATIC(latent_entropy_decl) = 1;
94947 + TREE_PUBLIC(latent_entropy_decl) = 1;
94948 + TREE_USED(latent_entropy_decl) = 1;
94949 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
94950 + DECL_EXTERNAL(latent_entropy_decl) = 1;
94951 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
94952 + DECL_INITIAL(latent_entropy_decl) = NULL;
94953 + lang_hooks.decls.pushdecl(latent_entropy_decl);
94954 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
94955 +// varpool_finalize_decl(latent_entropy_decl);
94956 +// varpool_mark_needed_node(latent_entropy_decl);
94957 +}
94958 +
94959 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94960 +{
94961 + const char * const plugin_name = plugin_info->base_name;
94962 + struct register_pass_info latent_entropy_pass_info = {
94963 + .pass = &latent_entropy_pass.pass,
94964 + .reference_pass_name = "optimized",
94965 + .ref_pass_instance_number = 1,
94966 + .pos_op = PASS_POS_INSERT_BEFORE
94967 + };
94968 +
94969 + if (!plugin_default_version_check(version, &gcc_version)) {
94970 + error(G_("incompatible gcc/plugin versions"));
94971 + return 1;
94972 + }
94973 +
94974 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
94975 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
94976 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
94977 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94978 +
94979 + return 0;
94980 +}
94981 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
94982 new file mode 100644
94983 index 0000000..7982a0c
94984 --- /dev/null
94985 +++ b/tools/gcc/size_overflow_hash.data
94986 @@ -0,0 +1,5893 @@
94987 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
94988 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
94989 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
94990 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
94991 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
94992 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
94993 +padzero_55 padzero 1 55 &sel_read_policyvers_55
94994 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
94995 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
94996 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
94997 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
94998 +load_msg_95 load_msg 2 95 NULL
94999 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
95000 +init_q_132 init_q 4 132 NULL
95001 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
95002 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
95003 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
95004 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
95005 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
95006 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
95007 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
95008 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
95009 +br_port_info_size_268 br_port_info_size 0 268 NULL
95010 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
95011 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
95012 +syslog_print_307 syslog_print 2 307 NULL
95013 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
95014 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
95015 +next_node_allowed_318 next_node_allowed 1 318 NULL
95016 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
95017 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
95018 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
95019 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
95020 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
95021 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
95022 +pidlist_resize_496 pidlist_resize 2 496 NULL
95023 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
95024 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
95025 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
95026 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
95027 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
95028 +dle_count_543 dle_count 0 543 NULL
95029 +devres_alloc_551 devres_alloc 2 551 NULL
95030 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
95031 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
95032 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
95033 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
95034 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
95035 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
95036 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
95037 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
95038 +isp1760_register_628 isp1760_register 1-2 628 NULL
95039 +clone_split_bio_633 clone_split_bio 6 633 NULL
95040 +remap_to_cache_640 remap_to_cache 3 640 NULL
95041 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
95042 +unlink_queued_645 unlink_queued 3-4 645 NULL
95043 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
95044 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
95045 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
95046 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
95047 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
95048 +disk_max_parts_719 disk_max_parts 0 719 NULL
95049 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
95050 +dvb_video_write_754 dvb_video_write 3 754 NULL
95051 +if_writecmd_815 if_writecmd 2 815 NULL
95052 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
95053 +read_fifo_826 read_fifo 3 826 NULL
95054 +um_idi_read_850 um_idi_read 3 850 NULL
95055 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
95056 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
95057 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
95058 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
95059 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
95060 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
95061 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
95062 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
95063 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
95064 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
95065 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
95066 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
95067 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
95068 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
95069 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
95070 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
95071 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
95072 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
95073 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
95074 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
95075 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
95076 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
95077 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
95078 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
95079 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
95080 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
95081 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
95082 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
95083 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
95084 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
95085 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
95086 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
95087 +nested_get_page_1252 nested_get_page 2 1252 NULL
95088 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
95089 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
95090 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
95091 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
95092 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
95093 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
95094 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
95095 +ffs_1322 ffs 0 1322 NULL
95096 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
95097 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
95098 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
95099 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
95100 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
95101 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
95102 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
95103 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
95104 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
95105 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
95106 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
95107 +zone_page_state_1393 zone_page_state 0 1393 NULL
95108 +file_read_actor_1401 file_read_actor 4 1401 NULL
95109 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
95110 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
95111 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
95112 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
95113 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
95114 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
95115 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
95116 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
95117 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
95118 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
95119 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
95120 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
95121 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
95122 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
95123 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
95124 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
95125 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
95126 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
95127 +rmap_add_1677 rmap_add 3 1677 NULL
95128 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
95129 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
95130 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
95131 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
95132 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
95133 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
95134 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
95135 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
95136 +cosa_write_1774 cosa_write 3 1774 NULL
95137 +update_macheader_1775 update_macheader 7 1775 NULL
95138 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
95139 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
95140 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
95141 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
95142 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
95143 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
95144 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
95145 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
95146 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
95147 +read_swap_header_1957 read_swap_header 0 1957 NULL
95148 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
95149 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
95150 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
95151 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
95152 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
95153 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
95154 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
95155 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
95156 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
95157 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
95158 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
95159 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
95160 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
95161 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
95162 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
95163 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
95164 +audit_expand_2098 audit_expand 2 2098 NULL
95165 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
95166 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
95167 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
95168 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
95169 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
95170 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
95171 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
95172 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
95173 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
95174 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
95175 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
95176 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
95177 +u32_array_read_2219 u32_array_read 3 2219 NULL
95178 +vhci_write_2224 vhci_write 3 2224 NULL
95179 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
95180 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
95181 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
95182 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
95183 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
95184 +do_update_counters_2259 do_update_counters 4 2259 NULL
95185 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
95186 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
95187 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
95188 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
95189 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
95190 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
95191 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
95192 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
95193 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
95194 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
95195 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
95196 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
95197 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
95198 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
95199 +raid1_size_2419 raid1_size 0-2 2419 NULL
95200 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
95201 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
95202 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
95203 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
95204 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
95205 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
95206 +update_pmkid_2481 update_pmkid 4 2481 NULL
95207 +wiphy_new_2482 wiphy_new 2 2482 NULL
95208 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
95209 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
95210 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
95211 +dm_write_2513 dm_write 3 2513 NULL
95212 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
95213 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
95214 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
95215 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
95216 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
95217 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
95218 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
95219 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
95220 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
95221 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
95222 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
95223 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
95224 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
95225 +__next_cpu_2782 __next_cpu 1 2782 NULL
95226 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
95227 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
95228 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
95229 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
95230 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
95231 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
95232 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
95233 +mq_map_2871 mq_map 2 2871 NULL
95234 +nla_padlen_2883 nla_padlen 1 2883 NULL
95235 +cmm_write_2896 cmm_write 3 2896 NULL
95236 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
95237 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
95238 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
95239 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
95240 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
95241 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
95242 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
95243 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
95244 +depth_write_3021 depth_write 3 3021 NULL
95245 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
95246 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
95247 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
95248 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
95249 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
95250 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
95251 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
95252 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
95253 +free_coherent_3082 free_coherent 4-2 3082 NULL
95254 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
95255 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
95256 +rb_alloc_3102 rb_alloc 1 3102 NULL
95257 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
95258 +print_time_3132 print_time 0 3132 NULL
95259 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
95260 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
95261 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
95262 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
95263 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
95264 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
95265 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
95266 +alloc_context_3194 alloc_context 1 3194 NULL
95267 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
95268 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
95269 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
95270 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
95271 +key_key_read_3241 key_key_read 3 3241 NULL
95272 +number_3243 number 0 3243 NULL
95273 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
95274 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
95275 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
95276 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
95277 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
95278 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
95279 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
95280 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
95281 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
95282 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
95283 +scnprintf_3360 scnprintf 0-2 3360 NULL
95284 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
95285 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
95286 +send_stream_3397 send_stream 4 3397 NULL
95287 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
95288 +msix_map_region_3411 msix_map_region 3 3411 NULL
95289 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
95290 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
95291 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
95292 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
95293 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
95294 +map_single_3449 map_single 0-2 3449 NULL
95295 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
95296 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
95297 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
95298 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
95299 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
95300 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
95301 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
95302 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
95303 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
95304 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
95305 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
95306 +evtchn_read_3569 evtchn_read 3 3569 NULL
95307 +vc_resize_3585 vc_resize 2-3 3585 NULL
95308 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
95309 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
95310 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
95311 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
95312 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
95313 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 NULL
95314 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
95315 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
95316 +create_irq_3703 create_irq 0 3703 NULL nohasharray
95317 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
95318 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
95319 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
95320 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
95321 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
95322 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
95323 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
95324 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
95325 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
95326 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
95327 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
95328 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
95329 +get_fd_set_3866 get_fd_set 1 3866 NULL
95330 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
95331 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
95332 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
95333 +nvram_write_3894 nvram_write 3 3894 NULL
95334 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
95335 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
95336 +vcs_write_3910 vcs_write 3 3910 NULL
95337 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
95338 +do_add_counters_3992 do_add_counters 3 3992 NULL
95339 +userspace_status_4004 userspace_status 4 4004 NULL
95340 +mei_write_4005 mei_write 3 4005 NULL nohasharray
95341 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
95342 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
95343 +mm_populate_4016 mm_populate 1 4016 NULL
95344 +blk_end_request_4024 blk_end_request 3 4024 NULL
95345 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
95346 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
95347 +read_file_queues_4078 read_file_queues 3 4078 NULL
95348 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
95349 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
95350 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
95351 +tm6000_read_4151 tm6000_read 3 4151 NULL
95352 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
95353 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
95354 +get_alua_req_4166 get_alua_req 3 4166 NULL
95355 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
95356 +read_file_bool_4180 read_file_bool 3 4180 NULL
95357 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
95358 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
95359 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
95360 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
95361 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
95362 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
95363 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
95364 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
95365 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
95366 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
95367 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
95368 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
95369 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
95370 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
95371 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
95372 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
95373 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
95374 +memparse_4444 memparse 0 4444 NULL
95375 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
95376 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
95377 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
95378 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
95379 +set_link_security_4502 set_link_security 4 4502 NULL
95380 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
95381 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
95382 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
95383 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
95384 +tty_register_device_4544 tty_register_device 2 4544 NULL
95385 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
95386 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
95387 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
95388 +bch_alloc_4593 bch_alloc 1 4593 NULL
95389 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
95390 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
95391 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
95392 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
95393 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
95394 +kone_receive_4690 kone_receive 4 4690 NULL
95395 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
95396 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
95397 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
95398 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
95399 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
95400 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
95401 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
95402 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
95403 +create_subvol_4791 create_subvol 4 4791 NULL
95404 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
95405 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
95406 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
95407 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
95408 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
95409 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
95410 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
95411 +sys_ipc_4889 sys_ipc 3 4889 NULL
95412 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
95413 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
95414 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
95415 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
95416 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
95417 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
95418 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
95419 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
95420 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
95421 +do_mincore_5018 do_mincore 0-1 5018 NULL
95422 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
95423 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
95424 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
95425 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
95426 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
95427 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
95428 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
95429 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
95430 +sound_write_5102 sound_write 3 5102 NULL
95431 +clear_dirty_5105 clear_dirty 3 5105 NULL
95432 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
95433 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
95434 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
95435 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
95436 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
95437 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
95438 +skb_network_header_5203 skb_network_header 0 5203 NULL
95439 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
95440 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
95441 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
95442 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
95443 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
95444 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
95445 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
95446 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
95447 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
95448 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
95449 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
95450 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
95451 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
95452 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
95453 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
95454 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
95455 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
95456 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
95457 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
95458 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
95459 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
95460 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
95461 +tty_write_5494 tty_write 3 5494 NULL
95462 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
95463 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
95464 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
95465 +spidev_message_5518 spidev_message 3 5518 NULL
95466 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
95467 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
95468 +le_readq_5557 le_readq 0 5557 NULL
95469 +inw_5558 inw 0 5558 NULL
95470 +fir16_create_5574 fir16_create 3 5574 NULL
95471 +bioset_create_5580 bioset_create 1 5580 NULL
95472 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
95473 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
95474 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
95475 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
95476 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
95477 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
95478 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
95479 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
95480 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
95481 +get_arg_5694 get_arg 3 5694 NULL
95482 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
95483 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
95484 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
95485 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
95486 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
95487 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
95488 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
95489 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
95490 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
95491 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
95492 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
95493 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
95494 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
95495 +setup_req_5848 setup_req 3 5848 NULL
95496 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
95497 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
95498 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
95499 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
95500 +port_show_regs_5904 port_show_regs 3 5904 NULL
95501 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
95502 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
95503 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
95504 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
95505 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
95506 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
95507 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
95508 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
95509 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
95510 +native_pte_val_5978 native_pte_val 0 5978 NULL
95511 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
95512 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
95513 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
95514 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
95515 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
95516 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
95517 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
95518 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
95519 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
95520 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
95521 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
95522 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
95523 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
95524 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
95525 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
95526 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
95527 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
95528 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
95529 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
95530 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
95531 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
95532 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
95533 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
95534 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
95535 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
95536 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
95537 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
95538 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
95539 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
95540 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
95541 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
95542 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
95543 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
95544 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
95545 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
95546 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
95547 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
95548 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
95549 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
95550 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
95551 +mei_read_6507 mei_read 3 6507 NULL
95552 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
95553 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
95554 +wdm_read_6549 wdm_read 3 6549 NULL
95555 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
95556 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
95557 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
95558 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
95559 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
95560 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
95561 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
95562 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
95563 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
95564 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
95565 +mpeg_read_6708 mpeg_read 3 6708 NULL
95566 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
95567 +video_proc_write_6724 video_proc_write 3 6724 NULL
95568 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
95569 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
95570 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
95571 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
95572 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
95573 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
95574 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
95575 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
95576 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
95577 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
95578 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
95579 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
95580 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
95581 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
95582 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
95583 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
95584 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
95585 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
95586 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
95587 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
95588 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
95589 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
95590 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
95591 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
95592 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
95593 +request_key_async_6990 request_key_async 4 6990 NULL
95594 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
95595 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
95596 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
95597 +wimax_msg_7030 wimax_msg 4 7030 NULL
95598 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
95599 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
95600 +event_enable_read_7074 event_enable_read 3 7074 NULL
95601 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
95602 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
95603 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
95604 +check_header_7108 check_header 0 7108 NULL
95605 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
95606 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
95607 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
95608 +get_param_h_7247 get_param_h 0 7247 NULL
95609 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
95610 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
95611 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
95612 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
95613 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
95614 +mgmt_control_7349 mgmt_control 3 7349 NULL
95615 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
95616 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
95617 +hweight_long_7388 hweight_long 0-1 7388 NULL
95618 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
95619 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
95620 +readb_7401 readb 0 7401 NULL
95621 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
95622 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
95623 +numa_emulation_7466 numa_emulation 2 7466 NULL
95624 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
95625 +garp_request_join_7471 garp_request_join 4 7471 NULL
95626 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
95627 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
95628 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
95629 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
95630 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
95631 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
95632 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
95633 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
95634 +groups_alloc_7614 groups_alloc 1 7614 NULL
95635 +sg_virt_7616 sg_virt 0 7616 NULL
95636 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
95637 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
95638 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
95639 +dev_write_7708 dev_write 3 7708 NULL
95640 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
95641 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
95642 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
95643 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
95644 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
95645 +ioread32be_7773 ioread32be 0 7773 NULL
95646 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
95647 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
95648 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
95649 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
95650 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
95651 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
95652 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
95653 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
95654 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
95655 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
95656 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
95657 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
95658 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
95659 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
95660 +sys_mbind_7990 sys_mbind 5 7990 NULL
95661 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
95662 +vcs_read_8017 vcs_read 3 8017 NULL
95663 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
95664 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
95665 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
95666 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
95667 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
95668 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
95669 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
95670 +venus_lookup_8121 venus_lookup 4 8121 NULL
95671 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
95672 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
95673 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
95674 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
95675 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
95676 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
95677 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
95678 +play_iframe_8219 play_iframe 3 8219 NULL
95679 +create_log_8225 create_log 2 8225 NULL nohasharray
95680 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
95681 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
95682 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
95683 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
95684 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
95685 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
95686 +init_cdev_8274 init_cdev 1 8274 NULL
95687 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
95688 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
95689 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
95690 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
95691 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
95692 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
95693 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
95694 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
95695 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
95696 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
95697 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
95698 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
95699 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
95700 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
95701 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
95702 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
95703 +dev_config_8506 dev_config 3 8506 NULL
95704 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
95705 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
95706 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
95707 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
95708 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
95709 +profile_remove_8556 profile_remove 3 8556 NULL
95710 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
95711 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
95712 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
95713 +tower_write_8580 tower_write 3 8580 NULL
95714 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
95715 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
95716 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
95717 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
95718 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
95719 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
95720 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
95721 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
95722 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
95723 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
95724 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
95725 +arcfb_write_8702 arcfb_write 3 8702 NULL
95726 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
95727 +init_header_8703 init_header 0 8703 &i_size_read_8703
95728 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
95729 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
95730 +f_dupfd_8730 f_dupfd 1 8730 NULL
95731 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
95732 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
95733 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
95734 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
95735 +sys_prctl_8766 sys_prctl 4 8766 NULL
95736 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
95737 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
95738 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
95739 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
95740 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
95741 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
95742 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
95743 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
95744 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
95745 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
95746 +clear_bitset_8840 clear_bitset 2 8840 NULL
95747 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
95748 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
95749 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
95750 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
95751 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
95752 +layout_commit_8926 layout_commit 3 8926 NULL
95753 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
95754 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
95755 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
95756 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
95757 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
95758 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
95759 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
95760 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
95761 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
95762 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
95763 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
95764 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
95765 +nla_put_9042 nla_put 3 9042 NULL
95766 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
95767 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
95768 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
95769 +string_9080 string 0 9080 NULL
95770 +create_queues_9088 create_queues 2-3 9088 NULL
95771 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
95772 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
95773 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
95774 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
95775 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
95776 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
95777 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
95778 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
95779 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
95780 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
95781 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
95782 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
95783 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
95784 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
95785 +get_pfn_9207 get_pfn 1 9207 NULL
95786 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
95787 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
95788 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
95789 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
95790 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
95791 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
95792 +flakey_status_9274 flakey_status 5 9274 NULL
95793 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
95794 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
95795 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
95796 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
95797 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
95798 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
95799 +read_9397 read 3 9397 NULL
95800 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
95801 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
95802 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
95803 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
95804 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
95805 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
95806 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
95807 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
95808 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
95809 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
95810 +lp_write_9511 lp_write 3 9511 NULL
95811 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
95812 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
95813 +read_file_dma_9530 read_file_dma 3 9530 NULL
95814 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
95815 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
95816 +fw_node_create_9559 fw_node_create 2 9559 NULL
95817 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
95818 +kobj_map_9566 kobj_map 2-3 9566 NULL
95819 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
95820 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
95821 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
95822 +do_sync_9604 do_sync 1 9604 NULL
95823 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
95824 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
95825 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
95826 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
95827 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
95828 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
95829 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
95830 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
95831 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
95832 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
95833 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
95834 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
95835 +is_hole_9694 is_hole 2 9694 NULL nohasharray
95836 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
95837 +fnb_9703 fnb 2-3 9703 NULL
95838 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
95839 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
95840 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
95841 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
95842 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
95843 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
95844 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
95845 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
95846 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
95847 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
95848 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
95849 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
95850 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
95851 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
95852 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
95853 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
95854 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
95855 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
95856 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
95857 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
95858 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
95859 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
95860 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
95861 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
95862 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
95863 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
95864 +read_file_misc_9948 read_file_misc 3 9948 NULL
95865 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
95866 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
95867 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
95868 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
95869 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
95870 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
95871 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
95872 +handle_request_10024 handle_request 9 10024 NULL
95873 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
95874 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
95875 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
95876 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
95877 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
95878 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
95879 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
95880 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
95881 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
95882 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
95883 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
95884 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
95885 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
95886 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
95887 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
95888 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
95889 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
95890 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
95891 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
95892 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
95893 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
95894 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
95895 +read_emulate_10310 read_emulate 2-4 10310 NULL
95896 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
95897 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
95898 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
95899 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
95900 +get_dump_page_10338 get_dump_page 1 10338 NULL
95901 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
95902 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
95903 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
95904 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
95905 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
95906 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
95907 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
95908 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
95909 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
95910 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
95911 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
95912 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
95913 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
95914 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
95915 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
95916 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
95917 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
95918 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
95919 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
95920 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
95921 +otp_read_10594 otp_read 2-4-5 10594 NULL
95922 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
95923 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
95924 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
95925 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
95926 +parport_write_10669 parport_write 0 10669 NULL
95927 +inl_10708 inl 0 10708 NULL nohasharray
95928 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
95929 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
95930 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
95931 +spi_sync_10731 spi_sync 0 10731 NULL
95932 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
95933 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
95934 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
95935 +sys_syslog_10746 sys_syslog 3 10746 NULL
95936 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
95937 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
95938 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
95939 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
95940 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
95941 +sys_bind_10799 sys_bind 3 10799 NULL
95942 +compat_put_int_10828 compat_put_int 1 10828 NULL
95943 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
95944 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
95945 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
95946 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
95947 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
95948 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
95949 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
95950 +get_scq_10897 get_scq 2 10897 NULL
95951 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
95952 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
95953 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
95954 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
95955 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
95956 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
95957 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
95958 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
95959 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
95960 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
95961 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
95962 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
95963 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
95964 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
95965 +count_argc_11083 count_argc 0 11083 NULL
95966 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
95967 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
95968 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
95969 +page_offset_11120 page_offset 0 11120 NULL
95970 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
95971 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
95972 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
95973 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
95974 +__swab16p_11220 __swab16p 0 11220 NULL
95975 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
95976 +mmap_region_11247 mmap_region 0-2 11247 NULL
95977 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
95978 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
95979 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
95980 +cru_detect_11272 cru_detect 1 11272 NULL
95981 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
95982 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
95983 +construct_key_11329 construct_key 3 11329 NULL nohasharray
95984 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
95985 +next_segment_11330 next_segment 0-2-1 11330 NULL
95986 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
95987 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
95988 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
95989 +sel_write_create_11353 sel_write_create 3 11353 NULL
95990 +handle_unit_11355 handle_unit 0-1 11355 NULL
95991 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
95992 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
95993 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
95994 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
95995 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
95996 +str_to_user_11411 str_to_user 2 11411 NULL
95997 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
95998 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
95999 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
96000 +trace_options_read_11419 trace_options_read 3 11419 NULL
96001 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
96002 +prepare_image_11424 prepare_image 0 11424 NULL
96003 +vring_size_11426 vring_size 0-1-2 11426 NULL
96004 +bttv_read_11432 bttv_read 3 11432 NULL
96005 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
96006 +swp_offset_11475 swp_offset 0 11475 NULL
96007 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
96008 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
96009 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
96010 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
96011 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
96012 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
96013 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
96014 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
96015 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
96016 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
96017 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
96018 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
96019 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
96020 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
96021 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
96022 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
96023 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
96024 +split_11691 split 2 11691 NULL
96025 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
96026 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
96027 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
96028 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
96029 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
96030 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
96031 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
96032 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
96033 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
96034 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
96035 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
96036 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
96037 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
96038 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
96039 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
96040 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
96041 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
96042 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
96043 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
96044 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
96045 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
96046 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
96047 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
96048 +atmel_read16_11981 atmel_read16 0 11981 NULL
96049 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
96050 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
96051 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
96052 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
96053 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
96054 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
96055 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
96056 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
96057 +set_powered_12129 set_powered 4 12129 NULL
96058 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
96059 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
96060 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
96061 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
96062 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
96063 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
96064 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
96065 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
96066 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
96067 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
96068 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
96069 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
96070 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
96071 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
96072 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
96073 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
96074 +receive_copy_12216 receive_copy 3 12216 NULL
96075 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
96076 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
96077 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
96078 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
96079 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
96080 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
96081 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
96082 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
96083 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
96084 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
96085 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
96086 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
96087 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
96088 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
96089 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
96090 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
96091 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
96092 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
96093 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
96094 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
96095 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
96096 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
96097 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
96098 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
96099 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
96100 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
96101 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
96102 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
96103 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
96104 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
96105 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
96106 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
96107 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
96108 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
96109 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
96110 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
96111 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
96112 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
96113 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
96114 +wb_create_12651 wb_create 1 12651 NULL
96115 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
96116 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
96117 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
96118 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
96119 +ivtv_write_12721 ivtv_write 3 12721 NULL
96120 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
96121 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
96122 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
96123 +listxattr_12769 listxattr 3 12769 NULL
96124 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
96125 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
96126 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
96127 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
96128 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
96129 +readq_12825 readq 0 12825 NULL
96130 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
96131 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
96132 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
96133 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
96134 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
96135 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
96136 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
96137 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
96138 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
96139 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
96140 +bm_status_write_12964 bm_status_write 3 12964 NULL
96141 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
96142 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
96143 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
96144 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
96145 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
96146 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
96147 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
96148 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
96149 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
96150 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
96151 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
96152 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
96153 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
96154 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
96155 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
96156 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
96157 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
96158 +blk_update_request_13146 blk_update_request 3 13146 NULL
96159 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
96160 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
96161 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
96162 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
96163 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
96164 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
96165 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
96166 +comedi_read_13199 comedi_read 3 13199 NULL
96167 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
96168 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
96169 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
96170 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
96171 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
96172 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
96173 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
96174 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
96175 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
96176 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
96177 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
96178 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
96179 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
96180 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
96181 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
96182 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
96183 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
96184 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
96185 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
96186 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
96187 +cache_ctr_13364 cache_ctr 2 13364 NULL
96188 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
96189 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
96190 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
96191 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
96192 +sky2_receive_13407 sky2_receive 2 13407 NULL
96193 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
96194 +keyring_read_13438 keyring_read 3 13438 NULL
96195 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
96196 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
96197 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
96198 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
96199 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
96200 +core_status_13515 core_status 4 13515 NULL
96201 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
96202 +bm_init_13529 bm_init 2 13529 NULL
96203 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL
96204 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
96205 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
96206 +sys_madvise_13569 sys_madvise 1 13569 NULL
96207 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
96208 +cache_write_13589 cache_write 3 13589 NULL
96209 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
96210 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
96211 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
96212 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
96213 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
96214 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
96215 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
96216 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
96217 +packet_snd_13634 packet_snd 3 13634 NULL
96218 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
96219 +cache_downcall_13666 cache_downcall 3 13666 NULL
96220 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
96221 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
96222 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
96223 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
96224 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
96225 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
96226 +random_read_13815 random_read 3 13815 NULL
96227 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
96228 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
96229 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
96230 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
96231 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
96232 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
96233 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
96234 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
96235 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
96236 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
96237 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
96238 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
96239 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
96240 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
96241 +com90xx_found_13974 com90xx_found 3 13974 NULL
96242 +qcam_read_13977 qcam_read 3 13977 NULL
96243 +dsp_read_13980 dsp_read 2 13980 NULL
96244 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
96245 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
96246 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
96247 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
96248 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
96249 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
96250 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
96251 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
96252 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
96253 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
96254 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
96255 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
96256 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
96257 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
96258 +em_canid_change_14150 em_canid_change 3 14150 NULL
96259 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
96260 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
96261 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
96262 +alloc_async_14208 alloc_async 1 14208 NULL
96263 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
96264 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
96265 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
96266 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
96267 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
96268 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
96269 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
96270 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
96271 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
96272 +rr_status_14293 rr_status 5 14293 NULL
96273 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
96274 +oo_objects_14319 oo_objects 0 14319 NULL
96275 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
96276 +scsi2int_14358 scsi2int 0 14358 NULL
96277 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
96278 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
96279 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
96280 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
96281 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
96282 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
96283 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
96284 +block_size_14443 block_size 0 14443 NULL
96285 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
96286 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
96287 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
96288 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
96289 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
96290 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
96291 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
96292 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
96293 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
96294 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
96295 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
96296 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
96297 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
96298 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
96299 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
96300 +dbJoin_14644 dbJoin 0 14644 NULL
96301 +profile_replace_14652 profile_replace 3 14652 NULL
96302 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
96303 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
96304 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
96305 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
96306 +get_bio_block_14714 get_bio_block 0 14714 NULL
96307 +vfd_write_14717 vfd_write 3 14717 NULL
96308 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
96309 +raid1_resize_14740 raid1_resize 2 14740 NULL
96310 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
96311 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
96312 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
96313 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
96314 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
96315 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
96316 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
96317 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
96318 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
96319 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
96320 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
96321 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
96322 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
96323 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
96324 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
96325 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
96326 +unifi_read_14899 unifi_read 3 14899 NULL
96327 +krealloc_14908 krealloc 2 14908 NULL
96328 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
96329 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
96330 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
96331 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
96332 +queue_cnt_14951 queue_cnt 0 14951 NULL
96333 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
96334 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
96335 +setkey_14987 setkey 3 14987 NULL nohasharray
96336 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
96337 +vmap_15025 vmap 2 15025 NULL
96338 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
96339 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
96340 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
96341 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
96342 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
96343 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
96344 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
96345 +start_port_15124 start_port 0 15124 NULL
96346 +memchr_15126 memchr 0 15126 NULL
96347 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
96348 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
96349 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
96350 +reserve_resources_15194 reserve_resources 3 15194 NULL
96351 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
96352 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
96353 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
96354 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
96355 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
96356 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
96357 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
96358 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
96359 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
96360 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
96361 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
96362 +ioread16_15342 ioread16 0 15342 NULL
96363 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
96364 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
96365 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
96366 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
96367 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
96368 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
96369 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
96370 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
96371 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
96372 +get_modalias_15406 get_modalias 2 15406 NULL
96373 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
96374 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
96375 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
96376 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
96377 +memweight_15450 memweight 2 15450 NULL
96378 +vmalloc_15464 vmalloc 1 15464 NULL
96379 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
96380 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
96381 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
96382 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
96383 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
96384 +persistent_status_15574 persistent_status 4 15574 NULL
96385 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
96386 +vme_user_write_15587 vme_user_write 3 15587 NULL
96387 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
96388 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
96389 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
96390 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
96391 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
96392 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
96393 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
96394 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
96395 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
96396 +fs_path_add_15648 fs_path_add 3 15648 NULL
96397 +xsd_read_15653 xsd_read 3 15653 NULL
96398 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
96399 +unix_bind_15668 unix_bind 3 15668 NULL
96400 +dm_read_15674 dm_read 3 15674 NULL
96401 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
96402 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
96403 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
96404 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
96405 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
96406 +do_test_15766 do_test 1 15766 NULL
96407 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
96408 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
96409 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
96410 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
96411 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
96412 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
96413 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
96414 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
96415 +table_size_15851 table_size 0-1-2 15851 NULL
96416 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
96417 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
96418 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
96419 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
96420 +native_read_msr_15905 native_read_msr 0 15905 NULL
96421 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
96422 +power_read_15939 power_read 3 15939 NULL
96423 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
96424 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
96425 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
96426 +frame_alloc_15981 frame_alloc 4 15981 NULL
96427 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
96428 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
96429 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
96430 +got_frame_16028 got_frame 2 16028 NULL
96431 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
96432 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
96433 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
96434 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
96435 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
96436 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
96437 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
96438 +fsm_init_16134 fsm_init 2 16134 NULL
96439 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
96440 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
96441 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
96442 +mapping_level_16188 mapping_level 2 16188 NULL
96443 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
96444 +create_table_16213 create_table 2 16213 NULL
96445 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
96446 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
96447 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
96448 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
96449 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
96450 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
96451 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
96452 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
96453 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
96454 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
96455 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
96456 +account_16283 account 0-2-4 16283 NULL nohasharray
96457 +mirror_status_16283 mirror_status 5 16283 &account_16283
96458 +retry_instruction_16285 retry_instruction 2 16285 NULL
96459 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
96460 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
96461 +wb_map_16301 wb_map 2 16301 NULL
96462 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
96463 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
96464 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
96465 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
96466 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
96467 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
96468 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
96469 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
96470 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
96471 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
96472 +raid10_resize_16537 raid10_resize 2 16537 NULL
96473 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
96474 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
96475 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
96476 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
96477 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
96478 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
96479 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
96480 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
96481 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
96482 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
96483 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
96484 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
96485 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
96486 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
96487 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
96488 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
96489 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
96490 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
96491 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
96492 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
96493 +st_write_16874 st_write 3 16874 NULL
96494 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
96495 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
96496 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
96497 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
96498 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
96499 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
96500 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
96501 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
96502 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
96503 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
96504 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
96505 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
96506 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
96507 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
96508 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
96509 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
96510 +mac_address_string_17091 mac_address_string 0 17091 NULL
96511 +entry_length_17093 entry_length 0 17093 NULL
96512 +sys_preadv_17100 sys_preadv 3 17100 NULL
96513 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
96514 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
96515 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
96516 +sep_read_17161 sep_read 3 17161 NULL
96517 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
96518 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
96519 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
96520 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
96521 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
96522 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
96523 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
96524 +to_oblock_17254 to_oblock 0-1 17254 NULL
96525 +unpack_value_17259 unpack_value 1 17259 NULL
96526 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
96527 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
96528 +alloc_ep_17269 alloc_ep 1 17269 NULL
96529 +pg_read_17276 pg_read 3 17276 NULL
96530 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
96531 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
96532 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
96533 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
96534 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
96535 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
96536 +skb_pad_17302 skb_pad 2 17302 NULL
96537 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
96538 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
96539 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
96540 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
96541 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
96542 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
96543 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
96544 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
96545 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
96546 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
96547 +compat_cmd_17465 compat_cmd 2 17465 NULL
96548 +probe_bios_17467 probe_bios 1 17467 NULL
96549 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
96550 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
96551 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
96552 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
96553 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
96554 +copy_from_user_17559 copy_from_user 3 17559 NULL
96555 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
96556 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
96557 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
96558 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
96559 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
96560 +osst_execute_17607 osst_execute 7-6 17607 NULL
96561 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
96562 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
96563 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
96564 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
96565 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
96566 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
96567 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
96568 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
96569 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
96570 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
96571 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
96572 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
96573 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
96574 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
96575 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
96576 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
96577 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
96578 +count_leafs_17842 count_leafs 0 17842 NULL
96579 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
96580 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
96581 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
96582 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
96583 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
96584 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
96585 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
96586 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
96587 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
96588 +recover_head_17904 recover_head 3 17904 NULL
96589 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
96590 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
96591 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
96592 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
96593 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
96594 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
96595 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
96596 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
96597 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
96598 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
96599 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
96600 +fill_read_18019 fill_read 0 18019 NULL
96601 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
96602 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
96603 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
96604 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
96605 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
96606 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
96607 +packet_came_18072 packet_came 3 18072 NULL
96608 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
96609 +get_vm_area_18080 get_vm_area 1 18080 NULL
96610 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
96611 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
96612 +svc_getnl_18120 svc_getnl 0 18120 NULL
96613 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
96614 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
96615 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
96616 +_has_tag_18169 _has_tag 2 18169 NULL
96617 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
96618 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
96619 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
96620 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
96621 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
96622 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
96623 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
96624 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
96625 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
96626 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
96627 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
96628 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
96629 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
96630 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
96631 +um_idi_write_18293 um_idi_write 3 18293 NULL
96632 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
96633 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
96634 +vga_r_18310 vga_r 0 18310 NULL
96635 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
96636 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
96637 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
96638 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
96639 +ep_io_18367 ep_io 0 18367 NULL
96640 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
96641 +__video_register_device_18399 __video_register_device 3 18399 NULL
96642 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 NULL
96643 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
96644 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
96645 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
96646 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
96647 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
96648 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
96649 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
96650 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
96651 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
96652 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
96653 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
96654 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
96655 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
96656 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
96657 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
96658 +debug_output_18575 debug_output 3 18575 NULL
96659 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
96660 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
96661 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL
96662 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
96663 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
96664 +from_buffer_18625 from_buffer 3 18625 NULL
96665 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
96666 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
96667 +unmap_page_18665 unmap_page 2-3 18665 NULL
96668 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
96669 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
96670 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
96671 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
96672 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
96673 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
96674 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
96675 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
96676 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
96677 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
96678 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
96679 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
96680 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
96681 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
96682 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
96683 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
96684 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
96685 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
96686 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
96687 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
96688 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
96689 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
96690 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
96691 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
96692 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
96693 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
96694 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
96695 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
96696 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
96697 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
96698 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
96699 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
96700 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
96701 +huge_page_size_19008 huge_page_size 0 19008 NULL
96702 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
96703 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
96704 +revalidate_19043 revalidate 2 19043 NULL
96705 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
96706 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
96707 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
96708 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
96709 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
96710 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
96711 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
96712 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
96713 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
96714 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
96715 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
96716 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
96717 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
96718 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
96719 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
96720 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
96721 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
96722 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
96723 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
96724 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
96725 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
96726 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
96727 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
96728 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
96729 +qc_capture_19298 qc_capture 3 19298 NULL
96730 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
96731 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
96732 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
96733 +debug_read_19322 debug_read 3 19322 NULL
96734 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
96735 +read_zero_19366 read_zero 3 19366 NULL
96736 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
96737 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
96738 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
96739 +__phys_addr_19434 __phys_addr 0 19434 NULL
96740 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
96741 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
96742 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
96743 +sky2_read16_19475 sky2_read16 0 19475 NULL
96744 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
96745 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
96746 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
96747 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
96748 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
96749 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
96750 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
96751 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
96752 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
96753 +nfsd_read_19568 nfsd_read 5 19568 NULL
96754 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
96755 +bm_status_read_19583 bm_status_read 3 19583 NULL
96756 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
96757 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
96758 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
96759 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
96760 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
96761 +bio_detain_19690 bio_detain 2 19690 NULL
96762 +read_reg_19723 read_reg 0 19723 NULL
96763 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
96764 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
96765 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
96766 +p9_client_read_19750 p9_client_read 5 19750 NULL
96767 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
96768 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
96769 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
96770 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
96771 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
96772 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
96773 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
96774 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
96775 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
96776 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
96777 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
96778 +__nla_put_19857 __nla_put 3 19857 NULL
96779 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
96780 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
96781 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
96782 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
96783 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
96784 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
96785 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
96786 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
96787 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
96788 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
96789 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
96790 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
96791 +team_options_register_20091 team_options_register 3 20091 NULL
96792 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
96793 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
96794 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
96795 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
96796 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
96797 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
96798 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
96799 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
96800 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
96801 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
96802 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
96803 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
96804 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
96805 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
96806 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
96807 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
96808 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
96809 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
96810 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
96811 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
96812 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
96813 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
96814 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
96815 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
96816 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
96817 +read_buf_20469 read_buf 2 20469 NULL
96818 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
96819 +fast_user_write_20494 fast_user_write 5 20494 NULL
96820 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
96821 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
96822 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
96823 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
96824 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
96825 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
96826 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
96827 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
96828 +venus_create_20555 venus_create 4 20555 NULL
96829 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
96830 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
96831 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
96832 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
96833 +lirc_write_20604 lirc_write 3 20604 NULL
96834 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
96835 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
96836 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
96837 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
96838 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
96839 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
96840 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
96841 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
96842 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
96843 +cpumask_size_20683 cpumask_size 0 20683 NULL
96844 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
96845 +gru_vtop_20689 gru_vtop 2 20689 NULL
96846 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
96847 +__maestro_read_20700 __maestro_read 0 20700 NULL
96848 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
96849 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
96850 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
96851 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
96852 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
96853 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
96854 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
96855 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
96856 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
96857 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
96858 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
96859 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
96860 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
96861 +sys_sendto_20809 sys_sendto 6 20809 NULL
96862 +strndup_user_20819 strndup_user 2 20819 NULL
96863 +calc_layout_20829 calc_layout 3 20829 NULL
96864 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
96865 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
96866 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
96867 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
96868 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
96869 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
96870 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
96871 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
96872 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
96873 +htable_bits_20933 htable_bits 0 20933 NULL
96874 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
96875 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
96876 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
96877 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
96878 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
96879 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
96880 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
96881 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
96882 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
96883 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
96884 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
96885 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
96886 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
96887 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
96888 +multipath_status_21094 multipath_status 5 21094 NULL
96889 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
96890 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
96891 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
96892 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
96893 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
96894 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
96895 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
96896 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
96897 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
96898 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
96899 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
96900 +input_ff_create_21240 input_ff_create 2 21240 NULL
96901 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
96902 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
96903 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
96904 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
96905 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
96906 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
96907 +add_res_range_21310 add_res_range 4 21310 NULL
96908 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
96909 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
96910 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
96911 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
96912 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
96913 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
96914 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
96915 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
96916 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
96917 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
96918 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
96919 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
96920 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
96921 +concat_writev_21451 concat_writev 3 21451 NULL
96922 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
96923 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
96924 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
96925 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
96926 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
96927 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
96928 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
96929 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
96930 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
96931 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
96932 +validate_nnode_21638 validate_nnode 0 21638 NULL
96933 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
96934 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
96935 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
96936 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
96937 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
96938 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
96939 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
96940 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
96941 +vm_brk_21739 vm_brk 1 21739 NULL
96942 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
96943 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
96944 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
96945 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
96946 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
96947 +min_odd_21802 min_odd 0 21802 NULL
96948 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
96949 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
96950 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
96951 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
96952 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
96953 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
96954 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
96955 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
96956 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
96957 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
96958 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
96959 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
96960 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
96961 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
96962 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
96963 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
96964 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
96965 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
96966 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
96967 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
96968 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
96969 +write_opcode_22082 write_opcode 2 22082 NULL
96970 +mem_rw_22085 mem_rw 3 22085 NULL
96971 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
96972 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
96973 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
96974 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
96975 +compat_insn_22142 compat_insn 2 22142 NULL
96976 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
96977 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
96978 +fls_22210 fls 0 22210 NULL
96979 +mem_write_22232 mem_write 3 22232 NULL
96980 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
96981 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
96982 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
96983 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
96984 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
96985 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
96986 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
96987 +extend_brk_22301 extend_brk 0 22301 NULL
96988 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
96989 +get_segment_base_22324 get_segment_base 0 22324 NULL
96990 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
96991 +atomic_read_22342 atomic_read 0 22342 NULL
96992 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
96993 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
96994 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
96995 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
96996 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
96997 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
96998 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
96999 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
97000 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
97001 +zoran_write_22404 zoran_write 3 22404 NULL
97002 +queue_reply_22416 queue_reply 3 22416 NULL
97003 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
97004 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
97005 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
97006 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
97007 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
97008 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
97009 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
97010 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
97011 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
97012 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
97013 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
97014 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
97015 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
97016 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
97017 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
97018 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
97019 +snapshot_read_22601 snapshot_read 3 22601 NULL
97020 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
97021 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
97022 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
97023 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
97024 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
97025 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
97026 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
97027 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
97028 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
97029 +map_22700 map 2 22700 NULL
97030 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
97031 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
97032 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
97033 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
97034 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
97035 +print_frame_22769 print_frame 0 22769 NULL
97036 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
97037 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
97038 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
97039 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
97040 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
97041 +create_attr_set_22861 create_attr_set 1 22861 NULL
97042 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
97043 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
97044 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
97045 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
97046 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
97047 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
97048 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
97049 +vme_get_size_22964 vme_get_size 0 22964 NULL
97050 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
97051 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
97052 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
97053 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
97054 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
97055 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
97056 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
97057 +st_status_23032 st_status 5 23032 NULL
97058 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
97059 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
97060 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
97061 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
97062 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
97063 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
97064 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
97065 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
97066 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
97067 +fls_long_23096 fls_long 0 23096 NULL
97068 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
97069 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
97070 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
97071 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
97072 +__clear_user_23118 __clear_user 0 23118 NULL
97073 +dm_write_async_23120 dm_write_async 3 23120 NULL
97074 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
97075 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
97076 +read_file_ani_23161 read_file_ani 3 23161 NULL
97077 +ioremap_23172 ioremap 1-2 23172 NULL
97078 +usblp_write_23178 usblp_write 3 23178 NULL
97079 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
97080 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
97081 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
97082 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
97083 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
97084 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
97085 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
97086 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
97087 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
97088 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
97089 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
97090 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
97091 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
97092 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
97093 +doc_probe_23285 doc_probe 1 23285 NULL
97094 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
97095 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
97096 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
97097 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
97098 +page_readlink_23346 page_readlink 3 23346 NULL
97099 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
97100 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
97101 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
97102 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
97103 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
97104 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
97105 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
97106 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
97107 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
97108 +event_filter_read_23494 event_filter_read 3 23494 NULL
97109 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
97110 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
97111 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
97112 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
97113 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
97114 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
97115 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
97116 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
97117 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
97118 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
97119 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
97120 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
97121 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
97122 +sInW_23663 sInW 0 23663 NULL
97123 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
97124 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
97125 +cx18_read_23699 cx18_read 3 23699 NULL
97126 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
97127 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
97128 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
97129 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
97130 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
97131 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
97132 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
97133 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
97134 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
97135 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
97136 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
97137 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
97138 +p54_init_common_23850 p54_init_common 1 23850 NULL
97139 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
97140 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
97141 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
97142 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
97143 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
97144 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
97145 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
97146 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
97147 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
97148 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
97149 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
97150 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
97151 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
97152 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
97153 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
97154 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
97155 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
97156 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
97157 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
97158 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
97159 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
97160 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
97161 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
97162 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
97163 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
97164 +mpu401_read_24126 mpu401_read 3 24126 NULL
97165 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
97166 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
97167 +set_discard_24162 set_discard 2 24162 NULL
97168 +adu_read_24177 adu_read 3 24177 NULL
97169 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
97170 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
97171 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
97172 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
97173 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
97174 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
97175 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
97176 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
97177 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
97178 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
97179 +thin_status_24278 thin_status 5 24278 NULL
97180 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
97181 +msg_size_24288 msg_size 0 24288 NULL
97182 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
97183 +map_page_24298 map_page 3-4 24298 NULL
97184 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
97185 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
97186 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
97187 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
97188 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
97189 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
97190 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
97191 +igetword_24373 igetword 0 24373 NULL
97192 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
97193 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
97194 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
97195 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
97196 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
97197 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
97198 +smk_user_access_24440 smk_user_access 3 24440 NULL
97199 +page_address_24444 page_address 0 24444 NULL
97200 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
97201 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
97202 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
97203 +pd_video_read_24510 pd_video_read 3 24510 NULL
97204 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
97205 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
97206 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
97207 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
97208 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
97209 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
97210 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
97211 +count_preds_24600 count_preds 0 24600 NULL
97212 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
97213 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
97214 +context_alloc_24645 context_alloc 3 24645 NULL
97215 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
97216 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
97217 +read_fs_24717 read_fs 0 24717 NULL
97218 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
97219 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
97220 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
97221 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
97222 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
97223 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
97224 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
97225 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
97226 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
97227 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
97228 +cache_read_24790 cache_read 3 24790 NULL
97229 +unpack_str_24798 unpack_str 0 24798 NULL
97230 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
97231 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
97232 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
97233 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
97234 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
97235 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
97236 +setup_buffering_24872 setup_buffering 3 24872 NULL
97237 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
97238 +queues_read_24877 queues_read 3 24877 NULL
97239 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
97240 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
97241 +next_token_24929 next_token 0 24929 NULL
97242 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
97243 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
97244 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
97245 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
97246 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
97247 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
97248 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
97249 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
97250 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
97251 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
97252 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
97253 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
97254 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
97255 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
97256 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
97257 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
97258 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
97259 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
97260 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
97261 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
97262 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
97263 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
97264 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
97265 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
97266 +stripe_status_25259 stripe_status 5 25259 NULL
97267 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
97268 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
97269 +vfs_writev_25278 vfs_writev 3 25278 NULL
97270 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
97271 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
97272 +help_25316 help 5 25316 NULL nohasharray
97273 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
97274 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
97275 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
97276 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
97277 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
97278 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
97279 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
97280 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
97281 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
97282 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
97283 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
97284 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
97285 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
97286 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
97287 +sb_permission_25523 sb_permission 0 25523 NULL
97288 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
97289 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
97290 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
97291 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
97292 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
97293 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
97294 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
97295 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
97296 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
97297 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
97298 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
97299 +__direct_map_25647 __direct_map 5-6 25647 NULL
97300 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
97301 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
97302 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
97303 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
97304 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
97305 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
97306 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
97307 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
97308 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
97309 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
97310 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
97311 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
97312 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
97313 +sg_read_25799 sg_read 3 25799 NULL
97314 +system_enable_read_25815 system_enable_read 3 25815 NULL
97315 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
97316 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
97317 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
97318 +parport_read_25855 parport_read 0 25855 NULL
97319 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
97320 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
97321 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
97322 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
97323 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
97324 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
97325 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
97326 +rcname_read_25919 rcname_read 3 25919 NULL
97327 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
97328 +key_flags_read_25931 key_flags_read 3 25931 NULL
97329 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
97330 +flush_25957 flush 2 25957 NULL
97331 +video_register_device_25971 video_register_device 3 25971 NULL
97332 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
97333 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
97334 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
97335 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
97336 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
97337 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
97338 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
97339 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
97340 +tun_do_read_26047 tun_do_read 5 26047 NULL
97341 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
97342 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
97343 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
97344 +skb_cow_26138 skb_cow 2 26138 NULL
97345 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
97346 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
97347 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
97348 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
97349 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
97350 +disk_devt_26180 disk_devt 0 26180 NULL
97351 +get_registers_26187 get_registers 3 26187 NULL
97352 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
97353 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
97354 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
97355 +mce_write_26201 mce_write 3 26201 NULL
97356 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
97357 +bio_split_26235 bio_split 2 26235 NULL
97358 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
97359 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
97360 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
97361 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
97362 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
97363 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
97364 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
97365 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
97366 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
97367 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
97368 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
97369 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
97370 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
97371 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
97372 +read_vmcore_26501 read_vmcore 3 26501 NULL
97373 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
97374 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
97375 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
97376 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
97377 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
97378 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
97379 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
97380 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
97381 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
97382 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
97383 +pack_value_26625 pack_value 1 26625 NULL
97384 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
97385 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
97386 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
97387 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
97388 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
97389 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
97390 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
97391 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
97392 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
97393 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
97394 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
97395 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
97396 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
97397 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
97398 +smk_write_load_26829 smk_write_load 3 26829 NULL
97399 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
97400 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
97401 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
97402 +scnprint_id_26842 scnprint_id 3 26842 NULL
97403 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
97404 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
97405 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
97406 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
97407 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
97408 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
97409 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
97410 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
97411 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
97412 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
97413 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
97414 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
97415 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
97416 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
97417 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
97418 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
97419 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
97420 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
97421 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
97422 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
97423 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
97424 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
97425 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
97426 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
97427 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
97428 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
97429 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
97430 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
97431 +pms_capture_27142 pms_capture 4 27142 NULL
97432 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
97433 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
97434 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
97435 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
97436 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
97437 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
97438 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
97439 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
97440 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
97441 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
97442 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
97443 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
97444 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
97445 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
97446 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
97447 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
97448 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
97449 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
97450 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
97451 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
97452 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
97453 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
97454 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
97455 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
97456 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
97457 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
97458 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
97459 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
97460 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
97461 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
97462 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
97463 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
97464 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
97465 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
97466 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
97467 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
97468 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
97469 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
97470 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
97471 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
97472 +qword_get_27670 qword_get 0 27670 NULL
97473 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
97474 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
97475 +evm_write_key_27715 evm_write_key 3 27715 NULL
97476 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
97477 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
97478 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
97479 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
97480 +kcalloc_27770 kcalloc 1-2 27770 NULL
97481 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
97482 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
97483 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
97484 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
97485 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
97486 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
97487 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
97488 +read_profile_27859 read_profile 3 27859 NULL
97489 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
97490 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
97491 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
97492 +gluebi_write_27905 gluebi_write 3 27905 NULL
97493 +bm_find_next_27929 bm_find_next 2 27929 NULL
97494 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
97495 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
97496 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
97497 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
97498 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
97499 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
97500 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
97501 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
97502 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
97503 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
97504 +pool_status_28055 pool_status 5 28055 NULL
97505 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
97506 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
97507 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
97508 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
97509 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
97510 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
97511 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
97512 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
97513 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
97514 +video_read_28148 video_read 3 28148 NULL
97515 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
97516 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
97517 +vread_28173 vread 0 28173 NULL
97518 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
97519 +d_path_28198 d_path 0 28198 NULL
97520 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
97521 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
97522 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
97523 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
97524 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
97525 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
97526 +usemap_size_28281 usemap_size 0 28281 NULL
97527 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
97528 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
97529 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
97530 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
97531 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
97532 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
97533 +snapshot_write_28351 snapshot_write 3 28351 NULL
97534 +sys_writev_28384 sys_writev 3 28384 NULL
97535 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
97536 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
97537 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
97538 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
97539 +__split_large_page_28429 __split_large_page 2 28429 NULL
97540 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
97541 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
97542 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
97543 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
97544 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
97545 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
97546 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
97547 +max_response_pages_28492 max_response_pages 0 28492 NULL
97548 +clear_discard_28494 clear_discard 2 28494 NULL
97549 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
97550 +__next_node_28521 __next_node 1 28521 NULL
97551 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
97552 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
97553 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
97554 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
97555 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
97556 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
97557 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
97558 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
97559 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
97560 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
97561 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
97562 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
97563 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
97564 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
97565 +_set_range_28627 _set_range 3 28627 NULL
97566 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
97567 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
97568 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
97569 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
97570 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
97571 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
97572 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
97573 +spi_execute_28736 spi_execute 5 28736 NULL
97574 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
97575 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
97576 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
97577 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
97578 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
97579 +sel_write_member_28800 sel_write_member 3 28800 NULL
97580 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
97581 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
97582 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
97583 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
97584 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
97585 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
97586 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
97587 +to_cblock_28899 to_cblock 0-1 28899 NULL
97588 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
97589 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
97590 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
97591 +push_rx_28939 push_rx 3 28939 NULL
97592 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
97593 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
97594 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
97595 +bin_uuid_28999 bin_uuid 3 28999 NULL
97596 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
97597 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
97598 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
97599 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
97600 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
97601 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
97602 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
97603 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
97604 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
97605 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
97606 +snprintf_29125 snprintf 0 29125 NULL
97607 +iov_shorten_29130 iov_shorten 0 29130 NULL
97608 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
97609 +reshape_ring_29147 reshape_ring 2 29147 NULL
97610 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
97611 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
97612 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
97613 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
97614 +__mm_populate_29204 __mm_populate 1 29204 NULL
97615 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
97616 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
97617 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
97618 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
97619 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
97620 +recover_peb_29238 recover_peb 6-7 29238 NULL
97621 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
97622 +block_div_29268 block_div 0-1-2 29268 NULL
97623 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
97624 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
97625 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
97626 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
97627 +tun_put_user_29337 tun_put_user 5 29337 NULL
97628 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
97629 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
97630 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
97631 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
97632 +mempool_create_29437 mempool_create 1 29437 NULL
97633 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
97634 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
97635 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
97636 +do_register_entry_29478 do_register_entry 4 29478 NULL
97637 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
97638 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
97639 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
97640 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
97641 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
97642 +set_brk_29551 set_brk 1 29551 NULL nohasharray
97643 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
97644 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
97645 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
97646 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
97647 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
97648 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
97649 +slots_per_page_29601 slots_per_page 0 29601 NULL
97650 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
97651 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
97652 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
97653 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
97654 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
97655 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
97656 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
97657 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
97658 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
97659 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
97660 +probes_write_29711 probes_write 3 29711 NULL
97661 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
97662 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
97663 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
97664 +dbAlloc_29794 dbAlloc 0 29794 NULL
97665 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
97666 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
97667 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
97668 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
97669 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
97670 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
97671 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
97672 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
97673 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
97674 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
97675 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
97676 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
97677 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
97678 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
97679 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
97680 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
97681 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
97682 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
97683 +drp_wmove_30043 drp_wmove 4 30043 NULL
97684 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
97685 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
97686 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
97687 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
97688 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
97689 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
97690 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
97691 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
97692 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
97693 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
97694 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
97695 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
97696 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
97697 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
97698 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
97699 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
97700 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
97701 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
97702 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
97703 +compat_readv_30273 compat_readv 3 30273 NULL
97704 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
97705 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
97706 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
97707 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
97708 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
97709 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
97710 +resource_from_user_30341 resource_from_user 3 30341 NULL
97711 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
97712 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
97713 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
97714 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
97715 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
97716 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
97717 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
97718 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
97719 +mq_create_30425 mq_create 1 30425 NULL
97720 +enable_write_30456 enable_write 3 30456 NULL
97721 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
97722 +urandom_read_30462 urandom_read 3 30462 NULL
97723 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
97724 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
97725 +write_head_30481 write_head 4 30481 NULL
97726 +adu_write_30487 adu_write 3 30487 NULL
97727 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
97728 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
97729 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
97730 +set_le_30581 set_le 4 30581 NULL
97731 +from_cblock_30582 from_cblock 0-1 30582 NULL
97732 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
97733 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
97734 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
97735 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
97736 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
97737 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
97738 +agp_remap_30665 agp_remap 2 30665 NULL
97739 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
97740 +il_free_pages_30692 il_free_pages 2 30692 NULL
97741 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
97742 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
97743 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
97744 +snapshot_status_30744 snapshot_status 5 30744 NULL
97745 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
97746 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
97747 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
97748 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
97749 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
97750 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
97751 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
97752 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
97753 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
97754 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
97755 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
97756 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
97757 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
97758 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
97759 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
97760 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
97761 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
97762 +sys_mincore_31079 sys_mincore 1 31079 NULL
97763 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
97764 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
97765 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
97766 +depth_read_31112 depth_read 3 31112 NULL
97767 +ssb_read16_31139 ssb_read16 0 31139 NULL
97768 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
97769 +size_inside_page_31141 size_inside_page 0 31141 NULL
97770 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
97771 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
97772 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
97773 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
97774 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
97775 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
97776 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
97777 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
97778 +__read_reg_31216 __read_reg 0 31216 NULL
97779 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
97780 +cyy_readb_31240 cyy_readb 0 31240 NULL
97781 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
97782 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
97783 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
97784 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
97785 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
97786 +command_file_write_31318 command_file_write 3 31318 NULL
97787 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
97788 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
97789 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
97790 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
97791 +inb_31388 inb 0 31388 NULL
97792 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
97793 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
97794 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
97795 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
97796 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
97797 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
97798 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
97799 +do_fcntl_31468 do_fcntl 3 31468 NULL
97800 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
97801 +alg_setkey_31485 alg_setkey 3 31485 NULL
97802 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
97803 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
97804 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
97805 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
97806 +hidraw_write_31536 hidraw_write 3 31536 NULL
97807 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
97808 +usbvision_read_31555 usbvision_read 3 31555 NULL
97809 +normalize_31566 normalize 0-1-2 31566 NULL
97810 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
97811 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
97812 +osst_write_31581 osst_write 3 31581 NULL
97813 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
97814 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
97815 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
97816 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
97817 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
97818 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
97819 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
97820 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
97821 +__lgread_31668 __lgread 4 31668 NULL
97822 +symbol_string_31670 symbol_string 0 31670 NULL
97823 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
97824 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
97825 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
97826 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
97827 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
97828 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
97829 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
97830 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
97831 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
97832 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
97833 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
97834 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
97835 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
97836 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
97837 +get_count_order_31800 get_count_order 0 31800 NULL
97838 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
97839 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
97840 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
97841 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
97842 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
97843 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
97844 +xattr_permission_31907 xattr_permission 0 31907 NULL
97845 +new_dir_31919 new_dir 3 31919 NULL
97846 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
97847 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
97848 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
97849 +vb2_write_31948 vb2_write 3 31948 NULL
97850 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
97851 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
97852 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
97853 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
97854 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
97855 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
97856 +calc_hmac_32010 calc_hmac 3 32010 NULL
97857 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
97858 +aead_len_32021 aead_len 0 32021 NULL
97859 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
97860 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
97861 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
97862 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
97863 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
97864 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
97865 +bio_alloc_32095 bio_alloc 2 32095 NULL
97866 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
97867 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
97868 +disk_status_32120 disk_status 4 32120 NULL
97869 +venus_link_32165 venus_link 5 32165 NULL
97870 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
97871 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
97872 +load_header_32183 load_header 0 32183 NULL
97873 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
97874 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
97875 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
97876 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
97877 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
97878 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
97879 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
97880 +hex_string_32310 hex_string 0 32310 NULL
97881 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
97882 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
97883 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
97884 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
97885 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
97886 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
97887 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
97888 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
97889 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
97890 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
97891 +log_text_32428 log_text 0 32428 NULL
97892 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
97893 +hid_input_report_32458 hid_input_report 4 32458 NULL
97894 +cache_status_32462 cache_status 5 32462 NULL
97895 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
97896 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
97897 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
97898 +disconnect_32521 disconnect 4 32521 NULL
97899 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
97900 +ilo_read_32531 ilo_read 3 32531 NULL
97901 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
97902 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
97903 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
97904 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
97905 +__first_node_32558 __first_node 0 32558 NULL
97906 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
97907 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
97908 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
97909 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
97910 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
97911 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
97912 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
97913 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
97914 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
97915 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
97916 +kvmalloc_32646 kvmalloc 1 32646 NULL
97917 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
97918 +generic_readlink_32654 generic_readlink 3 32654 NULL
97919 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
97920 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
97921 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
97922 +get_arg_page_32746 get_arg_page 2 32746 NULL
97923 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
97924 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
97925 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
97926 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
97927 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
97928 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
97929 +vga_rseq_32848 vga_rseq 0 32848 NULL
97930 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
97931 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
97932 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
97933 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
97934 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
97935 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
97936 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
97937 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
97938 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
97939 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
97940 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
97941 +compat_filldir_32999 compat_filldir 3 32999 NULL
97942 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
97943 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
97944 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
97945 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
97946 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
97947 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
97948 +alloc_tio_33077 alloc_tio 3 33077 NULL
97949 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
97950 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
97951 +write_node_33121 write_node 4 33121 NULL
97952 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
97953 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
97954 +__len_within_target_33132 __len_within_target 0 33132 NULL
97955 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
97956 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
97957 +pp_read_33210 pp_read 3 33210 NULL
97958 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
97959 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
97960 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
97961 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
97962 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
97963 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
97964 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
97965 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
97966 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
97967 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
97968 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
97969 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
97970 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
97971 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
97972 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
97973 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
97974 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
97975 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
97976 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
97977 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
97978 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
97979 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
97980 +create_entry_33479 create_entry 2 33479 NULL
97981 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
97982 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
97983 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
97984 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
97985 +res_counter_read_33499 res_counter_read 4 33499 NULL
97986 +fb_read_33506 fb_read 3 33506 NULL
97987 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
97988 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
97989 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
97990 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
97991 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
97992 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
97993 +dup_array_33551 dup_array 3 33551 NULL
97994 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
97995 +count_subheaders_33591 count_subheaders 0 33591 NULL
97996 +scsi_execute_33596 scsi_execute 5 33596 NULL
97997 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
97998 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
97999 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
98000 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
98001 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
98002 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
98003 +inw_p_33668 inw_p 0 33668 NULL
98004 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
98005 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
98006 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
98007 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
98008 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
98009 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
98010 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
98011 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
98012 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
98013 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
98014 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
98015 +Read_hfc_33755 Read_hfc 0 33755 NULL
98016 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
98017 +hashtab_create_33769 hashtab_create 3 33769 NULL
98018 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
98019 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
98020 +find_next_offset_33804 find_next_offset 3 33804 NULL
98021 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
98022 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
98023 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
98024 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
98025 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
98026 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
98027 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
98028 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
98029 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
98030 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
98031 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
98032 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
98033 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
98034 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
98035 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
98036 +ppp_write_34034 ppp_write 3 34034 NULL
98037 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
98038 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
98039 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
98040 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
98041 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
98042 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
98043 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
98044 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
98045 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
98046 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
98047 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
98048 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
98049 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
98050 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
98051 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
98052 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
98053 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
98054 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
98055 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
98056 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
98057 +__insert_34349 __insert 2-3 34349 NULL
98058 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
98059 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
98060 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
98061 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
98062 +ea_read_34378 ea_read 0 34378 NULL
98063 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
98064 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
98065 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
98066 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
98067 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
98068 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
98069 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
98070 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
98071 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
98072 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
98073 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
98074 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
98075 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
98076 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
98077 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
98078 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
98079 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
98080 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
98081 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
98082 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
98083 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
98084 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
98085 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
98086 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
98087 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
98088 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
98089 +port_print_34704 port_print 3 34704 NULL
98090 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
98091 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
98092 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
98093 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
98094 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
98095 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
98096 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
98097 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
98098 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
98099 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
98100 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
98101 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
98102 +msg_print_text_34889 msg_print_text 0 34889 NULL
98103 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
98104 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
98105 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
98106 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
98107 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
98108 +Realloc_34961 Realloc 2 34961 NULL
98109 +mq_lookup_34990 mq_lookup 2 34990 NULL
98110 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
98111 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
98112 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
98113 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
98114 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
98115 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
98116 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
98117 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
98118 +store_ifalias_35088 store_ifalias 4 35088 NULL
98119 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
98120 +capi_write_35104 capi_write 3 35104 NULL nohasharray
98121 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
98122 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
98123 +pointer_35138 pointer 0 35138 NULL
98124 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
98125 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
98126 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
98127 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
98128 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
98129 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
98130 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
98131 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
98132 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
98133 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
98134 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
98135 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
98136 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
98137 +set_fd_set_35249 set_fd_set 1 35249 NULL
98138 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
98139 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
98140 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
98141 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
98142 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
98143 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
98144 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
98145 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
98146 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
98147 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
98148 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
98149 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
98150 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
98151 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
98152 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
98153 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
98154 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
98155 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
98156 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
98157 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
98158 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
98159 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
98160 +async_setkey_35521 async_setkey 3 35521 NULL
98161 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
98162 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
98163 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
98164 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
98165 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
98166 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
98167 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
98168 +ReadZReg_35604 ReadZReg 0 35604 NULL
98169 +kernel_readv_35617 kernel_readv 3 35617 NULL
98170 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
98171 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
98172 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
98173 +store_debug_level_35652 store_debug_level 3 35652 NULL
98174 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
98175 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
98176 +dm_table_create_35687 dm_table_create 3 35687 NULL
98177 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
98178 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
98179 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
98180 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
98181 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
98182 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
98183 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
98184 +fls64_35862 fls64 0 35862 NULL
98185 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
98186 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
98187 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
98188 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
98189 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
98190 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
98191 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
98192 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
98193 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
98194 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
98195 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
98196 +acl_alloc_35979 acl_alloc 1 35979 NULL
98197 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
98198 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
98199 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
98200 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
98201 +account_shadowed_36048 account_shadowed 2 36048 NULL
98202 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
98203 +write_emulate_36065 write_emulate 2-4 36065 NULL
98204 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
98205 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
98206 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
98207 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
98208 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
98209 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
98210 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
98211 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
98212 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
98213 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
98214 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
98215 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
98216 +twl_set_36154 twl_set 2 36154 NULL
98217 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
98218 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
98219 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
98220 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
98221 +is_dirty_36223 is_dirty 2 36223 NULL
98222 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
98223 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
98224 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
98225 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
98226 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
98227 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
98228 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
98229 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
98230 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
98231 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
98232 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
98233 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
98234 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
98235 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
98236 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
98237 +lc_create_36332 lc_create 4 36332 NULL
98238 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
98239 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
98240 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
98241 +to_sector_36361 to_sector 0-1 36361 NULL
98242 +tunables_read_36385 tunables_read 3 36385 NULL
98243 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
98244 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
98245 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
98246 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
98247 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
98248 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
98249 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
98250 +get_param_l_36518 get_param_l 0 36518 NULL
98251 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
98252 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
98253 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
98254 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
98255 +get_entry_len_36549 get_entry_len 0 36549 NULL
98256 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
98257 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
98258 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
98259 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
98260 +__erst_read_36579 __erst_read 0 36579 NULL
98261 +put_cmsg_36589 put_cmsg 4 36589 NULL
98262 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
98263 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
98264 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
98265 +format_decode_36638 format_decode 0 36638 NULL
98266 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
98267 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
98268 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
98269 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
98270 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
98271 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
98272 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
98273 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
98274 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
98275 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
98276 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
98277 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
98278 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
98279 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
98280 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
98281 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
98282 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
98283 +cm_write_36858 cm_write 3 36858 NULL
98284 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
98285 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
98286 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
98287 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
98288 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
98289 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
98290 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
98291 +build_key_36931 build_key 1 36931 NULL
98292 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
98293 +write_leb_36957 write_leb 5 36957 NULL
98294 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
98295 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
98296 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
98297 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
98298 +setxattr_37006 setxattr 4 37006 NULL
98299 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
98300 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
98301 +parse_command_37079 parse_command 2 37079 NULL
98302 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
98303 +tun_get_user_37094 tun_get_user 5 37094 NULL
98304 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
98305 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
98306 +msg_word_37164 msg_word 0 37164 NULL
98307 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
98308 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
98309 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
98310 +__do_replace_37227 __do_replace 5 37227 NULL
98311 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
98312 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
98313 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
98314 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
98315 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
98316 +c101_run_37279 c101_run 2 37279 NULL
98317 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
98318 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
98319 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
98320 +send_msg_37323 send_msg 4 37323 NULL
98321 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
98322 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
98323 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
98324 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
98325 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
98326 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
98327 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
98328 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
98329 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
98330 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
98331 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
98332 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
98333 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
98334 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
98335 +__remove_37457 __remove 2 37457 NULL
98336 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
98337 +get_est_timing_37484 get_est_timing 0 37484 NULL
98338 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
98339 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
98340 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
98341 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
98342 +hdr_size_37536 hdr_size 0 37536 NULL
98343 +a2p_37544 a2p 0-1 37544 NULL
98344 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
98345 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
98346 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
98347 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
98348 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
98349 +policy_residency_37629 policy_residency 0 37629 NULL
98350 +check_pt_base_37635 check_pt_base 3 37635 NULL
98351 +alloc_fd_37637 alloc_fd 1 37637 NULL
98352 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
98353 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
98354 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
98355 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
98356 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
98357 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
98358 +nametbl_header_37698 nametbl_header 2 37698 NULL
98359 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
98360 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
98361 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
98362 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
98363 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
98364 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
98365 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
98366 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
98367 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
98368 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
98369 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
98370 +deny_write_access_37813 deny_write_access 0 37813 NULL
98371 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
98372 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
98373 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
98374 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
98375 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
98376 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
98377 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
98378 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
98379 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
98380 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
98381 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
98382 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
98383 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
98384 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
98385 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
98386 +vfs_readv_38011 vfs_readv 3 38011 NULL
98387 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
98388 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
98389 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
98390 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
98391 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
98392 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
98393 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
98394 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
98395 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
98396 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
98397 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
98398 +ep0_read_38095 ep0_read 3 38095 NULL
98399 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
98400 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
98401 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
98402 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
98403 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
98404 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
98405 +cdev_add_38176 cdev_add 2-3 38176 NULL
98406 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
98407 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
98408 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
98409 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
98410 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
98411 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
98412 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
98413 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
98414 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
98415 +from_dblock_38256 from_dblock 0-1 38256 NULL
98416 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
98417 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
98418 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
98419 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
98420 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
98421 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
98422 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
98423 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
98424 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
98425 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
98426 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
98427 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
98428 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
98429 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
98430 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
98431 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
98432 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
98433 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
98434 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
98435 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
98436 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
98437 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
98438 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
98439 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
98440 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
98441 +dev_names_read_38509 dev_names_read 3 38509 NULL
98442 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
98443 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
98444 +set_queue_count_38519 set_queue_count 0 38519 NULL
98445 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
98446 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
98447 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
98448 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
98449 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
98450 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
98451 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
98452 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
98453 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
98454 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
98455 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
98456 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
98457 +cma_create_area_38642 cma_create_area 2 38642 NULL
98458 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
98459 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
98460 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
98461 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
98462 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
98463 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
98464 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
98465 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
98466 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
98467 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
98468 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
98469 +udf_readpages_38761 udf_readpages 4 38761 NULL
98470 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
98471 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
98472 +err_decode_38804 err_decode 2 38804 NULL
98473 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
98474 +sys_select_38827 sys_select 1 38827 NULL
98475 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
98476 +direct_entry_38836 direct_entry 3 38836 NULL
98477 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
98478 +interfaces_38859 interfaces 2 38859 NULL
98479 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
98480 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
98481 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
98482 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
98483 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
98484 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
98485 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
98486 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
98487 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
98488 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
98489 +udf_new_block_38999 udf_new_block 4 38999 NULL
98490 +get_nodes_39012 get_nodes 3 39012 NULL
98491 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
98492 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
98493 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
98494 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
98495 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
98496 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
98497 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
98498 +ea_foreach_39133 ea_foreach 0 39133 NULL
98499 +generic_permission_39150 generic_permission 0 39150 NULL
98500 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
98501 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
98502 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
98503 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
98504 +init_list_set_39188 init_list_set 2-3 39188 NULL
98505 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
98506 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
98507 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
98508 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
98509 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
98510 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
98511 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
98512 +drm_order_39244 drm_order 0 39244 NULL
98513 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
98514 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
98515 +__skb_cow_39254 __skb_cow 2 39254 NULL
98516 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
98517 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
98518 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
98519 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
98520 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
98521 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
98522 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
98523 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
98524 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
98525 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
98526 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
98527 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
98528 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
98529 +__send_to_port_39386 __send_to_port 3 39386 NULL
98530 +user_power_read_39414 user_power_read 3 39414 NULL
98531 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
98532 +sys_semop_39457 sys_semop 3 39457 NULL
98533 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
98534 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
98535 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
98536 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
98537 +int_proc_write_39542 int_proc_write 3 39542 NULL
98538 +pp_write_39554 pp_write 3 39554 NULL
98539 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
98540 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
98541 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
98542 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
98543 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
98544 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
98545 +ext_depth_39607 ext_depth 0 39607 NULL
98546 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
98547 +sdio_readb_39618 sdio_readb 0 39618 NULL
98548 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
98549 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
98550 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
98551 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
98552 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
98553 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
98554 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
98555 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
98556 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
98557 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
98558 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
98559 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
98560 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
98561 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
98562 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
98563 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
98564 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
98565 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
98566 +pkt_add_39897 pkt_add 3 39897 NULL
98567 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
98568 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
98569 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
98570 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
98571 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
98572 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
98573 +__spi_async_39932 __spi_async 0 39932 NULL
98574 +__get_order_39935 __get_order 0 39935 NULL
98575 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
98576 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
98577 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
98578 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
98579 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
98580 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
98581 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
98582 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
98583 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
98584 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
98585 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
98586 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
98587 +add_tty_40055 add_tty 1 40055 NULL nohasharray
98588 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
98589 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
98590 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
98591 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
98592 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
98593 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
98594 +pt_write_40159 pt_write 3 40159 NULL
98595 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
98596 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
98597 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
98598 +allocate_probes_40204 allocate_probes 1 40204 NULL
98599 +compat_put_long_40214 compat_put_long 1 40214 NULL
98600 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
98601 +osst_read_40237 osst_read 3 40237 NULL
98602 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
98603 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
98604 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
98605 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
98606 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
98607 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
98608 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
98609 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
98610 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
98611 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
98612 +mmio_read_40348 mmio_read 4 40348 NULL
98613 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
98614 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
98615 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
98616 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
98617 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
98618 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
98619 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
98620 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
98621 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
98622 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
98623 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
98624 +tty_write_room_40495 tty_write_room 0 40495 NULL
98625 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
98626 +sg_phys_40507 sg_phys 0 40507 NULL
98627 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
98628 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
98629 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
98630 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
98631 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
98632 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
98633 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
98634 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
98635 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
98636 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
98637 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
98638 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
98639 +fops_read_40672 fops_read 3 40672 NULL
98640 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
98641 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
98642 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
98643 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
98644 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
98645 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
98646 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
98647 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
98648 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
98649 +card_send_command_40757 card_send_command 3 40757 NULL
98650 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
98651 +pg_write_40766 pg_write 3 40766 NULL
98652 +show_list_40775 show_list 3 40775 NULL
98653 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
98654 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
98655 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
98656 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
98657 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
98658 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
98659 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
98660 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
98661 +read_file_queue_40895 read_file_queue 3 40895 NULL
98662 +waiters_read_40902 waiters_read 3 40902 NULL
98663 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
98664 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
98665 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
98666 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
98667 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
98668 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
98669 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
98670 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
98671 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
98672 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
98673 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
98674 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
98675 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
98676 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
98677 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
98678 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
98679 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
98680 +dma_attach_41094 dma_attach 5-6 41094 NULL
98681 +provide_user_output_41105 provide_user_output 3 41105 NULL
98682 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
98683 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
98684 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
98685 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
98686 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
98687 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
98688 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
98689 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
98690 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
98691 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
98692 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
98693 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
98694 +erst_read_41260 erst_read 0 41260 NULL
98695 +__fprog_create_41263 __fprog_create 2 41263 NULL
98696 +alloc_context_41283 alloc_context 1 41283 NULL
98697 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
98698 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
98699 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
98700 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
98701 +kmp_init_41373 kmp_init 2 41373 NULL
98702 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
98703 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
98704 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
98705 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
98706 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
98707 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
98708 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
98709 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
98710 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
98711 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
98712 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
98713 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
98714 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
98715 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
98716 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
98717 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
98718 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
98719 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
98720 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
98721 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
98722 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
98723 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
98724 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
98725 +vga_io_r_41609 vga_io_r 0 41609 NULL
98726 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
98727 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
98728 +a2mp_send_41615 a2mp_send 4 41615 NULL
98729 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
98730 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
98731 +get_std_timing_41654 get_std_timing 0 41654 NULL
98732 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
98733 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
98734 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
98735 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
98736 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
98737 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
98738 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
98739 +fillonedir_41746 fillonedir 3 41746 NULL
98740 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
98741 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
98742 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
98743 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
98744 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
98745 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
98746 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
98747 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
98748 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
98749 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
98750 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
98751 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
98752 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
98753 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
98754 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
98755 +portnames_read_41958 portnames_read 3 41958 NULL
98756 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
98757 +dst_mtu_41969 dst_mtu 0 41969 NULL
98758 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
98759 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
98760 +lguest_map_42008 lguest_map 1-2 42008 NULL
98761 +pool_allocate_42012 pool_allocate 3 42012 NULL
98762 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
98763 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
98764 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
98765 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
98766 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
98767 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
98768 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
98769 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
98770 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
98771 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
98772 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
98773 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
98774 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
98775 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
98776 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
98777 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
98778 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
98779 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
98780 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
98781 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
98782 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
98783 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
98784 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
98785 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
98786 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
98787 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
98788 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
98789 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
98790 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
98791 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
98792 +free_cblock_42318 free_cblock 2 42318 NULL
98793 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
98794 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
98795 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
98796 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
98797 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
98798 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
98799 +krng_get_random_42420 krng_get_random 3 42420 NULL
98800 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
98801 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
98802 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
98803 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
98804 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
98805 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
98806 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
98807 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
98808 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
98809 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
98810 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
98811 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
98812 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
98813 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
98814 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
98815 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
98816 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
98817 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
98818 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
98819 +map_state_42602 map_state 1 42602 NULL nohasharray
98820 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
98821 +nd_get_link_42603 nd_get_link 0 42603 NULL
98822 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
98823 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
98824 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
98825 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
98826 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
98827 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
98828 +vb2_read_42703 vb2_read 3 42703 NULL
98829 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
98830 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
98831 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
98832 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
98833 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
98834 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
98835 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
98836 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
98837 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
98838 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
98839 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
98840 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
98841 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
98842 +set_arg_42824 set_arg 3 42824 NULL
98843 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
98844 +prandom_u32_42853 prandom_u32 0 42853 NULL
98845 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
98846 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
98847 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
98848 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
98849 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
98850 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
98851 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
98852 +hd_end_request_42904 hd_end_request 2 42904 NULL
98853 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
98854 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
98855 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
98856 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
98857 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
98858 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
98859 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
98860 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
98861 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
98862 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
98863 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
98864 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
98865 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
98866 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
98867 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
98868 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
98869 +uuid_string_43154 uuid_string 0 43154 NULL
98870 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
98871 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
98872 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
98873 +process_measurement_43190 process_measurement 0 43190 NULL
98874 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
98875 +uio_write_43202 uio_write 3 43202 NULL
98876 +iso_callback_43208 iso_callback 3 43208 NULL
98877 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
98878 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
98879 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
98880 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
98881 +fixup_leb_43256 fixup_leb 3 43256 NULL
98882 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
98883 +evtchn_write_43278 evtchn_write 3 43278 NULL
98884 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
98885 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
98886 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
98887 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
98888 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
98889 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
98890 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
98891 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
98892 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
98893 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
98894 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
98895 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
98896 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
98897 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
98898 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
98899 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
98900 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
98901 +do_readlink_43518 do_readlink 2 43518 NULL
98902 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
98903 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
98904 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
98905 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
98906 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
98907 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
98908 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
98909 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
98910 +proc_read_43614 proc_read 3 43614 NULL
98911 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
98912 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
98913 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
98914 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
98915 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
98916 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
98917 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
98918 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
98919 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
98920 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
98921 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
98922 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
98923 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
98924 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
98925 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
98926 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
98927 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
98928 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
98929 +read_flush_43851 read_flush 3 43851 NULL
98930 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
98931 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
98932 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
98933 +SendString_43928 SendString 3 43928 NULL
98934 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
98935 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
98936 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
98937 +nla_reserve_43984 nla_reserve 3 43984 NULL
98938 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
98939 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
98940 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
98941 +emit_flags_44006 emit_flags 4-3 44006 NULL
98942 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
98943 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
98944 +load_discard_44083 load_discard 3 44083 NULL
98945 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
98946 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
98947 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
98948 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
98949 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
98950 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
98951 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
98952 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
98953 +__set_free_44211 __set_free 2 44211 NULL
98954 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
98955 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
98956 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
98957 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
98958 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
98959 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
98960 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
98961 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
98962 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
98963 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
98964 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
98965 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
98966 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
98967 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
98968 +__is_discarded_44359 __is_discarded 2 44359 NULL
98969 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
98970 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
98971 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
98972 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
98973 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
98974 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
98975 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
98976 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
98977 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
98978 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
98979 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
98980 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
98981 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
98982 +spidev_write_44510 spidev_write 3 44510 NULL
98983 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
98984 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
98985 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
98986 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
98987 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
98988 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
98989 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
98990 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
98991 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
98992 +mpi_resize_44674 mpi_resize 2 44674 NULL
98993 +ts_read_44687 ts_read 3 44687 NULL
98994 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
98995 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
98996 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
98997 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
98998 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
98999 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
99000 +set_brk_44749 set_brk 1 44749 NULL
99001 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
99002 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
99003 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
99004 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
99005 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
99006 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
99007 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
99008 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
99009 +sisusb_write_44834 sisusb_write 3 44834 NULL
99010 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
99011 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
99012 +skb_availroom_44883 skb_availroom 0 44883 NULL
99013 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
99014 +do_tty_write_44896 do_tty_write 5 44896 NULL
99015 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
99016 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
99017 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
99018 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
99019 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
99020 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
99021 +sel_write_user_45060 sel_write_user 3 45060 NULL
99022 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
99023 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
99024 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
99025 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
99026 +usbdev_read_45114 usbdev_read 3 45114 NULL
99027 +send_to_tty_45141 send_to_tty 3 45141 NULL
99028 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
99029 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
99030 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
99031 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
99032 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
99033 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
99034 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
99035 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
99036 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
99037 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
99038 +add_child_45201 add_child 4 45201 NULL
99039 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
99040 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
99041 +__dirty_45228 __dirty 2 45228 NULL
99042 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
99043 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
99044 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
99045 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
99046 +pte_val_45313 pte_val 0 45313 NULL
99047 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
99048 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
99049 +keymap_store_45406 keymap_store 4 45406 NULL
99050 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
99051 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
99052 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
99053 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
99054 +__node_remap_45458 __node_remap 4 45458 NULL
99055 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
99056 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
99057 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
99058 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
99059 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
99060 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
99061 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
99062 +copy_macs_45534 copy_macs 4 45534 NULL
99063 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
99064 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
99065 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
99066 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
99067 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
99068 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
99069 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
99070 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
99071 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
99072 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
99073 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
99074 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
99075 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
99076 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
99077 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
99078 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
99079 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
99080 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
99081 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
99082 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
99083 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
99084 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
99085 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
99086 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
99087 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
99088 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
99089 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
99090 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
99091 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
99092 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
99093 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
99094 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
99095 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
99096 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
99097 +isdn_write_45863 isdn_write 3 45863 NULL
99098 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
99099 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
99100 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
99101 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
99102 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
99103 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
99104 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
99105 +alloc_mr_45935 alloc_mr 1 45935 NULL
99106 +split_large_page_45941 split_large_page 2 45941 NULL
99107 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
99108 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
99109 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
99110 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
99111 +get_free_entries_46030 get_free_entries 1 46030 NULL
99112 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
99113 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
99114 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
99115 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
99116 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
99117 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
99118 +slhc_toss_46066 slhc_toss 0 46066 NULL
99119 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
99120 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
99121 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
99122 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
99123 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
99124 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
99125 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
99126 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
99127 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
99128 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
99129 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
99130 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
99131 +add_conn_list_46197 add_conn_list 3 46197 NULL
99132 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
99133 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
99134 +dsp_write_46218 dsp_write 2 46218 NULL
99135 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
99136 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
99137 +ReadReg_46277 ReadReg 0 46277 NULL
99138 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
99139 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
99140 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
99141 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
99142 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
99143 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
99144 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
99145 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
99146 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
99147 +filldir64_46469 filldir64 3 46469 NULL
99148 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
99149 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
99150 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
99151 +kmsg_read_46514 kmsg_read 3 46514 NULL
99152 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
99153 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
99154 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
99155 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
99156 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
99157 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
99158 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
99159 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
99160 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
99161 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
99162 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
99163 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
99164 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
99165 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
99166 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
99167 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
99168 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
99169 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
99170 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
99171 +prepare_copy_46725 prepare_copy 2 46725 NULL
99172 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
99173 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
99174 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
99175 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
99176 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
99177 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
99178 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
99179 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
99180 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
99181 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
99182 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
99183 +spi_async_46857 spi_async 0 46857 NULL
99184 +vsnprintf_46863 vsnprintf 0 46863 NULL
99185 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
99186 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
99187 +rvmalloc_46873 rvmalloc 1 46873 NULL
99188 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
99189 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
99190 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
99191 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
99192 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
99193 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
99194 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
99195 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
99196 +fb_write_46924 fb_write 3 46924 NULL
99197 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
99198 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
99199 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
99200 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
99201 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
99202 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
99203 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
99204 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
99205 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
99206 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
99207 +__map_single_47020 __map_single 3-4-7 47020 NULL
99208 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
99209 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
99210 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
99211 +fs_path_len_47060 fs_path_len 0 47060 NULL
99212 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
99213 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
99214 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
99215 +mousedev_read_47123 mousedev_read 3 47123 NULL
99216 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
99217 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
99218 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
99219 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
99220 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
99221 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
99222 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
99223 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
99224 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
99225 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
99226 +l2headersize_47238 l2headersize 0 47238 NULL
99227 +options_write_47243 options_write 3 47243 NULL
99228 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
99229 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
99230 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
99231 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
99232 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
99233 +vsnprintf_47291 vsnprintf 0 47291 NULL
99234 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
99235 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
99236 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
99237 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
99238 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
99239 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
99240 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
99241 +nametbl_list_47391 nametbl_list 2 47391 NULL
99242 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
99243 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
99244 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
99245 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
99246 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
99247 +vzalloc_47421 vzalloc 1 47421 NULL
99248 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
99249 +__load_mapping_47460 __load_mapping 2 47460 NULL
99250 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
99251 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
99252 +core_sys_select_47494 core_sys_select 1 47494 NULL
99253 +unlink_simple_47506 unlink_simple 3 47506 NULL
99254 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
99255 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
99256 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
99257 +oz_events_read_47535 oz_events_read 3 47535 NULL
99258 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
99259 +read_ldt_47570 read_ldt 2 47570 NULL
99260 +pci_iomap_47575 pci_iomap 3 47575 NULL
99261 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
99262 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
99263 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
99264 +uea_request_47613 uea_request 4 47613 NULL
99265 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
99266 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
99267 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
99268 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
99269 +save_microcode_47717 save_microcode 3 47717 NULL
99270 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
99271 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
99272 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
99273 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
99274 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
99275 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
99276 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
99277 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
99278 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
99279 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
99280 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
99281 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
99282 +vhci_read_47878 vhci_read 3 47878 NULL
99283 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
99284 +load_mapping_47904 load_mapping 3 47904 NULL
99285 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
99286 +comedi_write_47926 comedi_write 3 47926 NULL
99287 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
99288 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
99289 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
99290 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
99291 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
99292 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
99293 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
99294 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
99295 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
99296 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
99297 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
99298 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
99299 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
99300 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
99301 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
99302 +set_discoverable_48141 set_discoverable 4 48141 NULL
99303 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
99304 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
99305 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
99306 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
99307 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
99308 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
99309 +init_ipath_48187 init_ipath 1 48187 NULL
99310 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
99311 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
99312 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
99313 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
99314 +read_file_recv_48232 read_file_recv 3 48232 NULL
99315 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
99316 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
99317 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
99318 +send_set_info_48288 send_set_info 7 48288 NULL
99319 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
99320 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
99321 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
99322 +hash_setkey_48310 hash_setkey 3 48310 NULL
99323 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
99324 +skb_add_data_48363 skb_add_data 3 48363 NULL
99325 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
99326 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
99327 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
99328 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
99329 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
99330 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
99331 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
99332 +send_control_msg_48498 send_control_msg 6 48498 NULL
99333 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
99334 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
99335 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
99336 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
99337 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
99338 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
99339 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
99340 +named_distribute_48544 named_distribute 4 48544 NULL
99341 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
99342 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
99343 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
99344 +mtd_read_48655 mtd_read 0 48655 NULL
99345 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
99346 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
99347 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
99348 +altera_drscan_48698 altera_drscan 2 48698 NULL
99349 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
99350 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
99351 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
99352 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
99353 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
99354 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
99355 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
99356 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
99357 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
99358 +azx_get_position_48841 azx_get_position 0 48841 NULL
99359 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
99360 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
99361 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
99362 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
99363 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
99364 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
99365 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
99366 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
99367 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
99368 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
99369 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
99370 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
99371 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
99372 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
99373 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
99374 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
99375 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
99376 +transient_status_49027 transient_status 4 49027 NULL
99377 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
99378 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
99379 +ubi_read_49061 ubi_read 0 49061 NULL
99380 +scsi_register_49094 scsi_register 2 49094 NULL
99381 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
99382 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
99383 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
99384 +pt_read_49136 pt_read 3 49136 NULL
99385 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
99386 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
99387 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
99388 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
99389 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
99390 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
99391 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
99392 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
99393 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
99394 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
99395 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
99396 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
99397 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
99398 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
99399 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
99400 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
99401 +uio_read_49300 uio_read 3 49300 NULL
99402 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
99403 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
99404 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
99405 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
99406 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
99407 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
99408 +px_raw_event_49371 px_raw_event 4 49371 NULL
99409 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
99410 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
99411 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
99412 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
99413 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
99414 +md_domain_init_49432 md_domain_init 2 49432 NULL
99415 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
99416 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
99417 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
99418 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
99419 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
99420 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
99421 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
99422 +smk_write_access_49561 smk_write_access 3 49561 NULL
99423 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
99424 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
99425 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
99426 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
99427 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
99428 +heap_init_49617 heap_init 2 49617 NULL
99429 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
99430 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
99431 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
99432 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
99433 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
99434 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
99435 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
99436 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
99437 +check_frame_49741 check_frame 0 49741 NULL
99438 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
99439 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
99440 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
99441 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
99442 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
99443 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
99444 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
99445 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
99446 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
99447 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
99448 +add_uuid_49831 add_uuid 4 49831 NULL
99449 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
99450 +twl4030_write_49846 twl4030_write 2 49846 NULL
99451 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
99452 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
99453 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
99454 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
99455 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
99456 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
99457 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
99458 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
99459 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
99460 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
99461 +__module_alloc_50004 __module_alloc 1 50004 NULL
99462 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
99463 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
99464 +isdn_read_50021 isdn_read 3 50021 NULL
99465 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
99466 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
99467 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
99468 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
99469 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
99470 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
99471 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
99472 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
99473 +read_file_slot_50111 read_file_slot 3 50111 NULL
99474 +copy_items_50140 copy_items 6 50140 NULL
99475 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
99476 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
99477 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
99478 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
99479 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
99480 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
99481 +odev_update_50169 odev_update 2 50169 NULL
99482 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
99483 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
99484 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
99485 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
99486 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
99487 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
99488 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
99489 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
99490 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
99491 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
99492 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
99493 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
99494 +do_launder_page_50329 do_launder_page 0 50329 NULL
99495 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
99496 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
99497 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
99498 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
99499 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
99500 +tpm_read_50344 tpm_read 3 50344 NULL
99501 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
99502 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
99503 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
99504 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
99505 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
99506 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
99507 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
99508 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
99509 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
99510 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
99511 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
99512 +force_mapping_50464 force_mapping 2 50464 NULL
99513 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
99514 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
99515 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
99516 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
99517 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
99518 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
99519 +fat_readpages_50582 fat_readpages 4 50582 NULL
99520 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
99521 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
99522 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
99523 +__ffs_50625 __ffs 0 50625 NULL
99524 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
99525 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
99526 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
99527 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
99528 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
99529 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
99530 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
99531 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
99532 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
99533 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
99534 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
99535 +skb_padto_50759 skb_padto 2 50759 NULL
99536 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
99537 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
99538 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
99539 +tpm_write_50798 tpm_write 3 50798 NULL
99540 +write_flush_50803 write_flush 3 50803 NULL
99541 +dvb_play_50814 dvb_play 3 50814 NULL
99542 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
99543 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
99544 +SetArea_50835 SetArea 4 50835 NULL nohasharray
99545 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
99546 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
99547 +self_check_write_50856 self_check_write 5 50856 NULL
99548 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
99549 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
99550 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
99551 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
99552 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
99553 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
99554 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
99555 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
99556 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
99557 +timeout_write_50991 timeout_write 3 50991 NULL
99558 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
99559 +proc_write_51003 proc_write 3 51003 NULL
99560 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
99561 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
99562 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
99563 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
99564 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
99565 +dump_midi_51040 dump_midi 3 51040 NULL
99566 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
99567 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
99568 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
99569 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
99570 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
99571 +ti_recv_51110 ti_recv 3 51110 NULL
99572 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
99573 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
99574 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
99575 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
99576 +set_dirty_51144 set_dirty 3 51144 NULL
99577 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
99578 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
99579 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
99580 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
99581 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
99582 +tipc_send_51238 tipc_send 4 51238 NULL
99583 +drm_property_create_51239 drm_property_create 4 51239 NULL
99584 +st_read_51251 st_read 3 51251 NULL
99585 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
99586 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
99587 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
99588 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
99589 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
99590 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
99591 +get_cell_51316 get_cell 2 51316 NULL
99592 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
99593 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
99594 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
99595 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
99596 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
99597 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
99598 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
99599 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
99600 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
99601 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
99602 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
99603 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
99604 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
99605 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
99606 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
99607 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
99608 +vaddr_51480 vaddr 0 51480 NULL
99609 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
99610 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
99611 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
99612 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
99613 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
99614 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
99615 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
99616 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
99617 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
99618 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
99619 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
99620 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
99621 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
99622 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
99623 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
99624 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
99625 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
99626 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
99627 +sel_write_access_51704 sel_write_access 3 51704 NULL
99628 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
99629 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
99630 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
99631 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
99632 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
99633 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
99634 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
99635 +if_write_51756 if_write 3 51756 NULL
99636 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
99637 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
99638 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
99639 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
99640 +ioread32_51847 ioread32 0 51847 NULL nohasharray
99641 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
99642 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
99643 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
99644 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
99645 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
99646 +user_read_51881 user_read 3 51881 NULL
99647 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
99648 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
99649 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
99650 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
99651 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
99652 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
99653 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
99654 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
99655 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
99656 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
99657 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
99658 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
99659 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
99660 +rdmalt_52022 rdmalt 0 52022 NULL
99661 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
99662 +override_release_52032 override_release 2 52032 NULL
99663 +end_port_52042 end_port 0 52042 NULL
99664 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
99665 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
99666 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
99667 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
99668 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
99669 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
99670 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
99671 +retry_count_read_52129 retry_count_read 3 52129 NULL
99672 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
99673 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
99674 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
99675 +htable_size_52148 htable_size 0-1 52148 NULL
99676 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
99677 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
99678 +alix_present_52165 alix_present 1 52165 NULL
99679 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
99680 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
99681 +print_prefix_52176 print_prefix 0 52176 NULL
99682 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
99683 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
99684 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
99685 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
99686 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
99687 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
99688 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
99689 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
99690 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
99691 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
99692 +read_file_reset_52310 read_file_reset 3 52310 NULL
99693 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
99694 +hwflags_read_52318 hwflags_read 3 52318 NULL
99695 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
99696 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
99697 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
99698 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
99699 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
99700 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
99701 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
99702 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
99703 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
99704 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
99705 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
99706 +delay_status_52431 delay_status 5 52431 NULL
99707 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
99708 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
99709 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
99710 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
99711 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
99712 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
99713 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
99714 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
99715 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
99716 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
99717 +from_oblock_52546 from_oblock 0-1 52546 NULL
99718 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
99719 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
99720 +emit_code_52583 emit_code 0-3 52583 NULL
99721 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
99722 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
99723 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
99724 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
99725 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
99726 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
99727 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
99728 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
99729 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
99730 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
99731 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
99732 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
99733 +twlreg_write_52880 twlreg_write 3 52880 NULL
99734 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
99735 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
99736 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
99737 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
99738 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
99739 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
99740 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
99741 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
99742 +send_packet_52960 send_packet 4 52960 NULL
99743 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
99744 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
99745 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
99746 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
99747 +num_node_state_52989 num_node_state 0 52989 NULL
99748 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
99749 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
99750 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
99751 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
99752 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
99753 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
99754 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
99755 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
99756 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
99757 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
99758 +verity_status_53120 verity_status 5 53120 NULL
99759 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
99760 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
99761 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
99762 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
99763 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
99764 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
99765 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
99766 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
99767 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
99768 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
99769 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
99770 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
99771 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
99772 +vm_mmap_53339 vm_mmap 0 53339 NULL
99773 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
99774 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
99775 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
99776 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
99777 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
99778 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
99779 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
99780 +n2_run_53459 n2_run 3 53459 NULL
99781 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
99782 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
99783 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
99784 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
99785 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
99786 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
99787 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
99788 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
99789 +check_acl_53512 check_acl 0 53512 NULL
99790 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
99791 +set_registers_53582 set_registers 3 53582 NULL
99792 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
99793 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
99794 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
99795 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
99796 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
99797 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
99798 +_preload_range_53676 _preload_range 2-3 53676 NULL
99799 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
99800 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
99801 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
99802 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
99803 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
99804 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
99805 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
99806 +wdm_write_53735 wdm_write 3 53735 NULL
99807 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
99808 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
99809 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
99810 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
99811 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
99812 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
99813 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
99814 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
99815 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
99816 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
99817 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
99818 +pms_read_53873 pms_read 3 53873 NULL
99819 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
99820 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
99821 +proc_file_read_53905 proc_file_read 3 53905 NULL
99822 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
99823 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
99824 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
99825 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
99826 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
99827 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
99828 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
99829 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
99830 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
99831 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
99832 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
99833 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
99834 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
99835 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
99836 +_malloc_54077 _malloc 1 54077 NULL
99837 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
99838 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
99839 +create_xattr_54106 create_xattr 5 54106 NULL
99840 +strn_len_54122 strn_len 0 54122 NULL
99841 +isku_receive_54130 isku_receive 4 54130 NULL
99842 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
99843 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
99844 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
99845 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
99846 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
99847 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
99848 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
99849 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
99850 +reada_add_block_54247 reada_add_block 2 54247 NULL
99851 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
99852 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
99853 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
99854 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
99855 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
99856 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
99857 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
99858 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
99859 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
99860 +sprintf_54306 sprintf 0 54306 NULL
99861 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
99862 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
99863 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
99864 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
99865 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
99866 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
99867 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
99868 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
99869 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
99870 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
99871 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
99872 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
99873 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
99874 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
99875 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
99876 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
99877 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
99878 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
99879 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
99880 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
99881 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
99882 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
99883 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
99884 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
99885 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
99886 +viacam_read_54526 viacam_read 3 54526 NULL
99887 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
99888 +setsockopt_54539 setsockopt 5 54539 NULL
99889 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
99890 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
99891 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
99892 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
99893 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
99894 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
99895 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
99896 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
99897 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
99898 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
99899 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
99900 +evm_read_key_54674 evm_read_key 3 54674 NULL
99901 +resource_string_54699 resource_string 0 54699 NULL
99902 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
99903 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
99904 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
99905 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
99906 +kzalloc_54740 kzalloc 1 54740 NULL
99907 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
99908 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
99909 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
99910 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
99911 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
99912 +domain_init_54797 domain_init 2 54797 NULL
99913 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
99914 +get_dev_size_54807 get_dev_size 0 54807 NULL
99915 +nfsd_write_54809 nfsd_write 6 54809 NULL
99916 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
99917 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
99918 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
99919 +write_rio_54837 write_rio 3 54837 NULL
99920 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
99921 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
99922 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
99923 +printer_read_54851 printer_read 3 54851 NULL
99924 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
99925 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
99926 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
99927 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
99928 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
99929 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
99930 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
99931 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
99932 +add_port_54941 add_port 2 54941 NULL
99933 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
99934 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
99935 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
99936 +c4_add_card_54968 c4_add_card 3 54968 NULL
99937 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
99938 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
99939 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
99940 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
99941 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
99942 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
99943 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
99944 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
99945 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
99946 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
99947 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
99948 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
99949 +corrupt_data_55120 corrupt_data 0 55120 NULL
99950 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
99951 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
99952 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
99953 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
99954 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
99955 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
99956 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
99957 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
99958 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
99959 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
99960 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
99961 +dump_command_55220 dump_command 1 55220 NULL
99962 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
99963 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
99964 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
99965 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
99966 +ptrace_request_55288 ptrace_request 3 55288 NULL
99967 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
99968 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
99969 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
99970 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
99971 +do_shmat_55336 do_shmat 5 55336 NULL
99972 +vme_user_read_55338 vme_user_read 3 55338 NULL
99973 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
99974 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
99975 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
99976 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
99977 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
99978 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
99979 +alloc_skb_55439 alloc_skb 1 55439 NULL
99980 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
99981 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
99982 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
99983 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
99984 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
99985 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
99986 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
99987 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
99988 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
99989 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
99990 +ea_get_55522 ea_get 0 55522 NULL
99991 +buffer_size_55534 buffer_size 0 55534 NULL
99992 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
99993 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
99994 +add_partition_55588 add_partition 2 55588 NULL
99995 +free_pages_55603 free_pages 1 55603 NULL
99996 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
99997 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
99998 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
99999 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
100000 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
100001 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
100002 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
100003 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
100004 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
100005 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
100006 +read_oldmem_55658 read_oldmem 3 55658 NULL
100007 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
100008 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
100009 +get_info_55681 get_info 3 55681 NULL
100010 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
100011 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
100012 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
100013 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
100014 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
100015 +set_local_name_55757 set_local_name 4 55757 NULL
100016 +strlen_55778 strlen 0 55778 NULL
100017 +set_spte_55783 set_spte 5-4 55783 NULL
100018 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
100019 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
100020 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
100021 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
100022 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
100023 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
100024 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
100025 +hsc_write_55875 hsc_write 3 55875 NULL
100026 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
100027 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
100028 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
100029 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
100030 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
100031 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
100032 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
100033 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
100034 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
100035 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
100036 +__set_discard_56081 __set_discard 2 56081 NULL
100037 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
100038 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
100039 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
100040 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
100041 +map_addr_56144 map_addr 7 56144 NULL
100042 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
100043 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
100044 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
100045 +skb_headroom_56200 skb_headroom 0 56200 NULL
100046 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
100047 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
100048 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
100049 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
100050 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
100051 +fd_copyin_56247 fd_copyin 3 56247 NULL
100052 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
100053 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
100054 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
100055 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
100056 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
100057 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
100058 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
100059 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
100060 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
100061 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
100062 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
100063 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
100064 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
100065 +dev_read_56369 dev_read 3 56369 NULL
100066 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
100067 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
100068 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
100069 +store_msg_56417 store_msg 3 56417 NULL
100070 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
100071 +fl_create_56435 fl_create 5 56435 NULL
100072 +gnttab_map_56439 gnttab_map 2 56439 NULL
100073 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
100074 +set_connectable_56458 set_connectable 4 56458 NULL
100075 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
100076 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
100077 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
100078 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
100079 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
100080 +ip_options_get_56538 ip_options_get 4 56538 NULL
100081 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
100082 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
100083 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
100084 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
100085 +event_filter_write_56609 event_filter_write 3 56609 NULL
100086 +gather_array_56641 gather_array 3 56641 NULL
100087 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
100088 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
100089 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
100090 +build_map_info_56696 build_map_info 2 56696 NULL
100091 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
100092 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
100093 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
100094 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
100095 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
100096 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
100097 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
100098 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
100099 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
100100 +hash_lookup_56792 hash_lookup 2 56792 NULL
100101 +do_syslog_56807 do_syslog 3 56807 NULL
100102 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
100103 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
100104 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
100105 +wb_lookup_56858 wb_lookup 2 56858 NULL
100106 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
100107 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
100108 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
100109 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
100110 +strcspn_56913 strcspn 0 56913 NULL
100111 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
100112 +check_header_56930 check_header 2 56930 NULL
100113 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
100114 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
100115 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
100116 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
100117 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
100118 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
100119 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
100120 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
100121 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
100122 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
100123 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
100124 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
100125 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
100126 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
100127 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
100128 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
100129 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
100130 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
100131 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
100132 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
100133 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
100134 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
100135 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
100136 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
100137 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
100138 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
100139 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
100140 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
100141 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
100142 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
100143 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
100144 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
100145 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
100146 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
100147 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
100148 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
100149 +fw_file_size_57307 fw_file_size 0 57307 NULL
100150 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
100151 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
100152 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
100153 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
100154 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
100155 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
100156 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
100157 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
100158 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
100159 +read_file_blob_57406 read_file_blob 3 57406 NULL
100160 +enclosure_register_57412 enclosure_register 3 57412 NULL
100161 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
100162 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
100163 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
100164 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
100165 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
100166 +ReadReg_57453 ReadReg 0 57453 NULL
100167 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
100168 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
100169 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
100170 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
100171 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
100172 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
100173 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
100174 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
100175 +skb_headlen_57501 skb_headlen 0 57501 NULL
100176 +copy_in_user_57502 copy_in_user 3 57502 NULL
100177 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
100178 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
100179 +init_tag_map_57515 init_tag_map 3 57515 NULL
100180 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
100181 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
100182 +inode_permission_57531 inode_permission 0 57531 NULL
100183 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
100184 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
100185 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
100186 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
100187 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
100188 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
100189 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
100190 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
100191 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
100192 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
100193 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
100194 +mem_read_57631 mem_read 3 57631 NULL
100195 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
100196 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
100197 +r3964_write_57662 r3964_write 4 57662 NULL
100198 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
100199 +__lgwrite_57669 __lgwrite 4 57669 NULL
100200 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
100201 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
100202 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
100203 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
100204 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
100205 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
100206 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
100207 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
100208 +ld2_57794 ld2 0 57794 NULL
100209 +ivtv_read_57796 ivtv_read 3 57796 NULL
100210 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
100211 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
100212 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
100213 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
100214 +copy_to_user_57835 copy_to_user 3 57835 NULL
100215 +flash_read_57843 flash_read 3 57843 NULL
100216 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
100217 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
100218 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
100219 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
100220 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
100221 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
100222 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
100223 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
100224 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
100225 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
100226 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
100227 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
100228 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
100229 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
100230 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
100231 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
100232 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
100233 +mce_async_out_58056 mce_async_out 3 58056 NULL
100234 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
100235 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
100236 +cm4040_write_58079 cm4040_write 3 58079 NULL
100237 +udi_log_event_58105 udi_log_event 3 58105 NULL
100238 +savemem_58129 savemem 3 58129 NULL
100239 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
100240 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
100241 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
100242 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
100243 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
100244 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
100245 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
100246 +read_file_debug_58256 read_file_debug 3 58256 NULL
100247 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
100248 +profile_load_58267 profile_load 3 58267 NULL
100249 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
100250 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
100251 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
100252 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
100253 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
100254 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
100255 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
100256 +next_pidmap_58347 next_pidmap 2 58347 NULL
100257 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
100258 +save_hint_58359 save_hint 2 58359 NULL
100259 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
100260 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
100261 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
100262 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
100263 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
100264 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
100265 +capabilities_read_58457 capabilities_read 3 58457 NULL
100266 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
100267 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
100268 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
100269 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
100270 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
100271 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
100272 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
100273 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
100274 +__clear_discard_58546 __clear_discard 2 58546 NULL
100275 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
100276 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
100277 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
100278 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
100279 +xip_file_read_58592 xip_file_read 3 58592 NULL
100280 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
100281 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
100282 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
100283 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
100284 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
100285 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
100286 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
100287 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
100288 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
100289 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
100290 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
100291 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
100292 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
100293 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
100294 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
100295 +acpi_map_58725 acpi_map 1-2 58725 NULL
100296 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
100297 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
100298 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
100299 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
100300 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
100301 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
100302 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
100303 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
100304 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
100305 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
100306 +ep_read_58813 ep_read 3 58813 NULL
100307 +command_write_58841 command_write 3 58841 NULL
100308 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
100309 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
100310 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
100311 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
100312 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
100313 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
100314 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
100315 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
100316 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
100317 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
100318 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
100319 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
100320 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
100321 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
100322 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
100323 +ep_write_59008 ep_write 3 59008 NULL
100324 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
100325 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
100326 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
100327 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
100328 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
100329 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
100330 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
100331 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
100332 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
100333 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
100334 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
100335 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
100336 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
100337 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
100338 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
100339 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
100340 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
100341 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
100342 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
100343 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
100344 +dt3155_read_59226 dt3155_read 3 59226 NULL
100345 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
100346 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
100347 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
100348 +nla_len_59258 nla_len 0 59258 NULL
100349 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
100350 +fd_copyout_59323 fd_copyout 3 59323 NULL
100351 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
100352 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
100353 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
100354 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
100355 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
100356 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
100357 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
100358 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
100359 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
100360 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
100361 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
100362 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
100363 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
100364 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
100365 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
100366 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
100367 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
100368 +tunables_write_59563 tunables_write 3 59563 NULL
100369 +memdup_user_59590 memdup_user 2 59590 NULL
100370 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
100371 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
100372 +mtrr_write_59622 mtrr_write 3 59622 NULL
100373 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
100374 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
100375 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
100376 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
100377 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
100378 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
100379 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
100380 +sriov_enable_59689 sriov_enable 2 59689 NULL
100381 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
100382 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
100383 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
100384 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
100385 +strnlen_59746 strnlen 0 59746 NULL
100386 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
100387 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
100388 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
100389 +venus_remove_59781 venus_remove 4 59781 NULL
100390 +ipw_write_59807 ipw_write 3 59807 NULL
100391 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
100392 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
100393 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
100394 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
100395 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
100396 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
100397 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
100398 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
100399 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
100400 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
100401 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
100402 +lookup_node_59953 lookup_node 2 59953 NULL
100403 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
100404 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
100405 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
100406 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
100407 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
100408 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
100409 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
100410 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
100411 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
100412 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
100413 +register_device_60015 register_device 2-3 60015 NULL
100414 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
100415 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
100416 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
100417 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
100418 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
100419 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
100420 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
100421 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
100422 +compat_writev_60063 compat_writev 3 60063 NULL
100423 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
100424 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
100425 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
100426 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
100427 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
100428 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
100429 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
100430 +init_state_60165 init_state 2 60165 NULL
100431 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
100432 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
100433 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
100434 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
100435 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
100436 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
100437 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
100438 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
100439 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
100440 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
100441 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
100442 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
100443 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
100444 +printer_write_60276 printer_write 3 60276 NULL
100445 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
100446 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
100447 +getDataLength_60301 getDataLength 0 60301 NULL
100448 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
100449 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
100450 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
100451 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
100452 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
100453 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
100454 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
100455 +driver_names_read_60399 driver_names_read 3 60399 NULL
100456 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
100457 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
100458 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
100459 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
100460 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
100461 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
100462 +rx_data_60442 rx_data 4 60442 NULL
100463 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
100464 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
100465 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
100466 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
100467 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
100468 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
100469 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
100470 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
100471 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
100472 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
100473 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
100474 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
100475 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
100476 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
100477 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
100478 +init_data_container_60709 init_data_container 1 60709 NULL
100479 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
100480 +raid_status_60755 raid_status 5 60755 NULL
100481 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
100482 +opticon_write_60775 opticon_write 4 60775 NULL
100483 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
100484 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
100485 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
100486 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
100487 +generic_writepages_60871 generic_writepages 0 60871 NULL
100488 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
100489 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
100490 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
100491 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
100492 +sys_mlock_60932 sys_mlock 1 60932 NULL
100493 +pti_char_write_60960 pti_char_write 3 60960 NULL
100494 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
100495 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
100496 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
100497 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
100498 +symtab_init_61050 symtab_init 2 61050 NULL
100499 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
100500 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
100501 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
100502 +get_derived_key_61100 get_derived_key 4 61100 NULL
100503 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
100504 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
100505 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
100506 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
100507 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
100508 +__vmalloc_61168 __vmalloc 1 61168 NULL
100509 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
100510 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
100511 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
100512 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
100513 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
100514 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
100515 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
100516 +sys_add_key_61288 sys_add_key 4 61288 NULL
100517 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
100518 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
100519 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
100520 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
100521 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
100522 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
100523 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
100524 +change_xattr_61390 change_xattr 5 61390 NULL
100525 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
100526 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
100527 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
100528 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
100529 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
100530 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
100531 +erst_errno_61526 erst_errno 0 61526 NULL
100532 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
100533 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
100534 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
100535 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
100536 +seq_open_private_61589 seq_open_private 3 61589 NULL
100537 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
100538 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
100539 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
100540 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
100541 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
100542 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
100543 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
100544 +resize_stripes_61650 resize_stripes 2 61650 NULL
100545 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
100546 +insert_one_name_61668 insert_one_name 7 61668 NULL
100547 +lock_loop_61681 lock_loop 1 61681 NULL
100548 +filter_read_61692 filter_read 3 61692 NULL
100549 +iov_length_61716 iov_length 0 61716 NULL
100550 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
100551 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
100552 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
100553 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
100554 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
100555 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
100556 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
100557 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
100558 +get_fw_name_61874 get_fw_name 3 61874 NULL
100559 +free_init_pages_61875 free_init_pages 2 61875 NULL
100560 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
100561 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
100562 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
100563 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
100564 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
100565 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
100566 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
100567 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
100568 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
100569 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
100570 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
100571 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
100572 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
100573 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
100574 +cow_file_range_61979 cow_file_range 3 61979 NULL
100575 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
100576 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
100577 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
100578 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
100579 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
100580 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
100581 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
100582 +do_pselect_62061 do_pselect 1 62061 NULL
100583 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
100584 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
100585 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
100586 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
100587 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
100588 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
100589 +ql_status_62135 ql_status 5 62135 NULL
100590 +video_usercopy_62151 video_usercopy 2 62151 NULL
100591 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
100592 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
100593 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
100594 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
100595 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
100596 +allocate_partition_62245 allocate_partition 4 62245 NULL
100597 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
100598 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
100599 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
100600 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
100601 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
100602 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
100603 +subseq_list_62332 subseq_list 3-0 62332 NULL
100604 +flash_write_62354 flash_write 3 62354 NULL
100605 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
100606 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
100607 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
100608 +altera_irscan_62396 altera_irscan 2 62396 NULL
100609 +set_ssp_62411 set_ssp 4 62411 NULL
100610 +unmap_single_62423 unmap_single 2 62423 NULL
100611 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
100612 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
100613 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
100614 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
100615 +remove_mapping_62491 remove_mapping 2 62491 NULL
100616 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
100617 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
100618 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
100619 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
100620 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
100621 +debugfs_read_62535 debugfs_read 3 62535 NULL
100622 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
100623 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
100624 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
100625 +get_subdir_62581 get_subdir 3 62581 NULL
100626 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
100627 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
100628 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
100629 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
100630 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
100631 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
100632 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
100633 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
100634 +write_62671 write 3 62671 NULL
100635 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
100636 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
100637 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
100638 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
100639 +rdm_62719 rdm 0 62719 NULL
100640 +key_replays_read_62746 key_replays_read 3 62746 NULL
100641 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
100642 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
100643 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
100644 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
100645 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
100646 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
100647 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
100648 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
100649 +set_swbp_62853 set_swbp 3 62853 NULL
100650 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
100651 +aoechr_write_62883 aoechr_write 3 62883 NULL
100652 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
100653 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
100654 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
100655 +getdqbuf_62908 getdqbuf 1 62908 NULL
100656 +try_async_pf_62914 try_async_pf 3 62914 NULL
100657 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
100658 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
100659 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
100660 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
100661 +unlink1_63059 unlink1 3 63059 NULL
100662 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
100663 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
100664 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
100665 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
100666 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
100667 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
100668 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
100669 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
100670 +vme_master_read_63221 vme_master_read 0 63221 NULL
100671 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
100672 +ptp_read_63251 ptp_read 4 63251 NULL
100673 +raid5_resize_63306 raid5_resize 2 63306 NULL
100674 +proc_info_read_63344 proc_info_read 3 63344 NULL
100675 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
100676 +idmouse_read_63374 idmouse_read 3 63374 NULL
100677 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
100678 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
100679 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
100680 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
100681 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
100682 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
100683 +kone_send_63435 kone_send 4 63435 NULL
100684 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
100685 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
100686 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
100687 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
100688 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
100689 +read_kcore_63488 read_kcore 3 63488 NULL
100690 +save_hint_63497 save_hint 2 63497 NULL
100691 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
100692 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
100693 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
100694 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
100695 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
100696 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
100697 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
100698 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
100699 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
100700 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
100701 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
100702 +module_alloc_63630 module_alloc 1 63630 NULL
100703 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
100704 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
100705 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
100706 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
100707 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
100708 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
100709 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
100710 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
100711 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
100712 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
100713 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
100714 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
100715 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
100716 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
100717 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
100718 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
100719 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
100720 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
100721 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
100722 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
100723 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
100724 +sel_write_load_63830 sel_write_load 3 63830 NULL
100725 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
100726 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
100727 +divas_write_63901 divas_write 3 63901 NULL
100728 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
100729 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
100730 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
100731 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
100732 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
100733 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
100734 +__team_options_register_63941 __team_options_register 3 63941 NULL
100735 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
100736 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
100737 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
100738 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
100739 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
100740 +kmemdup_64015 kmemdup 2 64015 NULL
100741 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
100742 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
100743 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
100744 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
100745 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
100746 +get_u8_64076 get_u8 0 64076 NULL
100747 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
100748 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
100749 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
100750 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
100751 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
100752 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
100753 +init_bch_64130 init_bch 1-2 64130 NULL
100754 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
100755 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
100756 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
100757 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
100758 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
100759 +read_pulse_64227 read_pulse 0-3 64227 NULL
100760 +header_len_64232 header_len 0 64232 NULL
100761 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
100762 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
100763 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
100764 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
100765 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
100766 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
100767 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
100768 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
100769 +ffz_64324 ffz 0 64324 NULL
100770 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
100771 +ts_write_64336 ts_write 3 64336 NULL
100772 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
100773 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
100774 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
100775 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
100776 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
100777 +ilo_write_64378 ilo_write 3 64378 NULL
100778 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
100779 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
100780 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
100781 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
100782 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
100783 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
100784 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
100785 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
100786 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
100787 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
100788 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
100789 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
100790 +cap_capable_64462 cap_capable 0 64462 NULL
100791 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
100792 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
100793 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
100794 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
100795 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
100796 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
100797 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
100798 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
100799 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
100800 +__spi_sync_64561 __spi_sync 0 64561 NULL
100801 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
100802 +fanotify_write_64623 fanotify_write 3 64623 NULL
100803 +to_dblock_64655 to_dblock 0-1 64655 NULL
100804 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
100805 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
100806 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
100807 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
100808 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
100809 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
100810 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
100811 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
100812 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
100813 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
100814 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
100815 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
100816 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
100817 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
100818 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
100819 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
100820 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
100821 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
100822 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
100823 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
100824 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
100825 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
100826 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
100827 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
100828 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
100829 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
100830 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
100831 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
100832 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
100833 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
100834 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
100835 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
100836 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
100837 +pskb_pull_65005 pskb_pull 2 65005 NULL
100838 +unifi_write_65012 unifi_write 3 65012 NULL
100839 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
100840 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
100841 +insert_dent_65034 insert_dent 7 65034 NULL
100842 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
100843 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
100844 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
100845 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
100846 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
100847 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
100848 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
100849 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
100850 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
100851 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
100852 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
100853 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
100854 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
100855 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
100856 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
100857 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
100858 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
100859 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
100860 +get_var_len_65304 get_var_len 0 65304 NULL
100861 +unpack_array_65318 unpack_array 0 65318 NULL
100862 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
100863 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
100864 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
100865 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
100866 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
100867 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
100868 +strchr_65372 strchr 0 65372 NULL
100869 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
100870 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
100871 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
100872 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
100873 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
100874 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
100875 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
100876 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
100877 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
100878 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
100879 +alloc_dr_65495 alloc_dr 2 65495 NULL
100880 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
100881 new file mode 100644
100882 index 0000000..9db0d0e
100883 --- /dev/null
100884 +++ b/tools/gcc/size_overflow_plugin.c
100885 @@ -0,0 +1,2114 @@
100886 +/*
100887 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
100888 + * Licensed under the GPL v2, or (at your option) v3
100889 + *
100890 + * Homepage:
100891 + * http://www.grsecurity.net/~ephox/overflow_plugin/
100892 + *
100893 + * Documentation:
100894 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
100895 + *
100896 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
100897 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
100898 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
100899 + *
100900 + * Usage:
100901 + * $ 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
100902 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
100903 + */
100904 +
100905 +#include "gcc-plugin.h"
100906 +#include "config.h"
100907 +#include "system.h"
100908 +#include "coretypes.h"
100909 +#include "tree.h"
100910 +#include "tree-pass.h"
100911 +#include "intl.h"
100912 +#include "plugin-version.h"
100913 +#include "tm.h"
100914 +#include "toplev.h"
100915 +#include "function.h"
100916 +#include "tree-flow.h"
100917 +#include "plugin.h"
100918 +#include "gimple.h"
100919 +#include "diagnostic.h"
100920 +#include "cfgloop.h"
100921 +
100922 +#if BUILDING_GCC_VERSION >= 4008
100923 +#define TODO_dump_func 0
100924 +#endif
100925 +
100926 +struct size_overflow_hash {
100927 + const struct size_overflow_hash * const next;
100928 + const char * const name;
100929 + const unsigned int param;
100930 +};
100931 +
100932 +#include "size_overflow_hash.h"
100933 +
100934 +enum mark {
100935 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
100936 +};
100937 +
100938 +enum err_code_conditions {
100939 + CAST_ONLY, FROM_CONST
100940 +};
100941 +
100942 +static unsigned int call_count = 0;
100943 +
100944 +#define __unused __attribute__((__unused__))
100945 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
100946 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
100947 +#define BEFORE_STMT true
100948 +#define AFTER_STMT false
100949 +#define CREATE_NEW_VAR NULL_TREE
100950 +#define CODES_LIMIT 32
100951 +#define MAX_PARAM 31
100952 +#define MY_STMT GF_PLF_1
100953 +#define NO_CAST_CHECK GF_PLF_2
100954 +#define FROM_ARG true
100955 +#define FROM_RET false
100956 +
100957 +#if BUILDING_GCC_VERSION == 4005
100958 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
100959 +#endif
100960 +
100961 +int plugin_is_GPL_compatible;
100962 +void debug_gimple_stmt(gimple gs);
100963 +
100964 +static tree expand(struct pointer_set_t *visited, tree lhs);
100965 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
100966 +static tree report_size_overflow_decl;
100967 +static const_tree const_char_ptr_type_node;
100968 +static unsigned int handle_function(void);
100969 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
100970 +static tree get_size_overflow_type(gimple stmt, const_tree node);
100971 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
100972 +static void print_missing_msg(tree func, unsigned int argnum);
100973 +
100974 +static struct plugin_info size_overflow_plugin_info = {
100975 + .version = "20130410beta",
100976 + .help = "no-size-overflow\tturn off size overflow checking\n",
100977 +};
100978 +
100979 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
100980 +{
100981 + unsigned int arg_count;
100982 + enum tree_code code = TREE_CODE(*node);
100983 +
100984 + switch (code) {
100985 + case FUNCTION_DECL:
100986 + arg_count = type_num_arguments(TREE_TYPE(*node));
100987 + break;
100988 + case FUNCTION_TYPE:
100989 + case METHOD_TYPE:
100990 + arg_count = type_num_arguments(*node);
100991 + break;
100992 + default:
100993 + *no_add_attrs = true;
100994 + error("%s: %qE attribute only applies to functions", __func__, name);
100995 + return NULL_TREE;
100996 + }
100997 +
100998 + for (; args; args = TREE_CHAIN(args)) {
100999 + tree position = TREE_VALUE(args);
101000 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101001 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101002 + *no_add_attrs = true;
101003 + }
101004 + }
101005 + return NULL_TREE;
101006 +}
101007 +
101008 +static const char* get_asm_name(tree node)
101009 +{
101010 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
101011 +}
101012 +
101013 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101014 +{
101015 + unsigned int arg_count, arg_num;
101016 + enum tree_code code = TREE_CODE(*node);
101017 +
101018 + switch (code) {
101019 + case FUNCTION_DECL:
101020 + arg_count = type_num_arguments(TREE_TYPE(*node));
101021 + break;
101022 + case FUNCTION_TYPE:
101023 + case METHOD_TYPE:
101024 + arg_count = type_num_arguments(*node);
101025 + break;
101026 + case FIELD_DECL:
101027 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
101028 + if (arg_num != 0) {
101029 + *no_add_attrs = true;
101030 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
101031 + }
101032 + return NULL_TREE;
101033 + default:
101034 + *no_add_attrs = true;
101035 + error("%qE attribute only applies to functions", name);
101036 + return NULL_TREE;
101037 + }
101038 +
101039 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
101040 + return NULL_TREE;
101041 +
101042 + for (; args; args = TREE_CHAIN(args)) {
101043 + tree position = TREE_VALUE(args);
101044 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101045 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101046 + *no_add_attrs = true;
101047 + }
101048 + }
101049 + return NULL_TREE;
101050 +}
101051 +
101052 +static struct attribute_spec size_overflow_attr = {
101053 + .name = "size_overflow",
101054 + .min_length = 1,
101055 + .max_length = -1,
101056 + .decl_required = true,
101057 + .type_required = false,
101058 + .function_type_required = false,
101059 + .handler = handle_size_overflow_attribute,
101060 +#if BUILDING_GCC_VERSION >= 4007
101061 + .affects_type_identity = false
101062 +#endif
101063 +};
101064 +
101065 +static struct attribute_spec intentional_overflow_attr = {
101066 + .name = "intentional_overflow",
101067 + .min_length = 1,
101068 + .max_length = -1,
101069 + .decl_required = true,
101070 + .type_required = false,
101071 + .function_type_required = false,
101072 + .handler = handle_intentional_overflow_attribute,
101073 +#if BUILDING_GCC_VERSION >= 4007
101074 + .affects_type_identity = false
101075 +#endif
101076 +};
101077 +
101078 +static void register_attributes(void __unused *event_data, void __unused *data)
101079 +{
101080 + register_attribute(&size_overflow_attr);
101081 + register_attribute(&intentional_overflow_attr);
101082 +}
101083 +
101084 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
101085 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
101086 +{
101087 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
101088 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
101089 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
101090 +
101091 + unsigned int m = 0x57559429;
101092 + unsigned int n = 0x5052acdb;
101093 + const unsigned int *key4 = (const unsigned int *)key;
101094 + unsigned int h = len;
101095 + unsigned int k = len + seed + n;
101096 + unsigned long long p;
101097 +
101098 + while (len >= 8) {
101099 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
101100 + len -= 8;
101101 + }
101102 + if (len >= 4) {
101103 + cwmixb(key4[0]) key4 += 1;
101104 + len -= 4;
101105 + }
101106 + if (len)
101107 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
101108 + cwmixb(h ^ (k + n));
101109 + return k ^ h;
101110 +
101111 +#undef cwfold
101112 +#undef cwmixa
101113 +#undef cwmixb
101114 +}
101115 +
101116 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
101117 +{
101118 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
101119 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
101120 + return fn ^ codes;
101121 +}
101122 +
101123 +static inline tree get_original_function_decl(tree fndecl)
101124 +{
101125 + if (DECL_ABSTRACT_ORIGIN(fndecl))
101126 + return DECL_ABSTRACT_ORIGIN(fndecl);
101127 + return fndecl;
101128 +}
101129 +
101130 +static inline gimple get_def_stmt(const_tree node)
101131 +{
101132 + gcc_assert(node != NULL_TREE);
101133 + if (TREE_CODE(node) != SSA_NAME)
101134 + return NULL;
101135 + return SSA_NAME_DEF_STMT(node);
101136 +}
101137 +
101138 +static unsigned char get_tree_code(const_tree type)
101139 +{
101140 + switch (TREE_CODE(type)) {
101141 + case ARRAY_TYPE:
101142 + return 0;
101143 + case BOOLEAN_TYPE:
101144 + return 1;
101145 + case ENUMERAL_TYPE:
101146 + return 2;
101147 + case FUNCTION_TYPE:
101148 + return 3;
101149 + case INTEGER_TYPE:
101150 + return 4;
101151 + case POINTER_TYPE:
101152 + return 5;
101153 + case RECORD_TYPE:
101154 + return 6;
101155 + case UNION_TYPE:
101156 + return 7;
101157 + case VOID_TYPE:
101158 + return 8;
101159 + case REAL_TYPE:
101160 + return 9;
101161 + case VECTOR_TYPE:
101162 + return 10;
101163 + case REFERENCE_TYPE:
101164 + return 11;
101165 + case OFFSET_TYPE:
101166 + return 12;
101167 + case COMPLEX_TYPE:
101168 + return 13;
101169 + default:
101170 + debug_tree((tree)type);
101171 + gcc_unreachable();
101172 + }
101173 +}
101174 +
101175 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
101176 +{
101177 + gcc_assert(type != NULL_TREE);
101178 +
101179 + while (type && len < CODES_LIMIT) {
101180 + tree_codes[len] = get_tree_code(type);
101181 + len++;
101182 + type = TREE_TYPE(type);
101183 + }
101184 + return len;
101185 +}
101186 +
101187 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
101188 +{
101189 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
101190 + enum tree_code code = TREE_CODE(type);
101191 + size_t len = 0;
101192 +
101193 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
101194 +
101195 + arg = TYPE_ARG_TYPES(type);
101196 + // skip builtins __builtin_constant_p
101197 + if (!arg && DECL_BUILT_IN(fndecl))
101198 + return 0;
101199 +
101200 + if (TREE_CODE_CLASS(code) == tcc_type)
101201 + result = type;
101202 + else
101203 + result = DECL_RESULT(fndecl);
101204 +
101205 + gcc_assert(result != NULL_TREE);
101206 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
101207 +
101208 + if (arg == NULL_TREE) {
101209 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
101210 + arg_field = DECL_ARGUMENT_FLD(fndecl);
101211 + if (arg_field == NULL_TREE)
101212 + return 0;
101213 + arg = TREE_TYPE(arg_field);
101214 + len = add_type_codes(arg, tree_codes, len);
101215 + gcc_assert(len != 0);
101216 + return len;
101217 + }
101218 +
101219 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
101220 + while (arg && len < CODES_LIMIT) {
101221 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
101222 + arg = TREE_CHAIN(arg);
101223 + }
101224 +
101225 + gcc_assert(len != 0);
101226 + return len;
101227 +}
101228 +
101229 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
101230 +{
101231 + unsigned int hash;
101232 + const struct size_overflow_hash *entry;
101233 + unsigned char tree_codes[CODES_LIMIT];
101234 + size_t len;
101235 + const char *func_name;
101236 +
101237 + fndecl = get_original_function_decl(fndecl);
101238 + len = get_function_decl(fndecl, tree_codes);
101239 + if (len == 0)
101240 + return NULL;
101241 +
101242 + func_name = get_asm_name(fndecl);
101243 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
101244 +
101245 + entry = size_overflow_hash[hash];
101246 + while (entry) {
101247 + if (!strcmp(entry->name, func_name))
101248 + return entry;
101249 + entry = entry->next;
101250 + }
101251 +
101252 + return NULL;
101253 +}
101254 +
101255 +static bool is_bool(const_tree node)
101256 +{
101257 + const_tree type;
101258 +
101259 + if (node == NULL_TREE)
101260 + return false;
101261 +
101262 + type = TREE_TYPE(node);
101263 + if (!INTEGRAL_TYPE_P(type))
101264 + return false;
101265 + if (TREE_CODE(type) == BOOLEAN_TYPE)
101266 + return true;
101267 + if (TYPE_PRECISION(type) == 1)
101268 + return true;
101269 + return false;
101270 +}
101271 +
101272 +static bool skip_types(const_tree var)
101273 +{
101274 + tree type;
101275 +
101276 + if (is_gimple_constant(var))
101277 + return true;
101278 +
101279 + switch (TREE_CODE(var)) {
101280 + case ADDR_EXPR:
101281 +#if BUILDING_GCC_VERSION >= 4006
101282 + case MEM_REF:
101283 +#endif
101284 + case ARRAY_REF:
101285 + case BIT_FIELD_REF:
101286 + case INDIRECT_REF:
101287 + case TARGET_MEM_REF:
101288 + return true;
101289 + case PARM_DECL:
101290 + case VAR_DECL:
101291 + case COMPONENT_REF:
101292 + return false;
101293 + default:
101294 + break;
101295 + }
101296 +
101297 + gcc_assert(TREE_CODE(var) == SSA_NAME);
101298 +
101299 + type = TREE_TYPE(var);
101300 + switch (TREE_CODE(type)) {
101301 + case INTEGER_TYPE:
101302 + case ENUMERAL_TYPE:
101303 + return false;
101304 + case BOOLEAN_TYPE:
101305 + return is_bool(var);
101306 + default:
101307 + break;
101308 + }
101309 +
101310 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
101311 +
101312 + type = TREE_TYPE(type);
101313 + gcc_assert(type != NULL_TREE);
101314 + switch (TREE_CODE(type)) {
101315 + case RECORD_TYPE:
101316 + case POINTER_TYPE:
101317 + case ARRAY_TYPE:
101318 + return true;
101319 + case VOID_TYPE:
101320 + case INTEGER_TYPE:
101321 + case UNION_TYPE:
101322 + return false;
101323 + default:
101324 + break;
101325 + }
101326 +
101327 + debug_tree((tree)var);
101328 + gcc_unreachable();
101329 +}
101330 +
101331 +static unsigned int find_arg_number(const_tree arg, tree func)
101332 +{
101333 + tree var;
101334 + unsigned int argnum = 1;
101335 +
101336 + if (TREE_CODE(arg) == SSA_NAME)
101337 + arg = SSA_NAME_VAR(arg);
101338 +
101339 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
101340 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
101341 + continue;
101342 + if (!skip_types(var))
101343 + return argnum;
101344 + }
101345 +
101346 + return 0;
101347 +}
101348 +
101349 +static tree create_new_var(tree type)
101350 +{
101351 + tree new_var = create_tmp_var(type, "cicus");
101352 +
101353 +#if BUILDING_GCC_VERSION <= 4007
101354 + add_referenced_var(new_var);
101355 + mark_sym_for_renaming(new_var);
101356 +#endif
101357 + return new_var;
101358 +}
101359 +
101360 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
101361 +{
101362 + gimple assign;
101363 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101364 + tree type = TREE_TYPE(rhs1);
101365 + tree lhs = create_new_var(type);
101366 +
101367 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
101368 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
101369 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101370 +
101371 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101372 + update_stmt(assign);
101373 + gimple_set_plf(assign, MY_STMT, true);
101374 + return assign;
101375 +}
101376 +
101377 +static tree cast_a_tree(tree type, tree var)
101378 +{
101379 + gcc_assert(type != NULL_TREE);
101380 + gcc_assert(var != NULL_TREE);
101381 + gcc_assert(fold_convertible_p(type, var));
101382 +
101383 + return fold_convert(type, var);
101384 +}
101385 +
101386 +static tree get_lhs(const_gimple stmt)
101387 +{
101388 + switch (gimple_code(stmt)) {
101389 + case GIMPLE_ASSIGN:
101390 + return gimple_get_lhs(stmt);
101391 + case GIMPLE_PHI:
101392 + return gimple_phi_result(stmt);
101393 + case GIMPLE_CALL:
101394 + return gimple_call_lhs(stmt);
101395 + default:
101396 + return NULL_TREE;
101397 + }
101398 +}
101399 +
101400 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
101401 +{
101402 + const_gimple def_stmt = get_def_stmt(rhs);
101403 +
101404 + if (force)
101405 + return false;
101406 +
101407 + if (is_gimple_constant(rhs))
101408 + return false;
101409 +
101410 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101411 + return false;
101412 +
101413 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
101414 + return false;
101415 +
101416 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
101417 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101418 + return false;
101419 +
101420 + return true;
101421 +}
101422 +
101423 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
101424 +{
101425 + gimple assign, def_stmt;
101426 +
101427 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
101428 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
101429 + gcc_unreachable();
101430 +
101431 + def_stmt = get_def_stmt(rhs);
101432 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
101433 + return def_stmt;
101434 +
101435 + if (lhs == CREATE_NEW_VAR)
101436 + lhs = create_new_var(dst_type);
101437 +
101438 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
101439 +
101440 + if (!gsi_end_p(*gsi)) {
101441 + location_t loc = gimple_location(gsi_stmt(*gsi));
101442 + gimple_set_location(assign, loc);
101443 + }
101444 +
101445 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101446 +
101447 + if (before)
101448 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
101449 + else
101450 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
101451 + update_stmt(assign);
101452 + gimple_set_plf(assign, MY_STMT, true);
101453 +
101454 + return assign;
101455 +}
101456 +
101457 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
101458 +{
101459 + gimple_stmt_iterator gsi;
101460 + tree lhs;
101461 + const_gimple new_stmt;
101462 +
101463 + if (rhs == NULL_TREE)
101464 + return NULL_TREE;
101465 +
101466 + gsi = gsi_for_stmt(stmt);
101467 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
101468 +
101469 + lhs = get_lhs(new_stmt);
101470 + gcc_assert(lhs != NULL_TREE);
101471 + return lhs;
101472 +}
101473 +
101474 +static tree cast_to_TI_type(gimple stmt, tree node)
101475 +{
101476 + gimple_stmt_iterator gsi;
101477 + gimple cast_stmt;
101478 + tree type = TREE_TYPE(node);
101479 +
101480 + if (types_compatible_p(type, intTI_type_node))
101481 + return node;
101482 +
101483 + gsi = gsi_for_stmt(stmt);
101484 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101485 + return gimple_get_lhs(cast_stmt);
101486 +}
101487 +
101488 +static void check_function_hash(const_gimple stmt)
101489 +{
101490 + tree func;
101491 + const struct size_overflow_hash *hash;
101492 +
101493 + if (gimple_code(stmt) != GIMPLE_CALL)
101494 + return;
101495 +
101496 + func = gimple_call_fndecl(stmt);
101497 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
101498 + if (func == NULL_TREE)
101499 + return;
101500 +
101501 + hash = get_function_hash(func);
101502 + if (!hash)
101503 + print_missing_msg(func, 0);
101504 +}
101505 +
101506 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
101507 +{
101508 + tree lhs, new_lhs;
101509 + gimple_stmt_iterator gsi;
101510 +
101511 + if (rhs1 == NULL_TREE) {
101512 + debug_gimple_stmt(oldstmt);
101513 + error("%s: rhs1 is NULL_TREE", __func__);
101514 + gcc_unreachable();
101515 + }
101516 +
101517 + switch (gimple_code(oldstmt)) {
101518 + case GIMPLE_ASM:
101519 + lhs = rhs1;
101520 + break;
101521 + case GIMPLE_CALL:
101522 + lhs = gimple_call_lhs(oldstmt);
101523 + break;
101524 + case GIMPLE_ASSIGN:
101525 + lhs = gimple_get_lhs(oldstmt);
101526 + break;
101527 + default:
101528 + debug_gimple_stmt(oldstmt);
101529 + gcc_unreachable();
101530 + }
101531 +
101532 + gsi = gsi_for_stmt(oldstmt);
101533 + pointer_set_insert(visited, oldstmt);
101534 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
101535 + basic_block next_bb, cur_bb;
101536 + const_edge e;
101537 +
101538 + gcc_assert(before == false);
101539 + gcc_assert(stmt_can_throw_internal(oldstmt));
101540 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
101541 + gcc_assert(!gsi_end_p(gsi));
101542 +
101543 + cur_bb = gimple_bb(oldstmt);
101544 + next_bb = cur_bb->next_bb;
101545 + e = find_edge(cur_bb, next_bb);
101546 + gcc_assert(e != NULL);
101547 + gcc_assert(e->flags & EDGE_FALLTHRU);
101548 +
101549 + gsi = gsi_after_labels(next_bb);
101550 + gcc_assert(!gsi_end_p(gsi));
101551 +
101552 + before = true;
101553 + oldstmt = gsi_stmt(gsi);
101554 + }
101555 +
101556 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
101557 + return new_lhs;
101558 +}
101559 +
101560 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
101561 +{
101562 + gimple stmt;
101563 + gimple_stmt_iterator gsi;
101564 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
101565 +
101566 + if (gimple_plf(oldstmt, MY_STMT))
101567 + return lhs;
101568 +
101569 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
101570 + rhs1 = gimple_assign_rhs1(oldstmt);
101571 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
101572 + }
101573 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
101574 + rhs2 = gimple_assign_rhs2(oldstmt);
101575 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
101576 + }
101577 +
101578 + stmt = gimple_copy(oldstmt);
101579 + gimple_set_location(stmt, gimple_location(oldstmt));
101580 + gimple_set_plf(stmt, MY_STMT, true);
101581 +
101582 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
101583 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
101584 +
101585 + size_overflow_type = get_size_overflow_type(oldstmt, node);
101586 +
101587 + new_var = create_new_var(size_overflow_type);
101588 + new_var = make_ssa_name(new_var, stmt);
101589 + gimple_set_lhs(stmt, new_var);
101590 +
101591 + if (rhs1 != NULL_TREE)
101592 + gimple_assign_set_rhs1(stmt, rhs1);
101593 +
101594 + if (rhs2 != NULL_TREE)
101595 + gimple_assign_set_rhs2(stmt, rhs2);
101596 +#if BUILDING_GCC_VERSION >= 4007
101597 + if (rhs3 != NULL_TREE)
101598 + gimple_assign_set_rhs3(stmt, rhs3);
101599 +#endif
101600 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
101601 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
101602 +
101603 + gsi = gsi_for_stmt(oldstmt);
101604 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
101605 + update_stmt(stmt);
101606 + pointer_set_insert(visited, oldstmt);
101607 + return gimple_get_lhs(stmt);
101608 +}
101609 +
101610 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
101611 +{
101612 + basic_block first_bb;
101613 + gimple assign;
101614 + gimple_stmt_iterator gsi;
101615 +
101616 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101617 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101618 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
101619 +
101620 + gsi = gsi_start_bb(first_bb);
101621 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101622 + return gimple_get_lhs(assign);
101623 +}
101624 +
101625 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
101626 +{
101627 + gimple_stmt_iterator gsi;
101628 + const_gimple assign;
101629 + gimple def_stmt = get_def_stmt(new_arg);
101630 +
101631 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
101632 + gsi = gsi_after_labels(gimple_bb(def_stmt));
101633 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
101634 + } else {
101635 + gsi = gsi_for_stmt(def_stmt);
101636 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
101637 + }
101638 +
101639 + return gimple_get_lhs(assign);
101640 +}
101641 +
101642 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
101643 +{
101644 + basic_block bb;
101645 + gimple_stmt_iterator gsi;
101646 + const_gimple assign, def_stmt;
101647 +
101648 + def_stmt = get_def_stmt(arg);
101649 + bb = gimple_bb(def_stmt);
101650 + gcc_assert(bb->index != 0);
101651 + gsi = gsi_after_labels(bb);
101652 +
101653 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101654 + return gimple_get_lhs(assign);
101655 +}
101656 +
101657 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
101658 +{
101659 + tree size_overflow_type;
101660 + const_gimple def_stmt = get_def_stmt(arg);
101661 +
101662 + if (phi_ssa_name != NULL_TREE)
101663 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
101664 +
101665 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
101666 +
101667 + if (new_arg != NULL_TREE) {
101668 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
101669 + return use_phi_ssa_name(phi_ssa_name, new_arg);
101670 + }
101671 +
101672 + switch(gimple_code(def_stmt)) {
101673 + case GIMPLE_PHI:
101674 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
101675 + case GIMPLE_NOP:
101676 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
101677 + default:
101678 + debug_gimple_stmt((gimple)def_stmt);
101679 + gcc_unreachable();
101680 + }
101681 +}
101682 +
101683 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
101684 +{
101685 + basic_block bb;
101686 + gimple phi;
101687 + gimple_seq seq;
101688 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
101689 +
101690 + bb = gsi_bb(gsi);
101691 +
101692 + phi = create_phi_node(result, bb);
101693 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
101694 + seq = phi_nodes(bb);
101695 + gsi = gsi_last(seq);
101696 + gsi_remove(&gsi, false);
101697 +
101698 + gsi = gsi_for_stmt(oldstmt);
101699 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
101700 + gimple_set_bb(phi, bb);
101701 + gimple_set_plf(phi, MY_STMT, true);
101702 + return phi;
101703 +}
101704 +
101705 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
101706 +{
101707 + gimple new_phi = NULL;
101708 + gimple oldstmt = get_def_stmt(orig_result);
101709 + tree phi_ssa_name = NULL_TREE;
101710 + unsigned int i;
101711 +
101712 + pointer_set_insert(visited, oldstmt);
101713 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
101714 + tree arg, new_arg;
101715 +
101716 + arg = gimple_phi_arg_def(oldstmt, i);
101717 +
101718 + new_arg = expand(visited, arg);
101719 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
101720 + if (i == 0) {
101721 + phi_ssa_name = new_arg;
101722 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
101723 + }
101724 +
101725 + gcc_assert(new_phi != NULL);
101726 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
101727 + }
101728 +
101729 + gcc_assert(new_phi != NULL);
101730 + update_stmt(new_phi);
101731 + return gimple_phi_result(new_phi);
101732 +}
101733 +
101734 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
101735 +{
101736 + const_gimple assign;
101737 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101738 + tree origtype = TREE_TYPE(orig_rhs);
101739 +
101740 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
101741 +
101742 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101743 + return gimple_get_lhs(assign);
101744 +}
101745 +
101746 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
101747 +{
101748 + const_tree rhs1, lhs, rhs1_type, lhs_type;
101749 + enum machine_mode lhs_mode, rhs_mode;
101750 + gimple def_stmt = get_def_stmt(no_const_rhs);
101751 +
101752 + if (!gimple_assign_cast_p(def_stmt))
101753 + return false;
101754 +
101755 + rhs1 = gimple_assign_rhs1(def_stmt);
101756 + lhs = gimple_get_lhs(def_stmt);
101757 + rhs1_type = TREE_TYPE(rhs1);
101758 + lhs_type = TREE_TYPE(lhs);
101759 + rhs_mode = TYPE_MODE(rhs1_type);
101760 + lhs_mode = TYPE_MODE(lhs_type);
101761 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
101762 + return false;
101763 +
101764 + return true;
101765 +}
101766 +
101767 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
101768 +{
101769 + tree rhs1 = gimple_assign_rhs1(stmt);
101770 + tree lhs = gimple_get_lhs(stmt);
101771 + const_tree rhs1_type = TREE_TYPE(rhs1);
101772 + const_tree lhs_type = TREE_TYPE(lhs);
101773 +
101774 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
101775 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101776 +
101777 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
101778 +}
101779 +
101780 +static bool no_uses(tree node)
101781 +{
101782 + imm_use_iterator imm_iter;
101783 + use_operand_p use_p;
101784 +
101785 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
101786 + const_gimple use_stmt = USE_STMT(use_p);
101787 + if (use_stmt == NULL)
101788 + return true;
101789 + if (is_gimple_debug(use_stmt))
101790 + continue;
101791 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
101792 + continue;
101793 + return false;
101794 + }
101795 + return true;
101796 +}
101797 +
101798 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
101799 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
101800 +{
101801 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
101802 + gimple def_stmt = get_def_stmt(lhs);
101803 +
101804 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
101805 + return false;
101806 +
101807 + rhs1 = gimple_assign_rhs1(def_stmt);
101808 + rhs_type = TREE_TYPE(rhs1);
101809 + lhs_type = TREE_TYPE(lhs);
101810 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
101811 + return false;
101812 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
101813 + return false;
101814 +
101815 + def_stmt = get_def_stmt(rhs1);
101816 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
101817 + return false;
101818 +
101819 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
101820 + return false;
101821 +
101822 + rhs1 = gimple_assign_rhs1(def_stmt);
101823 + rhs2 = gimple_assign_rhs2(def_stmt);
101824 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
101825 + return false;
101826 +
101827 + if (is_gimple_constant(rhs2))
101828 + not_const_rhs = rhs1;
101829 + else
101830 + not_const_rhs = rhs2;
101831 +
101832 + return no_uses(not_const_rhs);
101833 +}
101834 +
101835 +static bool skip_lhs_cast_check(const_gimple stmt)
101836 +{
101837 + const_tree rhs = gimple_assign_rhs1(stmt);
101838 + const_gimple def_stmt = get_def_stmt(rhs);
101839 +
101840 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
101841 + if (gimple_code(def_stmt) == GIMPLE_ASM)
101842 + return true;
101843 +
101844 + if (is_const_plus_unsigned_signed_truncation(rhs))
101845 + return true;
101846 +
101847 + return false;
101848 +}
101849 +
101850 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
101851 +{
101852 + bool cast_lhs, cast_rhs;
101853 + tree lhs = gimple_get_lhs(stmt);
101854 + tree rhs = gimple_assign_rhs1(stmt);
101855 + const_tree lhs_type = TREE_TYPE(lhs);
101856 + const_tree rhs_type = TREE_TYPE(rhs);
101857 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
101858 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
101859 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
101860 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
101861 +
101862 + static bool check_lhs[3][4] = {
101863 + // ss su us uu
101864 + { false, true, true, false }, // lhs > rhs
101865 + { false, false, false, false }, // lhs = rhs
101866 + { true, true, true, true }, // lhs < rhs
101867 + };
101868 +
101869 + static bool check_rhs[3][4] = {
101870 + // ss su us uu
101871 + { true, false, true, true }, // lhs > rhs
101872 + { true, false, true, true }, // lhs = rhs
101873 + { true, false, true, true }, // lhs < rhs
101874 + };
101875 +
101876 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
101877 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
101878 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101879 +
101880 + if (lhs_size > rhs_size) {
101881 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101882 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101883 + } else if (lhs_size == rhs_size) {
101884 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101885 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101886 + } else {
101887 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101888 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101889 + }
101890 +
101891 + if (!cast_lhs && !cast_rhs)
101892 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101893 +
101894 + if (cast_lhs && !skip_lhs_cast_check(stmt))
101895 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
101896 +
101897 + if (cast_rhs)
101898 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
101899 +
101900 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101901 +}
101902 +
101903 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
101904 +{
101905 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
101906 +
101907 + if (gimple_plf(stmt, MY_STMT))
101908 + return lhs;
101909 +
101910 + rhs1 = gimple_assign_rhs1(stmt);
101911 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
101912 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101913 +
101914 + new_rhs1 = expand(visited, rhs1);
101915 +
101916 + if (new_rhs1 == NULL_TREE)
101917 + return create_cast_assign(visited, stmt);
101918 +
101919 + if (gimple_plf(stmt, NO_CAST_CHECK))
101920 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101921 +
101922 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
101923 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
101924 +
101925 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
101926 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
101927 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101928 + }
101929 +
101930 + if (!gimple_assign_cast_p(stmt))
101931 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101932 +
101933 + return create_cast_overflow_check(visited, new_rhs1, stmt);
101934 +}
101935 +
101936 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
101937 +{
101938 + tree rhs1, lhs = gimple_get_lhs(stmt);
101939 + gimple def_stmt = get_def_stmt(lhs);
101940 +
101941 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
101942 + rhs1 = gimple_assign_rhs1(def_stmt);
101943 +
101944 + if (is_gimple_constant(rhs1))
101945 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101946 +
101947 + switch (TREE_CODE(rhs1)) {
101948 + case SSA_NAME:
101949 + return handle_unary_rhs(visited, def_stmt);
101950 + case ARRAY_REF:
101951 + case BIT_FIELD_REF:
101952 + case ADDR_EXPR:
101953 + case COMPONENT_REF:
101954 + case INDIRECT_REF:
101955 +#if BUILDING_GCC_VERSION >= 4006
101956 + case MEM_REF:
101957 +#endif
101958 + case TARGET_MEM_REF:
101959 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101960 + case PARM_DECL:
101961 + case VAR_DECL:
101962 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101963 +
101964 + default:
101965 + debug_gimple_stmt(def_stmt);
101966 + debug_tree(rhs1);
101967 + gcc_unreachable();
101968 + }
101969 +}
101970 +
101971 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
101972 +{
101973 + gimple cond_stmt;
101974 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
101975 +
101976 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
101977 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
101978 + update_stmt(cond_stmt);
101979 +}
101980 +
101981 +static tree create_string_param(tree string)
101982 +{
101983 + tree i_type, a_type;
101984 + const int length = TREE_STRING_LENGTH(string);
101985 +
101986 + gcc_assert(length > 0);
101987 +
101988 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
101989 + a_type = build_array_type(char_type_node, i_type);
101990 +
101991 + TREE_TYPE(string) = a_type;
101992 + TREE_CONSTANT(string) = 1;
101993 + TREE_READONLY(string) = 1;
101994 +
101995 + return build1(ADDR_EXPR, ptr_type_node, string);
101996 +}
101997 +
101998 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
101999 +{
102000 + gimple func_stmt;
102001 + const_gimple def_stmt;
102002 + const_tree loc_line;
102003 + tree loc_file, ssa_name, current_func;
102004 + expanded_location xloc;
102005 + char *ssa_name_buf;
102006 + int len;
102007 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
102008 +
102009 + def_stmt = get_def_stmt(arg);
102010 + xloc = expand_location(gimple_location(def_stmt));
102011 +
102012 + if (!gimple_has_location(def_stmt)) {
102013 + xloc = expand_location(gimple_location(stmt));
102014 + if (!gimple_has_location(stmt))
102015 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102016 + }
102017 +
102018 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
102019 +
102020 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
102021 + loc_file = create_string_param(loc_file);
102022 +
102023 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
102024 + current_func = create_string_param(current_func);
102025 +
102026 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
102027 + call_count++;
102028 + 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);
102029 + gcc_assert(len > 0);
102030 + ssa_name = build_string(len + 1, ssa_name_buf);
102031 + free(ssa_name_buf);
102032 + ssa_name = create_string_param(ssa_name);
102033 +
102034 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
102035 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
102036 +
102037 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
102038 +}
102039 +
102040 +static void __unused print_the_code_insertions(const_gimple stmt)
102041 +{
102042 + location_t loc = gimple_location(stmt);
102043 +
102044 + inform(loc, "Integer size_overflow check applied here.");
102045 +}
102046 +
102047 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
102048 +{
102049 + basic_block cond_bb, join_bb, bb_true;
102050 + edge e;
102051 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102052 +
102053 + cond_bb = gimple_bb(stmt);
102054 + if (before)
102055 + gsi_prev(&gsi);
102056 + if (gsi_end_p(gsi))
102057 + e = split_block_after_labels(cond_bb);
102058 + else
102059 + e = split_block(cond_bb, gsi_stmt(gsi));
102060 + cond_bb = e->src;
102061 + join_bb = e->dest;
102062 + e->flags = EDGE_FALSE_VALUE;
102063 + e->probability = REG_BR_PROB_BASE;
102064 +
102065 + bb_true = create_empty_bb(cond_bb);
102066 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
102067 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
102068 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
102069 +
102070 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102071 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
102072 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
102073 +
102074 + if (current_loops != NULL) {
102075 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
102076 + add_bb_to_loop(bb_true, cond_bb->loop_father);
102077 + }
102078 +
102079 + insert_cond(cond_bb, arg, cond_code, type_value);
102080 + insert_cond_result(bb_true, stmt, arg, min);
102081 +
102082 +// print_the_code_insertions(stmt);
102083 +}
102084 +
102085 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
102086 +{
102087 + const_tree rhs_type = TREE_TYPE(rhs);
102088 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
102089 +
102090 + gcc_assert(rhs_type != NULL_TREE);
102091 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
102092 + return;
102093 +
102094 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
102095 +
102096 + if (is_const_plus_unsigned_signed_truncation(rhs))
102097 + return;
102098 +
102099 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
102100 + // typemax (-1) < typemin (0)
102101 + if (TREE_OVERFLOW(type_max))
102102 + return;
102103 +
102104 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
102105 +
102106 + cast_rhs_type = TREE_TYPE(cast_rhs);
102107 + type_max_type = TREE_TYPE(type_max);
102108 + type_min_type = TREE_TYPE(type_min);
102109 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
102110 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
102111 +
102112 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
102113 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
102114 +}
102115 +
102116 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
102117 +{
102118 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
102119 + return false;
102120 + if (!is_gimple_constant(rhs))
102121 + return false;
102122 + return true;
102123 +}
102124 +
102125 +static tree get_def_stmt_rhs(const_tree var)
102126 +{
102127 + tree rhs1, def_stmt_rhs1;
102128 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
102129 +
102130 + def_stmt = get_def_stmt(var);
102131 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
102132 +
102133 + rhs1 = gimple_assign_rhs1(def_stmt);
102134 + rhs1_def_stmt = get_def_stmt(rhs1);
102135 + if (!gimple_assign_cast_p(rhs1_def_stmt))
102136 + return rhs1;
102137 +
102138 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102139 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
102140 +
102141 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
102142 + case GIMPLE_CALL:
102143 + case GIMPLE_NOP:
102144 + case GIMPLE_ASM:
102145 + case GIMPLE_PHI:
102146 + return def_stmt_rhs1;
102147 + case GIMPLE_ASSIGN:
102148 + return rhs1;
102149 + default:
102150 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
102151 + gcc_unreachable();
102152 + }
102153 +}
102154 +
102155 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
102156 +{
102157 + tree new_rhs, orig_rhs;
102158 + void (*gimple_assign_set_rhs)(gimple, tree);
102159 + tree rhs1 = gimple_assign_rhs1(stmt);
102160 + tree rhs2 = gimple_assign_rhs2(stmt);
102161 + tree lhs = gimple_get_lhs(stmt);
102162 +
102163 + if (!check_overflow)
102164 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102165 +
102166 + if (change_rhs == NULL_TREE)
102167 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102168 +
102169 + if (new_rhs2 == NULL_TREE) {
102170 + orig_rhs = rhs1;
102171 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
102172 + } else {
102173 + orig_rhs = rhs2;
102174 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
102175 + }
102176 +
102177 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
102178 +
102179 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
102180 + gimple_assign_set_rhs(stmt, new_rhs);
102181 + update_stmt(stmt);
102182 +
102183 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102184 +}
102185 +
102186 +static bool is_subtraction_special(const_gimple stmt)
102187 +{
102188 + gimple rhs1_def_stmt, rhs2_def_stmt;
102189 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
102190 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
102191 + const_tree rhs1 = gimple_assign_rhs1(stmt);
102192 + const_tree rhs2 = gimple_assign_rhs2(stmt);
102193 +
102194 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
102195 + return false;
102196 +
102197 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
102198 +
102199 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
102200 + return false;
102201 +
102202 + rhs1_def_stmt = get_def_stmt(rhs1);
102203 + rhs2_def_stmt = get_def_stmt(rhs2);
102204 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
102205 + return false;
102206 +
102207 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102208 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
102209 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
102210 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
102211 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
102212 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
102213 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
102214 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
102215 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
102216 + return false;
102217 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
102218 + return false;
102219 +
102220 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
102221 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
102222 + return true;
102223 +}
102224 +
102225 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
102226 +{
102227 + tree new_rhs1, new_rhs2;
102228 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
102229 + gimple assign, stmt = get_def_stmt(lhs);
102230 + tree rhs1 = gimple_assign_rhs1(stmt);
102231 + tree rhs2 = gimple_assign_rhs2(stmt);
102232 +
102233 + if (!is_subtraction_special(stmt))
102234 + return NULL_TREE;
102235 +
102236 + new_rhs1 = expand(visited, rhs1);
102237 + new_rhs2 = expand(visited, rhs2);
102238 +
102239 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
102240 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
102241 +
102242 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
102243 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
102244 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
102245 + }
102246 +
102247 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
102248 + new_lhs = gimple_get_lhs(assign);
102249 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
102250 +
102251 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102252 +}
102253 +
102254 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
102255 +{
102256 + const_gimple def_stmt;
102257 +
102258 + if (TREE_CODE(rhs) != SSA_NAME)
102259 + return false;
102260 +
102261 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
102262 + return false;
102263 +
102264 + def_stmt = get_def_stmt(rhs);
102265 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
102266 + return false;
102267 +
102268 + return true;
102269 +}
102270 +
102271 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
102272 +{
102273 + tree rhs1, rhs2, new_lhs;
102274 + gimple def_stmt = get_def_stmt(lhs);
102275 + tree new_rhs1 = NULL_TREE;
102276 + tree new_rhs2 = NULL_TREE;
102277 +
102278 + rhs1 = gimple_assign_rhs1(def_stmt);
102279 + rhs2 = gimple_assign_rhs2(def_stmt);
102280 +
102281 + /* no DImode/TImode division in the 32/64 bit kernel */
102282 + switch (gimple_assign_rhs_code(def_stmt)) {
102283 + case RDIV_EXPR:
102284 + case TRUNC_DIV_EXPR:
102285 + case CEIL_DIV_EXPR:
102286 + case FLOOR_DIV_EXPR:
102287 + case ROUND_DIV_EXPR:
102288 + case TRUNC_MOD_EXPR:
102289 + case CEIL_MOD_EXPR:
102290 + case FLOOR_MOD_EXPR:
102291 + case ROUND_MOD_EXPR:
102292 + case EXACT_DIV_EXPR:
102293 + case POINTER_PLUS_EXPR:
102294 + case BIT_AND_EXPR:
102295 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102296 + default:
102297 + break;
102298 + }
102299 +
102300 + new_lhs = handle_integer_truncation(visited, lhs);
102301 + if (new_lhs != NULL_TREE)
102302 + return new_lhs;
102303 +
102304 + if (TREE_CODE(rhs1) == SSA_NAME)
102305 + new_rhs1 = expand(visited, rhs1);
102306 + if (TREE_CODE(rhs2) == SSA_NAME)
102307 + new_rhs2 = expand(visited, rhs2);
102308 +
102309 + if (is_a_neg_overflow(def_stmt, rhs2))
102310 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
102311 + if (is_a_neg_overflow(def_stmt, rhs1))
102312 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
102313 +
102314 +
102315 + if (is_a_constant_overflow(def_stmt, rhs2))
102316 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
102317 + if (is_a_constant_overflow(def_stmt, rhs1))
102318 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
102319 +
102320 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102321 +}
102322 +
102323 +#if BUILDING_GCC_VERSION >= 4007
102324 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
102325 +{
102326 + if (is_gimple_constant(rhs))
102327 + return cast_a_tree(size_overflow_type, rhs);
102328 + if (TREE_CODE(rhs) != SSA_NAME)
102329 + return NULL_TREE;
102330 + return expand(visited, rhs);
102331 +}
102332 +
102333 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
102334 +{
102335 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
102336 + gimple def_stmt = get_def_stmt(lhs);
102337 +
102338 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
102339 +
102340 + rhs1 = gimple_assign_rhs1(def_stmt);
102341 + rhs2 = gimple_assign_rhs2(def_stmt);
102342 + rhs3 = gimple_assign_rhs3(def_stmt);
102343 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
102344 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
102345 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
102346 +
102347 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
102348 +}
102349 +#endif
102350 +
102351 +static tree get_size_overflow_type(gimple stmt, const_tree node)
102352 +{
102353 + const_tree type;
102354 + tree new_type;
102355 +
102356 + gcc_assert(node != NULL_TREE);
102357 +
102358 + type = TREE_TYPE(node);
102359 +
102360 + if (gimple_plf(stmt, MY_STMT))
102361 + return TREE_TYPE(node);
102362 +
102363 + switch (TYPE_MODE(type)) {
102364 + case QImode:
102365 + new_type = intHI_type_node;
102366 + break;
102367 + case HImode:
102368 + new_type = intSI_type_node;
102369 + break;
102370 + case SImode:
102371 + new_type = intDI_type_node;
102372 + break;
102373 + case DImode:
102374 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102375 + new_type = intDI_type_node;
102376 + else
102377 + new_type = intTI_type_node;
102378 + break;
102379 + default:
102380 + debug_tree((tree)node);
102381 + error("%s: unsupported gcc configuration.", __func__);
102382 + gcc_unreachable();
102383 + }
102384 +
102385 + if (TYPE_QUALS(type) != 0)
102386 + return build_qualified_type(new_type, TYPE_QUALS(type));
102387 + return new_type;
102388 +}
102389 +
102390 +static tree expand_visited(gimple def_stmt)
102391 +{
102392 + const_gimple next_stmt;
102393 + gimple_stmt_iterator gsi;
102394 + enum gimple_code code = gimple_code(def_stmt);
102395 +
102396 + if (code == GIMPLE_ASM)
102397 + return NULL_TREE;
102398 +
102399 + gsi = gsi_for_stmt(def_stmt);
102400 + gsi_next(&gsi);
102401 +
102402 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
102403 + return NULL_TREE;
102404 + gcc_assert(!gsi_end_p(gsi));
102405 + next_stmt = gsi_stmt(gsi);
102406 +
102407 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
102408 + return NULL_TREE;
102409 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
102410 +
102411 + return get_lhs(next_stmt);
102412 +}
102413 +
102414 +static tree expand(struct pointer_set_t *visited, tree lhs)
102415 +{
102416 + gimple def_stmt;
102417 +
102418 + if (skip_types(lhs))
102419 + return NULL_TREE;
102420 +
102421 + def_stmt = get_def_stmt(lhs);
102422 +
102423 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102424 + return NULL_TREE;
102425 +
102426 + if (gimple_plf(def_stmt, MY_STMT))
102427 + return lhs;
102428 +
102429 + if (pointer_set_contains(visited, def_stmt))
102430 + return expand_visited(def_stmt);
102431 +
102432 + switch (gimple_code(def_stmt)) {
102433 + case GIMPLE_PHI:
102434 + return handle_phi(visited, lhs);
102435 + case GIMPLE_CALL:
102436 + case GIMPLE_ASM:
102437 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102438 + case GIMPLE_ASSIGN:
102439 + switch (gimple_num_ops(def_stmt)) {
102440 + case 2:
102441 + return handle_unary_ops(visited, def_stmt);
102442 + case 3:
102443 + return handle_binary_ops(visited, lhs);
102444 +#if BUILDING_GCC_VERSION >= 4007
102445 + case 4:
102446 + return handle_ternary_ops(visited, lhs);
102447 +#endif
102448 + }
102449 + default:
102450 + debug_gimple_stmt(def_stmt);
102451 + error("%s: unknown gimple code", __func__);
102452 + gcc_unreachable();
102453 + }
102454 +}
102455 +
102456 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
102457 +{
102458 + const_gimple assign;
102459 + tree orig_type = TREE_TYPE(orig_node);
102460 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102461 +
102462 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102463 + return gimple_get_lhs(assign);
102464 +}
102465 +
102466 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
102467 +{
102468 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
102469 + update_stmt(stmt);
102470 +}
102471 +
102472 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
102473 +{
102474 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
102475 + update_stmt(stmt);
102476 +}
102477 +
102478 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
102479 +{
102480 + tree arg;
102481 + const_tree origarg;
102482 +
102483 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
102484 + return true;
102485 +
102486 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
102487 + while (origarg && *argnum) {
102488 + (*argnum)--;
102489 + origarg = TREE_CHAIN(origarg);
102490 + }
102491 +
102492 + gcc_assert(*argnum == 0);
102493 +
102494 + gcc_assert(origarg != NULL_TREE);
102495 + *argnum = 0;
102496 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
102497 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
102498 + return true;
102499 + return false;
102500 +}
102501 +
102502 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
102503 +{
102504 + gimple phi = get_def_stmt(result);
102505 + unsigned int i, n = gimple_phi_num_args(phi);
102506 +
102507 + if (!phi)
102508 + return MARK_NO;
102509 +
102510 + pointer_set_insert(visited, phi);
102511 + for (i = 0; i < n; i++) {
102512 + enum mark marked;
102513 + const_tree arg = gimple_phi_arg_def(phi, i);
102514 + marked = pre_expand(visited, search_err_code, arg);
102515 + if (marked != MARK_NO)
102516 + return marked;
102517 + }
102518 + return MARK_NO;
102519 +}
102520 +
102521 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102522 +{
102523 + gimple def_stmt = get_def_stmt(lhs);
102524 + const_tree rhs;
102525 +
102526 + if (!def_stmt)
102527 + return MARK_NO;
102528 +
102529 + rhs = gimple_assign_rhs1(def_stmt);
102530 +
102531 + def_stmt = get_def_stmt(rhs);
102532 + if (is_gimple_constant(rhs))
102533 + search_err_code[FROM_CONST] = true;
102534 +
102535 + return pre_expand(visited, search_err_code, rhs);
102536 +}
102537 +
102538 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102539 +{
102540 + gimple def_stmt = get_def_stmt(lhs);
102541 + const_tree rhs1, rhs2;
102542 + enum mark marked;
102543 +
102544 + if (!def_stmt)
102545 + return MARK_NO;
102546 +
102547 + search_err_code[CAST_ONLY] = false;
102548 +
102549 + rhs1 = gimple_assign_rhs1(def_stmt);
102550 + rhs2 = gimple_assign_rhs2(def_stmt);
102551 + marked = pre_expand(visited, search_err_code, rhs1);
102552 + if (marked != MARK_NO)
102553 + return marked;
102554 + return pre_expand(visited, search_err_code, rhs2);
102555 +}
102556 +
102557 +static const_tree search_field_decl(const_tree comp_ref)
102558 +{
102559 + const_tree field = NULL_TREE;
102560 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
102561 +
102562 + for (i = 0; i < len; i++) {
102563 + field = TREE_OPERAND(comp_ref, i);
102564 + if (TREE_CODE(field) == FIELD_DECL)
102565 + break;
102566 + }
102567 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
102568 + return field;
102569 +}
102570 +
102571 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
102572 +{
102573 + const_tree attr, p;
102574 +
102575 + // 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);
102576 + if (fndecl == NULL_TREE)
102577 + return MARK_NO;
102578 +
102579 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
102580 + if (!attr || !TREE_VALUE(attr))
102581 + return MARK_NO;
102582 +
102583 + p = TREE_VALUE(attr);
102584 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
102585 + return MARK_TURN_OFF;
102586 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
102587 + return MARK_NOT_INTENTIONAL;
102588 + if (argnum == 0) {
102589 + gcc_assert(current_function_decl == fndecl);
102590 + return MARK_NO;
102591 + }
102592 +
102593 + do {
102594 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
102595 + return MARK_YES;
102596 + p = TREE_CHAIN(p);
102597 + } while (p);
102598 +
102599 + return MARK_NO;
102600 +}
102601 +
102602 +static void print_missing_msg(tree func, unsigned int argnum)
102603 +{
102604 + unsigned int new_hash;
102605 + size_t len;
102606 + unsigned char tree_codes[CODES_LIMIT];
102607 + location_t loc;
102608 + const char *curfunc;
102609 +
102610 + func = get_original_function_decl(func);
102611 + loc = DECL_SOURCE_LOCATION(func);
102612 + curfunc = get_asm_name(func);
102613 +
102614 + len = get_function_decl(func, tree_codes);
102615 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
102616 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
102617 +}
102618 +
102619 +static unsigned int search_missing_attribute(const_tree arg)
102620 +{
102621 + unsigned int argnum;
102622 + const struct size_overflow_hash *hash;
102623 + const_tree type = TREE_TYPE(arg);
102624 + tree func = get_original_function_decl(current_function_decl);
102625 +
102626 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
102627 +
102628 + if (TREE_CODE(type) == POINTER_TYPE)
102629 + return 0;
102630 +
102631 + argnum = find_arg_number(arg, func);
102632 + if (argnum == 0)
102633 + return 0;
102634 +
102635 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
102636 + return argnum;
102637 +
102638 + hash = get_function_hash(func);
102639 + if (!hash || !(hash->param & (1U << argnum))) {
102640 + print_missing_msg(func, argnum);
102641 + return 0;
102642 + }
102643 + return argnum;
102644 +}
102645 +
102646 +static enum mark is_already_marked(const_tree lhs)
102647 +{
102648 + unsigned int argnum;
102649 + const_tree fndecl;
102650 +
102651 + argnum = search_missing_attribute(lhs);
102652 + fndecl = get_original_function_decl(current_function_decl);
102653 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
102654 + return MARK_YES;
102655 + return MARK_NO;
102656 +}
102657 +
102658 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102659 +{
102660 + const_gimple def_stmt;
102661 +
102662 + if (skip_types(lhs))
102663 + return MARK_NO;
102664 +
102665 + if (TREE_CODE(lhs) == PARM_DECL)
102666 + return is_already_marked(lhs);
102667 +
102668 + if (TREE_CODE(lhs) == COMPONENT_REF) {
102669 + const_tree field, attr;
102670 +
102671 + field = search_field_decl(lhs);
102672 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
102673 + if (!attr || !TREE_VALUE(attr))
102674 + return MARK_NO;
102675 + return MARK_YES;
102676 + }
102677 +
102678 + def_stmt = get_def_stmt(lhs);
102679 +
102680 + if (!def_stmt)
102681 + return MARK_NO;
102682 +
102683 + if (pointer_set_contains(visited, def_stmt))
102684 + return MARK_NO;
102685 +
102686 + switch (gimple_code(def_stmt)) {
102687 + case GIMPLE_NOP:
102688 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
102689 + return is_already_marked(lhs);
102690 + return MARK_NO;
102691 + case GIMPLE_PHI:
102692 + return walk_phi(visited, search_err_code, lhs);
102693 + case GIMPLE_CALL:
102694 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
102695 + return MARK_TURN_OFF;
102696 + check_function_hash(def_stmt);
102697 + return MARK_NO;
102698 + case GIMPLE_ASM:
102699 + search_err_code[CAST_ONLY] = false;
102700 + return MARK_NO;
102701 + case GIMPLE_ASSIGN:
102702 + switch (gimple_num_ops(def_stmt)) {
102703 + case 2:
102704 + return walk_unary_ops(visited, search_err_code, lhs);
102705 + case 3:
102706 + return walk_binary_ops(visited, search_err_code, lhs);
102707 + }
102708 + default:
102709 + debug_gimple_stmt((gimple)def_stmt);
102710 + error("%s: unknown gimple code", __func__);
102711 + gcc_unreachable();
102712 + }
102713 +}
102714 +
102715 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
102716 +static bool skip_asm(const_tree arg)
102717 +{
102718 + gimple def_stmt = get_def_stmt(arg);
102719 +
102720 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102721 + return false;
102722 +
102723 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
102724 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
102725 +}
102726 +
102727 +/*
102728 +0</MARK_YES: no dup, search attributes (so, int)
102729 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
102730 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
102731 +*/
102732 +
102733 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
102734 +{
102735 + struct pointer_set_t *visited;
102736 + enum mark is_marked, is_found;
102737 + location_t loc;
102738 + bool search_err_code[2] = {true, false};
102739 +
102740 + is_marked = mark_status(current_function_decl, 0);
102741 + if (is_marked == MARK_TURN_OFF)
102742 + return true;
102743 +
102744 + is_marked = mark_status(fndecl, argnum + 1);
102745 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
102746 + return true;
102747 +
102748 + visited = pointer_set_create();
102749 + is_found = pre_expand(visited, search_err_code, arg);
102750 + pointer_set_destroy(visited);
102751 +
102752 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
102753 + return true;
102754 +
102755 + if (where == FROM_ARG && skip_asm(arg))
102756 + return true;
102757 +
102758 + if (is_found == MARK_TURN_OFF)
102759 + return true;
102760 +
102761 + if ((is_found == MARK_YES && is_marked == MARK_YES))
102762 + return true;
102763 +
102764 + if (is_found == MARK_YES) {
102765 + loc = DECL_SOURCE_LOCATION(fndecl);
102766 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
102767 + return true;
102768 + }
102769 + return false;
102770 +}
102771 +
102772 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
102773 +{
102774 + struct pointer_set_t *visited;
102775 + tree arg, new_arg;
102776 + bool match;
102777 +
102778 + if (argnum == 0)
102779 + return;
102780 +
102781 + argnum--;
102782 +
102783 + match = get_function_arg(&argnum, fndecl);
102784 + if (!match)
102785 + return;
102786 + gcc_assert(gimple_call_num_args(stmt) > argnum);
102787 + arg = gimple_call_arg(stmt, argnum);
102788 + if (arg == NULL_TREE)
102789 + return;
102790 +
102791 + if (skip_types(arg))
102792 + return;
102793 +
102794 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
102795 + return;
102796 +
102797 + visited = pointer_set_create();
102798 + new_arg = expand(visited, arg);
102799 + pointer_set_destroy(visited);
102800 +
102801 + if (new_arg == NULL_TREE)
102802 + return;
102803 +
102804 + change_function_arg(stmt, arg, argnum, new_arg);
102805 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
102806 +}
102807 +
102808 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
102809 +{
102810 + tree p = TREE_VALUE(attr);
102811 + do {
102812 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
102813 + p = TREE_CHAIN(p);
102814 + } while (p);
102815 +}
102816 +
102817 +static void handle_function_by_hash(gimple stmt, tree fndecl)
102818 +{
102819 + unsigned int num;
102820 + const struct size_overflow_hash *hash;
102821 +
102822 + hash = get_function_hash(fndecl);
102823 + if (!hash)
102824 + return;
102825 +
102826 + for (num = 0; num <= MAX_PARAM; num++)
102827 + if (hash->param & (1U << num))
102828 + handle_function_arg(stmt, fndecl, num);
102829 +}
102830 +
102831 +static bool check_return_value(void)
102832 +{
102833 + const struct size_overflow_hash *hash;
102834 +
102835 + hash = get_function_hash(current_function_decl);
102836 + if (!hash || !(hash->param & 1U << 0))
102837 + return false;
102838 +
102839 + return true;
102840 +}
102841 +
102842 +static void handle_return_value(gimple ret_stmt)
102843 +{
102844 + struct pointer_set_t *visited;
102845 + tree ret, new_ret;
102846 +
102847 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
102848 + return;
102849 +
102850 + ret = gimple_return_retval(ret_stmt);
102851 +
102852 + if (skip_types(ret))
102853 + return;
102854 +
102855 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
102856 + return;
102857 +
102858 + visited = pointer_set_create();
102859 + new_ret = expand(visited, ret);
102860 + pointer_set_destroy(visited);
102861 +
102862 + change_function_return(ret_stmt, ret, new_ret);
102863 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
102864 +}
102865 +
102866 +static void set_plf_false(void)
102867 +{
102868 + basic_block bb;
102869 +
102870 + FOR_ALL_BB(bb) {
102871 + gimple_stmt_iterator si;
102872 +
102873 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
102874 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
102875 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
102876 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
102877 + }
102878 +}
102879 +
102880 +static unsigned int handle_function(void)
102881 +{
102882 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
102883 + bool check_ret;
102884 +
102885 + set_plf_false();
102886 +
102887 + check_ret = check_return_value();
102888 +
102889 + do {
102890 + gimple_stmt_iterator gsi;
102891 + next = bb->next_bb;
102892 +
102893 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102894 + tree fndecl, attr;
102895 + gimple stmt = gsi_stmt(gsi);
102896 +
102897 + if (check_ret)
102898 + handle_return_value(stmt);
102899 +
102900 + if (!(is_gimple_call(stmt)))
102901 + continue;
102902 + fndecl = gimple_call_fndecl(stmt);
102903 + if (fndecl == NULL_TREE)
102904 + continue;
102905 + if (gimple_call_num_args(stmt) == 0)
102906 + continue;
102907 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
102908 + if (!attr || !TREE_VALUE(attr))
102909 + handle_function_by_hash(stmt, fndecl);
102910 + else
102911 + handle_function_by_attribute(stmt, attr, fndecl);
102912 + gsi = gsi_for_stmt(stmt);
102913 + next = gimple_bb(stmt)->next_bb;
102914 + }
102915 + bb = next;
102916 + } while (bb);
102917 + return 0;
102918 +}
102919 +
102920 +static struct gimple_opt_pass size_overflow_pass = {
102921 + .pass = {
102922 + .type = GIMPLE_PASS,
102923 + .name = "size_overflow",
102924 +#if BUILDING_GCC_VERSION >= 4008
102925 + .optinfo_flags = OPTGROUP_NONE,
102926 +#endif
102927 + .gate = NULL,
102928 + .execute = handle_function,
102929 + .sub = NULL,
102930 + .next = NULL,
102931 + .static_pass_number = 0,
102932 + .tv_id = TV_NONE,
102933 + .properties_required = PROP_cfg,
102934 + .properties_provided = 0,
102935 + .properties_destroyed = 0,
102936 + .todo_flags_start = 0,
102937 + .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
102938 + }
102939 +};
102940 +
102941 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
102942 +{
102943 + tree fntype;
102944 +
102945 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
102946 +
102947 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
102948 + fntype = build_function_type_list(void_type_node,
102949 + const_char_ptr_type_node,
102950 + unsigned_type_node,
102951 + const_char_ptr_type_node,
102952 + const_char_ptr_type_node,
102953 + NULL_TREE);
102954 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
102955 +
102956 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
102957 + TREE_PUBLIC(report_size_overflow_decl) = 1;
102958 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
102959 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
102960 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
102961 +}
102962 +
102963 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102964 +{
102965 + int i;
102966 + const char * const plugin_name = plugin_info->base_name;
102967 + const int argc = plugin_info->argc;
102968 + const struct plugin_argument * const argv = plugin_info->argv;
102969 + bool enable = true;
102970 +
102971 + struct register_pass_info size_overflow_pass_info = {
102972 + .pass = &size_overflow_pass.pass,
102973 + .reference_pass_name = "ssa",
102974 + .ref_pass_instance_number = 1,
102975 + .pos_op = PASS_POS_INSERT_AFTER
102976 + };
102977 +
102978 + if (!plugin_default_version_check(version, &gcc_version)) {
102979 + error(G_("incompatible gcc/plugin versions"));
102980 + return 1;
102981 + }
102982 +
102983 + for (i = 0; i < argc; ++i) {
102984 + if (!strcmp(argv[i].key, "no-size-overflow")) {
102985 + enable = false;
102986 + continue;
102987 + }
102988 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102989 + }
102990 +
102991 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
102992 + if (enable) {
102993 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102994 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
102995 + }
102996 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102997 +
102998 + return 0;
102999 +}
103000 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
103001 new file mode 100644
103002 index 0000000..ac2901e
103003 --- /dev/null
103004 +++ b/tools/gcc/stackleak_plugin.c
103005 @@ -0,0 +1,327 @@
103006 +/*
103007 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103008 + * Licensed under the GPL v2
103009 + *
103010 + * Note: the choice of the license means that the compilation process is
103011 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103012 + * but for the kernel it doesn't matter since it doesn't link against
103013 + * any of the gcc libraries
103014 + *
103015 + * gcc plugin to help implement various PaX features
103016 + *
103017 + * - track lowest stack pointer
103018 + *
103019 + * TODO:
103020 + * - initialize all local variables
103021 + *
103022 + * BUGS:
103023 + * - none known
103024 + */
103025 +#include "gcc-plugin.h"
103026 +#include "config.h"
103027 +#include "system.h"
103028 +#include "coretypes.h"
103029 +#include "tree.h"
103030 +#include "tree-pass.h"
103031 +#include "flags.h"
103032 +#include "intl.h"
103033 +#include "toplev.h"
103034 +#include "plugin.h"
103035 +//#include "expr.h" where are you...
103036 +#include "diagnostic.h"
103037 +#include "plugin-version.h"
103038 +#include "tm.h"
103039 +#include "function.h"
103040 +#include "basic-block.h"
103041 +#include "gimple.h"
103042 +#include "rtl.h"
103043 +#include "emit-rtl.h"
103044 +
103045 +#if BUILDING_GCC_VERSION >= 4008
103046 +#define TODO_dump_func 0
103047 +#endif
103048 +
103049 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103050 +
103051 +int plugin_is_GPL_compatible;
103052 +
103053 +static int track_frame_size = -1;
103054 +static const char track_function[] = "pax_track_stack";
103055 +static const char check_function[] = "pax_check_alloca";
103056 +static bool init_locals;
103057 +
103058 +static struct plugin_info stackleak_plugin_info = {
103059 + .version = "201302112000",
103060 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
103061 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
103062 +};
103063 +
103064 +static bool gate_stackleak_track_stack(void);
103065 +static unsigned int execute_stackleak_tree_instrument(void);
103066 +static unsigned int execute_stackleak_final(void);
103067 +
103068 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
103069 + .pass = {
103070 + .type = GIMPLE_PASS,
103071 + .name = "stackleak_tree_instrument",
103072 +#if BUILDING_GCC_VERSION >= 4008
103073 + .optinfo_flags = OPTGROUP_NONE,
103074 +#endif
103075 + .gate = gate_stackleak_track_stack,
103076 + .execute = execute_stackleak_tree_instrument,
103077 + .sub = NULL,
103078 + .next = NULL,
103079 + .static_pass_number = 0,
103080 + .tv_id = TV_NONE,
103081 + .properties_required = PROP_gimple_leh | PROP_cfg,
103082 + .properties_provided = 0,
103083 + .properties_destroyed = 0,
103084 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103085 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103086 + }
103087 +};
103088 +
103089 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
103090 + .pass = {
103091 + .type = RTL_PASS,
103092 + .name = "stackleak_final",
103093 +#if BUILDING_GCC_VERSION >= 4008
103094 + .optinfo_flags = OPTGROUP_NONE,
103095 +#endif
103096 + .gate = gate_stackleak_track_stack,
103097 + .execute = execute_stackleak_final,
103098 + .sub = NULL,
103099 + .next = NULL,
103100 + .static_pass_number = 0,
103101 + .tv_id = TV_NONE,
103102 + .properties_required = 0,
103103 + .properties_provided = 0,
103104 + .properties_destroyed = 0,
103105 + .todo_flags_start = 0,
103106 + .todo_flags_finish = TODO_dump_func
103107 + }
103108 +};
103109 +
103110 +static bool gate_stackleak_track_stack(void)
103111 +{
103112 + return track_frame_size >= 0;
103113 +}
103114 +
103115 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
103116 +{
103117 + gimple check_alloca;
103118 + tree fntype, fndecl, alloca_size;
103119 +
103120 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
103121 + fndecl = build_fn_decl(check_function, fntype);
103122 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103123 +
103124 + // insert call to void pax_check_alloca(unsigned long size)
103125 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
103126 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
103127 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
103128 +}
103129 +
103130 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
103131 +{
103132 + gimple track_stack;
103133 + tree fntype, fndecl;
103134 +
103135 + fntype = build_function_type_list(void_type_node, NULL_TREE);
103136 + fndecl = build_fn_decl(track_function, fntype);
103137 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103138 +
103139 + // insert call to void pax_track_stack(void)
103140 + track_stack = gimple_build_call(fndecl, 0);
103141 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
103142 +}
103143 +
103144 +#if BUILDING_GCC_VERSION == 4005
103145 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
103146 +{
103147 + tree fndecl;
103148 +
103149 + if (!is_gimple_call(stmt))
103150 + return false;
103151 + fndecl = gimple_call_fndecl(stmt);
103152 + if (!fndecl)
103153 + return false;
103154 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
103155 + return false;
103156 +// print_node(stderr, "pax", fndecl, 4);
103157 + return DECL_FUNCTION_CODE(fndecl) == code;
103158 +}
103159 +#endif
103160 +
103161 +static bool is_alloca(gimple stmt)
103162 +{
103163 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
103164 + return true;
103165 +
103166 +#if BUILDING_GCC_VERSION >= 4007
103167 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
103168 + return true;
103169 +#endif
103170 +
103171 + return false;
103172 +}
103173 +
103174 +static unsigned int execute_stackleak_tree_instrument(void)
103175 +{
103176 + basic_block bb, entry_bb;
103177 + bool prologue_instrumented = false, is_leaf = true;
103178 +
103179 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
103180 +
103181 + // 1. loop through BBs and GIMPLE statements
103182 + FOR_EACH_BB(bb) {
103183 + gimple_stmt_iterator gsi;
103184 +
103185 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103186 + gimple stmt;
103187 +
103188 + stmt = gsi_stmt(gsi);
103189 +
103190 + if (is_gimple_call(stmt))
103191 + is_leaf = false;
103192 +
103193 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
103194 + if (!is_alloca(stmt))
103195 + continue;
103196 +
103197 + // 2. insert stack overflow check before each __builtin_alloca call
103198 + stackleak_check_alloca(&gsi);
103199 +
103200 + // 3. insert track call after each __builtin_alloca call
103201 + stackleak_add_instrumentation(&gsi);
103202 + if (bb == entry_bb)
103203 + prologue_instrumented = true;
103204 + }
103205 + }
103206 +
103207 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
103208 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
103209 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
103210 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
103211 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
103212 + return 0;
103213 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
103214 + return 0;
103215 +
103216 + // 4. insert track call at the beginning
103217 + if (!prologue_instrumented) {
103218 + gimple_stmt_iterator gsi;
103219 +
103220 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103221 + if (dom_info_available_p(CDI_DOMINATORS))
103222 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103223 + gsi = gsi_start_bb(bb);
103224 + stackleak_add_instrumentation(&gsi);
103225 + }
103226 +
103227 + return 0;
103228 +}
103229 +
103230 +static unsigned int execute_stackleak_final(void)
103231 +{
103232 + rtx insn, next;
103233 +
103234 + if (cfun->calls_alloca)
103235 + return 0;
103236 +
103237 + // keep calls only if function frame is big enough
103238 + if (get_frame_size() >= track_frame_size)
103239 + return 0;
103240 +
103241 + // 1. find pax_track_stack calls
103242 + for (insn = get_insns(); insn; insn = next) {
103243 + // 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))
103244 + rtx body;
103245 +
103246 + next = NEXT_INSN(insn);
103247 + if (!CALL_P(insn))
103248 + continue;
103249 + body = PATTERN(insn);
103250 + if (GET_CODE(body) != CALL)
103251 + continue;
103252 + body = XEXP(body, 0);
103253 + if (GET_CODE(body) != MEM)
103254 + continue;
103255 + body = XEXP(body, 0);
103256 + if (GET_CODE(body) != SYMBOL_REF)
103257 + continue;
103258 + if (strcmp(XSTR(body, 0), track_function))
103259 + continue;
103260 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103261 + // 2. delete call
103262 + delete_insn_and_edges(insn);
103263 +#if BUILDING_GCC_VERSION >= 4007
103264 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
103265 + insn = next;
103266 + next = NEXT_INSN(insn);
103267 + delete_insn_and_edges(insn);
103268 + }
103269 +#endif
103270 + }
103271 +
103272 +// print_simple_rtl(stderr, get_insns());
103273 +// print_rtl(stderr, get_insns());
103274 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103275 +
103276 + return 0;
103277 +}
103278 +
103279 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103280 +{
103281 + const char * const plugin_name = plugin_info->base_name;
103282 + const int argc = plugin_info->argc;
103283 + const struct plugin_argument * const argv = plugin_info->argv;
103284 + int i;
103285 + struct register_pass_info stackleak_tree_instrument_pass_info = {
103286 + .pass = &stackleak_tree_instrument_pass.pass,
103287 +// .reference_pass_name = "tree_profile",
103288 + .reference_pass_name = "optimized",
103289 + .ref_pass_instance_number = 1,
103290 + .pos_op = PASS_POS_INSERT_BEFORE
103291 + };
103292 + struct register_pass_info stackleak_final_pass_info = {
103293 + .pass = &stackleak_final_rtl_opt_pass.pass,
103294 + .reference_pass_name = "final",
103295 + .ref_pass_instance_number = 1,
103296 + .pos_op = PASS_POS_INSERT_BEFORE
103297 + };
103298 +
103299 + if (!plugin_default_version_check(version, &gcc_version)) {
103300 + error(G_("incompatible gcc/plugin versions"));
103301 + return 1;
103302 + }
103303 +
103304 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
103305 +
103306 + for (i = 0; i < argc; ++i) {
103307 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
103308 + if (!argv[i].value) {
103309 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103310 + continue;
103311 + }
103312 + track_frame_size = atoi(argv[i].value);
103313 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
103314 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103315 + continue;
103316 + }
103317 + if (!strcmp(argv[i].key, "initialize-locals")) {
103318 + if (argv[i].value) {
103319 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103320 + continue;
103321 + }
103322 + init_locals = true;
103323 + continue;
103324 + }
103325 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103326 + }
103327 +
103328 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
103329 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
103330 +
103331 + return 0;
103332 +}
103333 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
103334 new file mode 100644
103335 index 0000000..4fae911
103336 --- /dev/null
103337 +++ b/tools/gcc/structleak_plugin.c
103338 @@ -0,0 +1,277 @@
103339 +/*
103340 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
103341 + * Licensed under the GPL v2
103342 + *
103343 + * Note: the choice of the license means that the compilation process is
103344 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103345 + * but for the kernel it doesn't matter since it doesn't link against
103346 + * any of the gcc libraries
103347 + *
103348 + * gcc plugin to forcibly initialize certain local variables that could
103349 + * otherwise leak kernel stack to userland if they aren't properly initialized
103350 + * by later code
103351 + *
103352 + * Homepage: http://pax.grsecurity.net/
103353 + *
103354 + * Usage:
103355 + * $ # for 4.5/4.6/C based 4.7
103356 + * $ 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
103357 + * $ # for C++ based 4.7/4.8+
103358 + * $ 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
103359 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
103360 + *
103361 + * TODO: eliminate redundant initializers
103362 + * increase type coverage
103363 + */
103364 +
103365 +#include "gcc-plugin.h"
103366 +#include "config.h"
103367 +#include "system.h"
103368 +#include "coretypes.h"
103369 +#include "tree.h"
103370 +#include "tree-pass.h"
103371 +#include "intl.h"
103372 +#include "plugin-version.h"
103373 +#include "tm.h"
103374 +#include "toplev.h"
103375 +#include "function.h"
103376 +#include "tree-flow.h"
103377 +#include "plugin.h"
103378 +#include "gimple.h"
103379 +#include "diagnostic.h"
103380 +#include "cfgloop.h"
103381 +#include "langhooks.h"
103382 +
103383 +#if BUILDING_GCC_VERSION >= 4008
103384 +#define TODO_dump_func 0
103385 +#endif
103386 +
103387 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103388 +
103389 +// unused type flag in all versions 4.5-4.8
103390 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
103391 +
103392 +int plugin_is_GPL_compatible;
103393 +void debug_gimple_stmt(gimple gs);
103394 +
103395 +static struct plugin_info structleak_plugin_info = {
103396 + .version = "201304082245",
103397 + .help = "disable\tdo not activate plugin\n",
103398 +};
103399 +
103400 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103401 +{
103402 + *no_add_attrs = true;
103403 +
103404 + // check for types? for now accept everything linux has to offer
103405 + if (TREE_CODE(*node) != FIELD_DECL)
103406 + return NULL_TREE;
103407 +
103408 + *no_add_attrs = false;
103409 + return NULL_TREE;
103410 +}
103411 +
103412 +static struct attribute_spec user_attr = {
103413 + .name = "user",
103414 + .min_length = 0,
103415 + .max_length = 0,
103416 + .decl_required = false,
103417 + .type_required = false,
103418 + .function_type_required = false,
103419 + .handler = handle_user_attribute,
103420 +#if BUILDING_GCC_VERSION >= 4007
103421 + .affects_type_identity = true
103422 +#endif
103423 +};
103424 +
103425 +static void register_attributes(void *event_data, void *data)
103426 +{
103427 + register_attribute(&user_attr);
103428 +// register_attribute(&force_attr);
103429 +}
103430 +
103431 +static tree get_field_type(tree field)
103432 +{
103433 + return strip_array_types(TREE_TYPE(field));
103434 +}
103435 +
103436 +static bool is_userspace_type(tree type)
103437 +{
103438 + tree field;
103439 +
103440 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
103441 + tree fieldtype = get_field_type(field);
103442 + enum tree_code code = TREE_CODE(fieldtype);
103443 +
103444 + if (code == RECORD_TYPE || code == UNION_TYPE)
103445 + if (is_userspace_type(fieldtype))
103446 + return true;
103447 +
103448 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
103449 + return true;
103450 + }
103451 + return false;
103452 +}
103453 +
103454 +static void finish_type(void *event_data, void *data)
103455 +{
103456 + tree type = (tree)event_data;
103457 +
103458 + if (TYPE_USERSPACE(type))
103459 + return;
103460 +
103461 + if (is_userspace_type(type))
103462 + TYPE_USERSPACE(type) = 1;
103463 +}
103464 +
103465 +static void initialize(tree var)
103466 +{
103467 + basic_block bb;
103468 + gimple_stmt_iterator gsi;
103469 + tree initializer;
103470 + gimple init_stmt;
103471 +
103472 + // this is the original entry bb before the forced split
103473 + // TODO: check further BBs in case more splits occured before us
103474 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
103475 +
103476 + // first check if the variable is already initialized, warn otherwise
103477 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103478 + gimple stmt = gsi_stmt(gsi);
103479 + tree rhs1;
103480 +
103481 + // we're looking for an assignment of a single rhs...
103482 + if (!gimple_assign_single_p(stmt))
103483 + continue;
103484 + rhs1 = gimple_assign_rhs1(stmt);
103485 +#if BUILDING_GCC_VERSION >= 4007
103486 + // ... of a non-clobbering expression...
103487 + if (TREE_CLOBBER_P(rhs1))
103488 + continue;
103489 +#endif
103490 + // ... to our variable...
103491 + if (gimple_get_lhs(stmt) != var)
103492 + continue;
103493 + // if it's an initializer then we're good
103494 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
103495 + return;
103496 + }
103497 +
103498 + // these aren't the 0days you're looking for
103499 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
103500 +
103501 + // build the initializer expression
103502 + initializer = build_constructor(TREE_TYPE(var), NULL);
103503 +
103504 + // build the initializer stmt
103505 + init_stmt = gimple_build_assign(var, initializer);
103506 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
103507 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
103508 + update_stmt(init_stmt);
103509 +}
103510 +
103511 +static unsigned int handle_function(void)
103512 +{
103513 + basic_block bb;
103514 + unsigned int ret = 0;
103515 + tree var;
103516 +
103517 +#if BUILDING_GCC_VERSION == 4005
103518 + tree vars;
103519 +#else
103520 + unsigned int i;
103521 +#endif
103522 +
103523 + // split the first bb where we can put the forced initializers
103524 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103525 + if (dom_info_available_p(CDI_DOMINATORS))
103526 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103527 +
103528 + // enumarate all local variables and forcibly initialize our targets
103529 +#if BUILDING_GCC_VERSION == 4005
103530 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
103531 + var = TREE_VALUE(vars);
103532 +#else
103533 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
103534 +#endif
103535 + tree type = TREE_TYPE(var);
103536 +
103537 + gcc_assert(DECL_P(var));
103538 + if (!auto_var_in_fn_p(var, current_function_decl))
103539 + continue;
103540 +
103541 + // only care about structure types
103542 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
103543 + continue;
103544 +
103545 + // if the type is of interest, examine the variable
103546 + if (TYPE_USERSPACE(type))
103547 + initialize(var);
103548 + }
103549 +
103550 + return ret;
103551 +}
103552 +
103553 +static struct gimple_opt_pass structleak_pass = {
103554 + .pass = {
103555 + .type = GIMPLE_PASS,
103556 + .name = "structleak",
103557 +#if BUILDING_GCC_VERSION >= 4008
103558 + .optinfo_flags = OPTGROUP_NONE,
103559 +#endif
103560 + .gate = NULL,
103561 + .execute = handle_function,
103562 + .sub = NULL,
103563 + .next = NULL,
103564 + .static_pass_number = 0,
103565 + .tv_id = TV_NONE,
103566 + .properties_required = PROP_cfg,
103567 + .properties_provided = 0,
103568 + .properties_destroyed = 0,
103569 + .todo_flags_start = 0,
103570 + .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
103571 + }
103572 +};
103573 +
103574 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103575 +{
103576 + int i;
103577 + const char * const plugin_name = plugin_info->base_name;
103578 + const int argc = plugin_info->argc;
103579 + const struct plugin_argument * const argv = plugin_info->argv;
103580 + bool enable = true;
103581 +
103582 + struct register_pass_info structleak_pass_info = {
103583 + .pass = &structleak_pass.pass,
103584 + .reference_pass_name = "ssa",
103585 + .ref_pass_instance_number = 1,
103586 + .pos_op = PASS_POS_INSERT_AFTER
103587 + };
103588 +
103589 + if (!plugin_default_version_check(version, &gcc_version)) {
103590 + error(G_("incompatible gcc/plugin versions"));
103591 + return 1;
103592 + }
103593 +
103594 + if (strcmp(lang_hooks.name, "GNU C")) {
103595 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
103596 + enable = false;
103597 + }
103598 +
103599 + for (i = 0; i < argc; ++i) {
103600 + if (!strcmp(argv[i].key, "disable")) {
103601 + enable = false;
103602 + continue;
103603 + }
103604 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103605 + }
103606 +
103607 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
103608 + if (enable) {
103609 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
103610 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
103611 + }
103612 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103613 +
103614 + return 0;
103615 +}
103616 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
103617 index 6789d78..4afd019e 100644
103618 --- a/tools/perf/util/include/asm/alternative-asm.h
103619 +++ b/tools/perf/util/include/asm/alternative-asm.h
103620 @@ -5,4 +5,7 @@
103621
103622 #define altinstruction_entry #
103623
103624 + .macro pax_force_retaddr rip=0, reload=0
103625 + .endm
103626 +
103627 #endif
103628 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
103629 index 96b919d..c49bb74 100644
103630 --- a/tools/perf/util/include/linux/compiler.h
103631 +++ b/tools/perf/util/include/linux/compiler.h
103632 @@ -18,4 +18,12 @@
103633 #define __force
103634 #endif
103635
103636 +#ifndef __size_overflow
103637 +# define __size_overflow(...)
103638 +#endif
103639 +
103640 +#ifndef __intentional_overflow
103641 +# define __intentional_overflow(...)
103642 +#endif
103643 +
103644 #endif
103645 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
103646 index f18013f..90421df 100644
103647 --- a/virt/kvm/kvm_main.c
103648 +++ b/virt/kvm/kvm_main.c
103649 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
103650
103651 static cpumask_var_t cpus_hardware_enabled;
103652 static int kvm_usage_count = 0;
103653 -static atomic_t hardware_enable_failed;
103654 +static atomic_unchecked_t hardware_enable_failed;
103655
103656 struct kmem_cache *kvm_vcpu_cache;
103657 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
103658
103659 -static __read_mostly struct preempt_ops kvm_preempt_ops;
103660 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
103661 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
103662 +static struct preempt_ops kvm_preempt_ops = {
103663 + .sched_in = kvm_sched_in,
103664 + .sched_out = kvm_sched_out,
103665 +};
103666
103667 struct dentry *kvm_debugfs_dir;
103668
103669 @@ -769,7 +774,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
103670 /* We can read the guest memory with __xxx_user() later on. */
103671 if (user_alloc &&
103672 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
103673 - !access_ok(VERIFY_WRITE,
103674 + !__access_ok(VERIFY_WRITE,
103675 (void __user *)(unsigned long)mem->userspace_addr,
103676 mem->memory_size)))
103677 goto out;
103678 @@ -1881,7 +1886,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
103679 return 0;
103680 }
103681
103682 -static struct file_operations kvm_vcpu_fops = {
103683 +static file_operations_no_const kvm_vcpu_fops __read_only = {
103684 .release = kvm_vcpu_release,
103685 .unlocked_ioctl = kvm_vcpu_ioctl,
103686 #ifdef CONFIG_COMPAT
103687 @@ -2402,7 +2407,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
103688 return 0;
103689 }
103690
103691 -static struct file_operations kvm_vm_fops = {
103692 +static file_operations_no_const kvm_vm_fops __read_only = {
103693 .release = kvm_vm_release,
103694 .unlocked_ioctl = kvm_vm_ioctl,
103695 #ifdef CONFIG_COMPAT
103696 @@ -2500,7 +2505,7 @@ out:
103697 return r;
103698 }
103699
103700 -static struct file_operations kvm_chardev_ops = {
103701 +static file_operations_no_const kvm_chardev_ops __read_only = {
103702 .unlocked_ioctl = kvm_dev_ioctl,
103703 .compat_ioctl = kvm_dev_ioctl,
103704 .llseek = noop_llseek,
103705 @@ -2526,7 +2531,7 @@ static void hardware_enable_nolock(void *junk)
103706
103707 if (r) {
103708 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
103709 - atomic_inc(&hardware_enable_failed);
103710 + atomic_inc_unchecked(&hardware_enable_failed);
103711 printk(KERN_INFO "kvm: enabling virtualization on "
103712 "CPU%d failed\n", cpu);
103713 }
103714 @@ -2580,10 +2585,10 @@ static int hardware_enable_all(void)
103715
103716 kvm_usage_count++;
103717 if (kvm_usage_count == 1) {
103718 - atomic_set(&hardware_enable_failed, 0);
103719 + atomic_set_unchecked(&hardware_enable_failed, 0);
103720 on_each_cpu(hardware_enable_nolock, NULL, 1);
103721
103722 - if (atomic_read(&hardware_enable_failed)) {
103723 + if (atomic_read_unchecked(&hardware_enable_failed)) {
103724 hardware_disable_all_nolock();
103725 r = -EBUSY;
103726 }
103727 @@ -2941,7 +2946,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
103728 kvm_arch_vcpu_put(vcpu);
103729 }
103730
103731 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103732 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103733 struct module *module)
103734 {
103735 int r;
103736 @@ -2977,7 +2982,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103737 if (!vcpu_align)
103738 vcpu_align = __alignof__(struct kvm_vcpu);
103739 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
103740 - 0, NULL);
103741 + SLAB_USERCOPY, NULL);
103742 if (!kvm_vcpu_cache) {
103743 r = -ENOMEM;
103744 goto out_free_3;
103745 @@ -2987,9 +2992,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103746 if (r)
103747 goto out_free;
103748
103749 + pax_open_kernel();
103750 kvm_chardev_ops.owner = module;
103751 kvm_vm_fops.owner = module;
103752 kvm_vcpu_fops.owner = module;
103753 + pax_close_kernel();
103754
103755 r = misc_register(&kvm_dev);
103756 if (r) {
103757 @@ -2999,9 +3006,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103758
103759 register_syscore_ops(&kvm_syscore_ops);
103760
103761 - kvm_preempt_ops.sched_in = kvm_sched_in;
103762 - kvm_preempt_ops.sched_out = kvm_sched_out;
103763 -
103764 r = kvm_init_debug();
103765 if (r) {
103766 printk(KERN_ERR "kvm: create debugfs files failed\n");